2016-09-06 11:29:50 +00:00
|
|
|
/**
|
2016-09-11 20:20:15 +00:00
|
|
|
* Author......: See docs/credits.txt
|
2016-09-06 11:29:50 +00:00
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common.h"
|
2016-09-06 17:44:27 +00:00
|
|
|
#include "types.h"
|
2016-09-06 11:29:50 +00:00
|
|
|
#include "memory.h"
|
2016-10-09 20:41:55 +00:00
|
|
|
#include "event.h"
|
|
|
|
#include "dynloader.h"
|
2016-11-05 22:19:13 +00:00
|
|
|
#include "shared.h"
|
|
|
|
#include "folder.h"
|
2016-09-28 20:52:42 +00:00
|
|
|
#include "hwmon.h"
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
// general functions
|
|
|
|
|
|
|
|
static int get_adapters_num_adl (hashcat_ctx_t *hashcat_ctx, int *iNumberAdapters)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2021-06-10 18:26:24 +00:00
|
|
|
if (hm_ADL_Adapter_NumberOfAdapters_Get (hashcat_ctx, iNumberAdapters) == -1) return -1;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2016-11-14 00:56:31 +00:00
|
|
|
if (iNumberAdapters == NULL)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "No ADL adapters found.");
|
2016-09-06 11:29:50 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
static int hm_get_adapter_index_nvapi (hashcat_ctx_t *hashcat_ctx, HM_ADAPTER_NVAPI *nvapiGPUHandle)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
|
|
|
NvU32 pGpuCount;
|
|
|
|
|
2016-10-29 22:21:05 +00:00
|
|
|
if (hm_NvAPI_EnumPhysicalGPUs (hashcat_ctx, nvapiGPUHandle, &pGpuCount) == -1) return 0;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
|
|
|
if (pGpuCount == 0)
|
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "No NvAPI adapters found.");
|
2016-09-06 11:29:50 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (pGpuCount);
|
|
|
|
}
|
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
static int hm_get_adapter_index_nvml (hashcat_ctx_t *hashcat_ctx, HM_ADAPTER_NVML *nvmlGPUHandle)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2016-10-11 10:18:06 +00:00
|
|
|
unsigned int deviceCount = 0;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2016-10-11 10:18:06 +00:00
|
|
|
hm_NVML_nvmlDeviceGetCount (hashcat_ctx, &deviceCount);
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2016-10-11 10:18:06 +00:00
|
|
|
if (deviceCount == 0)
|
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "No NVML adapters found.");
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2016-10-11 10:18:06 +00:00
|
|
|
return 0;
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
|
|
|
|
2016-10-11 10:18:06 +00:00
|
|
|
for (u32 i = 0; i < deviceCount; i++)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2016-10-11 10:18:06 +00:00
|
|
|
if (hm_NVML_nvmlDeviceGetHandleByIndex (hashcat_ctx, i, &nvmlGPUHandle[i]) == -1) break;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2016-10-11 10:18:06 +00:00
|
|
|
// can be used to determine if the device by index matches the cuda device by index
|
|
|
|
// char name[100]; memset (name, 0, sizeof (name));
|
|
|
|
// hm_NVML_nvmlDeviceGetName (hashcat_ctx, nvGPUHandle[i], name, sizeof (name) - 1);
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
|
|
|
|
2016-10-11 10:18:06 +00:00
|
|
|
return (deviceCount);
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
int hm_get_threshold_slowdown_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-04-25 12:45:17 +00:00
|
|
|
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
|
|
|
|
backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
|
2016-10-06 09:10:00 +00:00
|
|
|
|
2016-09-28 21:07:25 +00:00
|
|
|
if (hwmon_ctx->enabled == false) return -1;
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].threshold_slowdown_get_supported == false) return -1;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
int target = 0;
|
|
|
|
|
|
|
|
if (hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_THRESHOLD_SLOWDOWN, (unsigned int *) &target) == -1)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
hwmon_ctx->hm_device[backend_device_idx].threshold_slowdown_get_supported = false;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
return -1;
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
return target;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_adl)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
2021-07-08 07:04:14 +00:00
|
|
|
else if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
|
2016-11-21 16:15:55 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
int target = 0;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_THRESHOLD_SLOWDOWN, (unsigned int *) &target) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].threshold_slowdown_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return target;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
2016-11-20 14:59:27 +00:00
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
hwmon_ctx->hm_device[backend_device_idx].threshold_slowdown_get_supported = false;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2016-09-06 11:29:50 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
int hm_get_threshold_shutdown_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-04-25 12:45:17 +00:00
|
|
|
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
|
|
|
|
backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
|
2016-10-06 09:10:00 +00:00
|
|
|
|
2016-09-28 21:07:25 +00:00
|
|
|
if (hwmon_ctx->enabled == false) return -1;
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].threshold_shutdown_get_supported == false) return -1;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
int target = 0;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_THRESHOLD_SHUTDOWN, (unsigned int *) &target) == -1)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
hwmon_ctx->hm_device[backend_device_idx].threshold_shutdown_get_supported = false;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
return -1;
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
|
|
|
|
return target;
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
|
2016-11-21 16:15:55 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_adl)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5)
|
|
|
|
{
|
2016-11-21 16:15:55 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
}
|
|
|
|
else if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6)
|
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
2016-11-21 16:15:55 +00:00
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
int target = 0;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_THRESHOLD_SHUTDOWN, (unsigned int *) &target) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].threshold_shutdown_get_supported = false;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return target;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
2016-11-20 14:59:27 +00:00
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
hwmon_ctx->hm_device[backend_device_idx].threshold_shutdown_get_supported = false;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2016-09-06 11:29:50 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
int hm_get_temperature_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-04-25 12:45:17 +00:00
|
|
|
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
|
|
|
|
backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
|
2016-10-06 09:10:00 +00:00
|
|
|
|
2016-09-28 21:07:25 +00:00
|
|
|
if (hwmon_ctx->enabled == false) return -1;
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported == false) return -1;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
int temperature = 0;
|
|
|
|
|
|
|
|
if (hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_GPU, (u32 *) &temperature) == -1)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return temperature;
|
|
|
|
}
|
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_CPU)
|
2021-06-12 18:13:31 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
#if defined (__APPLE__)
|
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_platform_vendor_id == VENDOR_ID_APPLE)
|
2021-06-12 18:13:31 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_iokit)
|
2021-06-12 18:13:31 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
double temperature = 0.0;
|
2021-06-12 18:13:31 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
char *key = HM_IOKIT_SMC_CPU_PROXIMITY;
|
|
|
|
|
2022-03-31 17:19:16 +00:00
|
|
|
if (hm_IOKIT_SMCGetTemperature (hashcat_ctx, key, &temperature) == -1)
|
2021-06-12 18:13:31 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
|
2021-06-12 18:13:31 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2021-06-12 18:13:31 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return (int) temperature;
|
2021-06-12 18:13:31 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-08 07:04:14 +00:00
|
|
|
#endif
|
2021-07-10 06:43:15 +00:00
|
|
|
|
|
|
|
if (hwmon_ctx->hm_sysfs_cpu)
|
|
|
|
{
|
|
|
|
int temperature = 0;
|
|
|
|
|
|
|
|
if (hm_SYSFS_CPU_get_temperature_current (hashcat_ctx, &temperature) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return temperature;
|
|
|
|
}
|
2021-06-12 18:13:31 +00:00
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
#if defined (__APPLE__)
|
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_platform_vendor_id == VENDOR_ID_APPLE)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_iokit)
|
2016-11-21 16:15:55 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
double temperature = 0.0;
|
2016-11-21 16:15:55 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
char *key = HM_IOKIT_SMC_GPU_PROXIMITY;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_INTEL_BEIGNET)
|
|
|
|
{
|
|
|
|
key = HM_IOKIT_SMC_PECI_GPU;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hm_IOKIT_SMCGetTemperature (hashcat_ctx, key, &temperature) == -1)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return (int) temperature;
|
2016-11-21 16:15:55 +00:00
|
|
|
}
|
2021-07-08 07:04:14 +00:00
|
|
|
}
|
|
|
|
#endif
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
|
2021-07-08 07:04:14 +00:00
|
|
|
{
|
|
|
|
if (hwmon_ctx->hm_adl)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5)
|
|
|
|
{
|
|
|
|
ADLTemperature Temperature;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
Temperature.iSize = sizeof (ADLTemperature);
|
|
|
|
|
|
|
|
if (hm_ADL_Overdrive5_Temperature_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, 0, &Temperature) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Temperature.iTemperature / 1000;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6)
|
|
|
|
{
|
|
|
|
int Temperature = 0;
|
|
|
|
|
|
|
|
if (hm_ADL_Overdrive6_Temperature_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &Temperature) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Temperature / 1000;
|
|
|
|
}
|
2021-07-26 05:48:56 +00:00
|
|
|
|
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].od_version == 8)
|
|
|
|
{
|
|
|
|
ADLPMLogDataOutput odlpDataOutput;
|
|
|
|
|
|
|
|
memset (&odlpDataOutput, 0, sizeof (ADLPMLogDataOutput));
|
|
|
|
|
|
|
|
if (hm_ADL2_New_QueryPMLogData_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &odlpDataOutput) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return odlpDataOutput.sensors[PMLOG_TEMPERATURE_EDGE].value;
|
|
|
|
}
|
2021-07-08 07:04:14 +00:00
|
|
|
}
|
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
if (hwmon_ctx->hm_sysfs_amdgpu)
|
2021-07-08 07:04:14 +00:00
|
|
|
{
|
|
|
|
int temperature = 0;
|
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
if (hm_SYSFS_AMDGPU_get_temperature_current (hashcat_ctx, backend_device_idx, &temperature) == -1)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return temperature;
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
2017-11-05 08:52:29 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
2016-11-21 16:15:55 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
int temperature = 0;
|
2016-11-05 22:19:13 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_TEMPERATURE_GPU, (u32 *) &temperature) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return temperature;
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
2016-11-21 16:15:55 +00:00
|
|
|
}
|
2016-11-20 14:59:27 +00:00
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2016-09-06 11:29:50 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
int hm_get_fanpolicy_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-04-25 12:45:17 +00:00
|
|
|
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
|
|
|
|
backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
|
2016-10-06 09:10:00 +00:00
|
|
|
|
2016-09-28 21:07:25 +00:00
|
|
|
if (hwmon_ctx->enabled == false) return -1;
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].fanpolicy_get_supported == false) return -1;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2016-11-20 14:59:27 +00:00
|
|
|
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_adl)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5)
|
|
|
|
{
|
|
|
|
ADLFanSpeedValue lpFanSpeedValue;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
memset (&lpFanSpeedValue, 0, sizeof (lpFanSpeedValue));
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
lpFanSpeedValue.iSize = sizeof (lpFanSpeedValue);
|
|
|
|
lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, 0, &lpFanSpeedValue) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].fanpolicy_get_supported = false;
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false;
|
2016-11-21 16:15:55 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (lpFanSpeedValue.iFanSpeed & ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED) ? 0 : 1;
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6)
|
|
|
|
{
|
2021-07-26 05:48:56 +00:00
|
|
|
ADLOD6FanSpeedInfo lpFanSpeedInfo;
|
|
|
|
|
|
|
|
memset (&lpFanSpeedInfo, 0, sizeof (lpFanSpeedInfo));
|
|
|
|
|
|
|
|
if (hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &lpFanSpeedInfo) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].fanpolicy_get_supported = false;
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2021-07-26 05:48:56 +00:00
|
|
|
|
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].od_version == 8)
|
|
|
|
{
|
|
|
|
ADLPMLogDataOutput odlpDataOutput;
|
|
|
|
|
|
|
|
memset (&odlpDataOutput, 0, sizeof (ADLPMLogDataOutput));
|
|
|
|
|
|
|
|
if (hm_ADL2_New_QueryPMLogData_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &odlpDataOutput) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].fanpolicy_get_supported = false;
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return odlpDataOutput.sensors[PMLOG_FAN_PERCENTAGE].supported;
|
|
|
|
}
|
2016-11-21 16:15:55 +00:00
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
if (hwmon_ctx->hm_sysfs_amdgpu)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
2017-11-05 08:52:29 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
|
2016-11-05 22:19:13 +00:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
hwmon_ctx->hm_device[backend_device_idx].fanpolicy_get_supported = false;
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2016-09-06 11:29:50 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-06-19 18:32:07 +00:00
|
|
|
#if defined(__APPLE__)
|
|
|
|
int hm_get_fanspeed_apple (hashcat_ctx_t *hashcat_ctx, char *fan_speed_buf)
|
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
|
2021-06-19 18:32:07 +00:00
|
|
|
|
|
|
|
if (hwmon_ctx->enabled == false) return -1;
|
|
|
|
|
|
|
|
if (hwmon_ctx->hm_iokit)
|
|
|
|
{
|
|
|
|
if (hm_IOKIT_get_fan_speed_current (hashcat_ctx, fan_speed_buf) == 0)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
int hm_get_fanspeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-04-25 12:45:17 +00:00
|
|
|
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
|
|
|
|
backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
|
2016-10-06 09:10:00 +00:00
|
|
|
|
2016-09-28 21:07:25 +00:00
|
|
|
if (hwmon_ctx->enabled == false) return -1;
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported == false) return -1;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
int speed = 0;
|
|
|
|
|
|
|
|
if (hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, (u32 *) &speed) == -1)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return speed;
|
|
|
|
}
|
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_adl)
|
2016-11-21 16:15:55 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5)
|
|
|
|
{
|
|
|
|
ADLFanSpeedValue lpFanSpeedValue;
|
2016-11-21 16:15:55 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
memset (&lpFanSpeedValue, 0, sizeof (lpFanSpeedValue));
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
lpFanSpeedValue.iSize = sizeof (lpFanSpeedValue);
|
|
|
|
lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
|
|
|
|
lpFanSpeedValue.iFlags = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, 0, &lpFanSpeedValue) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return lpFanSpeedValue.iFanSpeed;
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].od_version == 6)
|
|
|
|
{
|
|
|
|
ADLOD6FanSpeedInfo faninfo;
|
|
|
|
|
|
|
|
memset (&faninfo, 0, sizeof (faninfo));
|
|
|
|
|
|
|
|
if (hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &faninfo) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return faninfo.iFanSpeedPercent;
|
|
|
|
}
|
2021-07-26 05:48:56 +00:00
|
|
|
|
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].od_version == 8)
|
|
|
|
{
|
|
|
|
ADLPMLogDataOutput odlpDataOutput;
|
|
|
|
|
|
|
|
memset (&odlpDataOutput, 0, sizeof (ADLPMLogDataOutput));
|
|
|
|
|
|
|
|
if (hm_ADL2_New_QueryPMLogData_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &odlpDataOutput) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return odlpDataOutput.sensors[PMLOG_FAN_PERCENTAGE].value;
|
|
|
|
}
|
2016-11-21 16:15:55 +00:00
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
if (hwmon_ctx->hm_sysfs_amdgpu)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
int speed = 0;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
if (hm_SYSFS_AMDGPU_get_fan_speed_current (hashcat_ctx, backend_device_idx, &speed) == -1)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return speed;
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
2016-11-20 14:59:27 +00:00
|
|
|
}
|
2017-11-05 08:52:29 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
|
2016-11-20 14:59:27 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
2016-11-21 16:15:55 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
int speed = 0;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, (u32 *) &speed) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return speed;
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
2016-11-21 16:15:55 +00:00
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2016-09-06 11:29:50 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
int hm_get_buslanes_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-04-25 12:45:17 +00:00
|
|
|
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
|
|
|
|
backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
|
2016-10-06 09:10:00 +00:00
|
|
|
|
2016-09-28 21:07:25 +00:00
|
|
|
if (hwmon_ctx->enabled == false) return -1;
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported == false) return -1;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
unsigned int currLinkWidth;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &currLinkWidth) == -1)
|
2016-11-21 16:15:55 +00:00
|
|
|
{
|
2019-04-30 11:38:44 +00:00
|
|
|
hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported = false;
|
2016-11-21 16:15:55 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
return currLinkWidth;
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
2016-11-06 11:46:51 +00:00
|
|
|
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
|
2016-11-21 16:15:55 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_adl)
|
|
|
|
{
|
2021-07-26 05:48:56 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5)
|
|
|
|
{
|
|
|
|
ADLPMActivity PMActivity;
|
2016-11-21 16:15:55 +00:00
|
|
|
|
2021-07-26 05:48:56 +00:00
|
|
|
PMActivity.iSize = sizeof (ADLPMActivity);
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-26 05:48:56 +00:00
|
|
|
if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &PMActivity) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported = false;
|
2021-07-08 07:04:14 +00:00
|
|
|
|
2021-07-26 05:48:56 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PMActivity.iCurrentBusLanes;
|
2021-07-08 07:04:14 +00:00
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-27 10:02:27 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].od_version == 8)
|
|
|
|
{
|
|
|
|
ADLPMLogDataOutput odlpDataOutput;
|
|
|
|
|
|
|
|
memset (&odlpDataOutput, 0, sizeof (ADLPMLogDataOutput));
|
|
|
|
|
|
|
|
if (hm_ADL2_New_QueryPMLogData_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &odlpDataOutput) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return odlpDataOutput.sensors[PMLOG_BUS_LANES].value;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
if (hwmon_ctx->hm_sysfs_amdgpu)
|
2021-07-08 07:04:14 +00:00
|
|
|
{
|
|
|
|
int lanes;
|
2016-11-06 11:46:51 +00:00
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
if (hm_SYSFS_AMDGPU_get_pp_dpm_pcie (hashcat_ctx, backend_device_idx, &lanes) == -1)
|
2021-07-08 07:04:14 +00:00
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported = false;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return lanes;
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
|
2016-11-21 16:15:55 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
unsigned int currLinkWidth;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &currLinkWidth) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return currLinkWidth;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
2016-11-20 14:59:27 +00:00
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported = false;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2016-09-06 11:29:50 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
int hm_get_utilization_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-04-25 12:45:17 +00:00
|
|
|
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
|
|
|
|
backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
|
2016-10-06 09:10:00 +00:00
|
|
|
|
2016-09-28 21:07:25 +00:00
|
|
|
if (hwmon_ctx->enabled == false) return -1;
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported == false) return -1;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
nvmlUtilization_t utilization;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &utilization) == -1)
|
2016-11-21 16:15:55 +00:00
|
|
|
{
|
2019-04-30 11:38:44 +00:00
|
|
|
hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false;
|
2016-11-21 16:15:55 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
return utilization.gpu;
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-15 21:20:03 +00:00
|
|
|
#if defined(__APPLE__)
|
|
|
|
if (backend_ctx->devices_param[backend_device_idx].is_metal == true || backend_ctx->devices_param[backend_device_idx].is_opencl == true)
|
|
|
|
{
|
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_platform_vendor_id == VENDOR_ID_APPLE)
|
|
|
|
{
|
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
|
|
|
|
{
|
|
|
|
if (hwmon_ctx->hm_iokit)
|
|
|
|
{
|
|
|
|
int utilization = 0;
|
|
|
|
|
|
|
|
if (hm_IOKIT_get_utilization_current (hashcat_ctx, &utilization) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return utilization;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
|
2016-11-21 16:15:55 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_adl)
|
|
|
|
{
|
2021-07-26 05:48:56 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5)
|
|
|
|
{
|
|
|
|
ADLPMActivity PMActivity;
|
2016-11-21 16:15:55 +00:00
|
|
|
|
2021-07-26 05:48:56 +00:00
|
|
|
PMActivity.iSize = sizeof (ADLPMActivity);
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-26 05:48:56 +00:00
|
|
|
if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &PMActivity) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false;
|
2021-07-08 07:04:14 +00:00
|
|
|
|
2021-07-26 05:48:56 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PMActivity.iActivityPercent;
|
2021-07-08 07:04:14 +00:00
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-26 05:48:56 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].od_version == 8)
|
|
|
|
{
|
|
|
|
ADLPMLogDataOutput odlpDataOutput;
|
|
|
|
|
|
|
|
memset (&odlpDataOutput, 0, sizeof (ADLPMLogDataOutput));
|
|
|
|
|
|
|
|
if (hm_ADL2_New_QueryPMLogData_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &odlpDataOutput) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return odlpDataOutput.sensors[PMLOG_INFO_ACTIVITY_GFX].value;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
if (hwmon_ctx->hm_sysfs_amdgpu)
|
2021-07-08 07:04:14 +00:00
|
|
|
{
|
|
|
|
int util;
|
2021-06-07 07:34:34 +00:00
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
if (hm_SYSFS_AMDGPU_get_gpu_busy_percent (hashcat_ctx, backend_device_idx, &util) == -1)
|
2021-07-08 07:04:14 +00:00
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false;
|
2021-06-07 07:34:34 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2021-06-07 07:34:34 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return util;
|
2021-06-07 07:34:34 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
nvmlUtilization_t utilization;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &utilization) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return utilization.gpu;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
2016-11-20 14:59:27 +00:00
|
|
|
}
|
2021-07-10 12:24:51 +00:00
|
|
|
|
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_CPU)
|
|
|
|
{
|
|
|
|
if (hwmon_ctx->hm_sysfs_cpu)
|
|
|
|
{
|
|
|
|
int utilization = 0;
|
|
|
|
|
|
|
|
if (hm_SYSFS_CPU_get_utilization_current (hashcat_ctx, &utilization) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return utilization;
|
|
|
|
}
|
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2016-09-06 11:29:50 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
int hm_get_memoryspeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-04-25 12:45:17 +00:00
|
|
|
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
|
|
|
|
backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
|
2016-10-06 09:10:00 +00:00
|
|
|
|
2016-09-28 21:07:25 +00:00
|
|
|
if (hwmon_ctx->enabled == false) return -1;
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported == false) return -1;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
unsigned int clockfreq;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_CLOCK_MEM, &clockfreq) == -1)
|
2016-11-21 16:15:55 +00:00
|
|
|
{
|
2019-04-30 11:38:44 +00:00
|
|
|
hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported = false;
|
2016-11-21 16:15:55 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
return clockfreq;
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
2016-11-06 11:46:51 +00:00
|
|
|
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
|
2016-11-21 16:15:55 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_adl)
|
|
|
|
{
|
2021-07-26 05:48:56 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5)
|
|
|
|
{
|
|
|
|
ADLPMActivity PMActivity;
|
2016-11-21 16:15:55 +00:00
|
|
|
|
2021-07-26 05:48:56 +00:00
|
|
|
PMActivity.iSize = sizeof (ADLPMActivity);
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-26 05:48:56 +00:00
|
|
|
if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &PMActivity) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported = false;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-26 05:48:56 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PMActivity.iMemoryClock / 100;
|
2021-07-08 07:04:14 +00:00
|
|
|
}
|
|
|
|
|
2021-07-26 05:48:56 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].od_version == 8)
|
|
|
|
{
|
|
|
|
ADLPMLogDataOutput odlpDataOutput;
|
|
|
|
|
|
|
|
memset (&odlpDataOutput, 0, sizeof (ADLPMLogDataOutput));
|
|
|
|
|
|
|
|
if (hm_ADL2_New_QueryPMLogData_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &odlpDataOutput) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return odlpDataOutput.sensors[PMLOG_CLK_MEMCLK].value;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
if (hwmon_ctx->hm_sysfs_amdgpu)
|
2021-07-08 07:04:14 +00:00
|
|
|
{
|
|
|
|
int clockfreq;
|
2016-11-06 11:46:51 +00:00
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
if (hm_SYSFS_AMDGPU_get_pp_dpm_mclk (hashcat_ctx, backend_device_idx, &clockfreq) == -1)
|
2021-07-08 07:04:14 +00:00
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported = false;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return clockfreq;
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
|
2016-11-21 16:15:55 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
unsigned int clockfreq;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_CLOCK_MEM, &clockfreq) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported = false;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return clockfreq;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
2016-11-20 14:59:27 +00:00
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported = false;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2016-09-06 11:29:50 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
int hm_get_corespeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-04-25 12:45:17 +00:00
|
|
|
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
|
|
|
|
backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
|
2016-10-06 09:10:00 +00:00
|
|
|
|
2016-09-28 21:07:25 +00:00
|
|
|
if (hwmon_ctx->enabled == false) return -1;
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported == false) return -1;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
unsigned int clockfreq;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_CLOCK_SM, &clockfreq) == -1)
|
2016-11-21 16:15:55 +00:00
|
|
|
{
|
2019-04-30 11:38:44 +00:00
|
|
|
hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported = false;
|
2016-11-21 16:15:55 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
return clockfreq;
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
2016-11-06 11:46:51 +00:00
|
|
|
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
|
2016-11-21 16:15:55 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_adl)
|
|
|
|
{
|
2021-07-26 05:48:56 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].od_version == 5)
|
|
|
|
{
|
|
|
|
ADLPMActivity PMActivity;
|
2016-11-21 16:15:55 +00:00
|
|
|
|
2021-07-26 05:48:56 +00:00
|
|
|
PMActivity.iSize = sizeof (ADLPMActivity);
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-26 05:48:56 +00:00
|
|
|
if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &PMActivity) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported = false;
|
2021-07-08 07:04:14 +00:00
|
|
|
|
2021-07-26 05:48:56 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PMActivity.iEngineClock / 100;
|
2021-07-08 07:04:14 +00:00
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-26 05:48:56 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].od_version == 8)
|
|
|
|
{
|
|
|
|
ADLPMLogDataOutput odlpDataOutput;
|
|
|
|
|
|
|
|
memset (&odlpDataOutput, 0, sizeof (ADLPMLogDataOutput));
|
|
|
|
|
|
|
|
if (hm_ADL2_New_QueryPMLogData_Get (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].adl, &odlpDataOutput) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported = false;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return odlpDataOutput.sensors[PMLOG_CLK_GFXCLK].value;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
if (hwmon_ctx->hm_sysfs_amdgpu)
|
2021-07-08 07:04:14 +00:00
|
|
|
{
|
|
|
|
int clockfreq;
|
2016-11-06 11:46:51 +00:00
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
if (hm_SYSFS_AMDGPU_get_pp_dpm_sclk (hashcat_ctx, backend_device_idx, &clockfreq) == -1)
|
2021-07-08 07:04:14 +00:00
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported = false;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return clockfreq;
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
|
2016-11-21 16:15:55 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
unsigned int clockfreq;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, NVML_CLOCK_SM, &clockfreq) == -1)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported = false;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return clockfreq;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
2016-11-20 14:59:27 +00:00
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
}
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported = false;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2016-09-06 11:29:50 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
int hm_get_throttle_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2019-04-25 12:45:17 +00:00
|
|
|
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
|
|
|
|
backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
|
2016-10-06 09:10:00 +00:00
|
|
|
|
2016-09-28 21:07:25 +00:00
|
|
|
if (hwmon_ctx->enabled == false) return -1;
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
if (hwmon_ctx->hm_device[backend_device_idx].throttle_get_supported == false) return -1;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].is_cuda == true)
|
2016-09-06 11:29:50 +00:00
|
|
|
{
|
2016-11-20 14:59:27 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
|
|
|
{
|
|
|
|
/* this is triggered by mask generator, too. therefore useless
|
|
|
|
unsigned long long clocksThrottleReasons = 0;
|
|
|
|
unsigned long long supportedThrottleReasons = 0;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
if (hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &clocksThrottleReasons) == -1) return -1;
|
|
|
|
if (hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &supportedThrottleReasons) == -1) return -1;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2016-11-20 14:59:27 +00:00
|
|
|
clocksThrottleReasons &= supportedThrottleReasons;
|
|
|
|
clocksThrottleReasons &= ~nvmlClocksThrottleReasonGpuIdle;
|
|
|
|
clocksThrottleReasons &= ~nvmlClocksThrottleReasonApplicationsClocksSetting;
|
|
|
|
clocksThrottleReasons &= ~nvmlClocksThrottleReasonUnknown;
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2019-04-25 12:45:17 +00:00
|
|
|
if (backend_ctx->kernel_power_final)
|
2016-11-20 14:59:27 +00:00
|
|
|
{
|
|
|
|
clocksThrottleReasons &= ~nvmlClocksThrottleReasonHwSlowdown;
|
|
|
|
}
|
2016-09-06 11:29:50 +00:00
|
|
|
|
2016-11-20 14:59:27 +00:00
|
|
|
return (clocksThrottleReasons != nvmlClocksThrottleReasonNone);
|
|
|
|
*/
|
|
|
|
}
|
2016-10-10 09:03:11 +00:00
|
|
|
|
|
|
|
if (hwmon_ctx->hm_nvapi)
|
|
|
|
{
|
2017-12-01 14:19:10 +00:00
|
|
|
NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 perfPolicies_info;
|
|
|
|
NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 perfPolicies_status;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2017-12-01 14:19:10 +00:00
|
|
|
memset (&perfPolicies_info, 0, sizeof (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1));
|
|
|
|
memset (&perfPolicies_status, 0, sizeof (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1));
|
2016-09-28 13:26:56 +00:00
|
|
|
|
2017-12-01 14:19:10 +00:00
|
|
|
perfPolicies_info.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1, 1);
|
|
|
|
perfPolicies_status.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1, 1);
|
2016-11-05 22:19:13 +00:00
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvapi, &perfPolicies_info);
|
2016-11-05 22:19:13 +00:00
|
|
|
|
2017-12-01 14:19:10 +00:00
|
|
|
perfPolicies_status.info_value = perfPolicies_info.info_value;
|
2016-11-20 14:59:27 +00:00
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvapi, &perfPolicies_status);
|
2016-11-21 16:15:55 +00:00
|
|
|
|
2017-12-01 14:19:10 +00:00
|
|
|
return perfPolicies_status.throttle & 2;
|
2016-11-21 16:15:55 +00:00
|
|
|
}
|
2016-11-05 22:19:13 +00:00
|
|
|
}
|
|
|
|
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].is_opencl == true) || (backend_ctx->devices_param[backend_device_idx].is_hip == true))
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) || (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
|
2021-07-08 07:04:14 +00:00
|
|
|
{
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
|
|
|
{
|
|
|
|
/* this is triggered by mask generator, too. therefore useless
|
|
|
|
unsigned long long clocksThrottleReasons = 0;
|
|
|
|
unsigned long long supportedThrottleReasons = 0;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &clocksThrottleReasons) == -1) return -1;
|
|
|
|
if (hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvml, &supportedThrottleReasons) == -1) return -1;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
clocksThrottleReasons &= supportedThrottleReasons;
|
|
|
|
clocksThrottleReasons &= ~nvmlClocksThrottleReasonGpuIdle;
|
|
|
|
clocksThrottleReasons &= ~nvmlClocksThrottleReasonApplicationsClocksSetting;
|
|
|
|
clocksThrottleReasons &= ~nvmlClocksThrottleReasonUnknown;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (backend_ctx->kernel_power_final)
|
|
|
|
{
|
|
|
|
clocksThrottleReasons &= ~nvmlClocksThrottleReasonHwSlowdown;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return (clocksThrottleReasons != nvmlClocksThrottleReasonNone);
|
|
|
|
*/
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_nvapi)
|
|
|
|
{
|
|
|
|
NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 perfPolicies_info;
|
|
|
|
NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 perfPolicies_status;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
memset (&perfPolicies_info, 0, sizeof (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1));
|
|
|
|
memset (&perfPolicies_status, 0, sizeof (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1));
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
perfPolicies_info.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1, 1);
|
|
|
|
perfPolicies_status.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1, 1);
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvapi, &perfPolicies_info);
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
perfPolicies_status.info_value = perfPolicies_info.info_value;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx, hwmon_ctx->hm_device[backend_device_idx].nvapi, &perfPolicies_status);
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
return perfPolicies_status.throttle & 2;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
hwmon_ctx->hm_device[backend_device_idx].throttle_get_supported = false;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2016-11-05 22:19:13 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-10-06 09:10:00 +00:00
|
|
|
int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
2016-09-28 13:26:56 +00:00
|
|
|
{
|
2016-10-06 09:10:00 +00:00
|
|
|
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
|
2019-04-25 12:45:17 +00:00
|
|
|
backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
|
2016-10-06 09:10:00 +00:00
|
|
|
user_options_t *user_options = hashcat_ctx->user_options;
|
|
|
|
|
2016-09-28 13:26:56 +00:00
|
|
|
hwmon_ctx->enabled = false;
|
|
|
|
|
2018-08-28 20:28:44 +00:00
|
|
|
#if !defined (WITH_HWMON)
|
|
|
|
return 0;
|
|
|
|
#endif // WITH_HWMON
|
|
|
|
|
2021-06-12 08:47:48 +00:00
|
|
|
if (user_options->hash_info == true) return 0;
|
|
|
|
if (user_options->keyspace == true) return 0;
|
|
|
|
if (user_options->left == true) return 0;
|
|
|
|
if (user_options->show == true) return 0;
|
|
|
|
if (user_options->stdout_flag == true) return 0;
|
|
|
|
if (user_options->usage == true) return 0;
|
|
|
|
if (user_options->version == true) return 0;
|
|
|
|
if (user_options->identify == true) return 0;
|
|
|
|
if (user_options->hwmon_disable == true) return 0;
|
2022-02-13 11:33:11 +00:00
|
|
|
if (user_options->backend_info > 0) return 0;
|
2016-09-28 13:26:56 +00:00
|
|
|
|
2016-11-20 21:54:52 +00:00
|
|
|
hwmon_ctx->hm_device = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t));
|
2016-09-28 13:26:56 +00:00
|
|
|
|
2016-09-28 20:28:44 +00:00
|
|
|
/**
|
|
|
|
* Initialize shared libraries
|
|
|
|
*/
|
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
hm_attrs_t *hm_adapters_adl = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t));
|
|
|
|
hm_attrs_t *hm_adapters_nvapi = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t));
|
|
|
|
hm_attrs_t *hm_adapters_nvml = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t));
|
|
|
|
hm_attrs_t *hm_adapters_sysfs_amdgpu = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t));
|
2021-07-10 06:43:15 +00:00
|
|
|
hm_attrs_t *hm_adapters_sysfs_cpu = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t));
|
2021-07-09 18:48:10 +00:00
|
|
|
hm_attrs_t *hm_adapters_iokit = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t));
|
|
|
|
|
|
|
|
#define FREE_ADAPTERS \
|
|
|
|
do { \
|
|
|
|
hcfree (hm_adapters_adl); \
|
|
|
|
hcfree (hm_adapters_nvapi); \
|
|
|
|
hcfree (hm_adapters_nvml); \
|
|
|
|
hcfree (hm_adapters_sysfs_amdgpu); \
|
2021-07-10 06:43:15 +00:00
|
|
|
hcfree (hm_adapters_sysfs_cpu); \
|
2021-07-09 18:48:10 +00:00
|
|
|
hcfree (hm_adapters_iokit); \
|
2020-06-13 09:19:00 +00:00
|
|
|
} while (0)
|
2017-02-14 11:30:15 +00:00
|
|
|
|
2019-04-25 12:45:17 +00:00
|
|
|
if (backend_ctx->need_nvml == true)
|
2016-09-28 20:28:44 +00:00
|
|
|
{
|
2017-02-14 10:48:18 +00:00
|
|
|
hwmon_ctx->hm_nvml = (NVML_PTR *) hcmalloc (sizeof (NVML_PTR));
|
2016-10-09 20:41:55 +00:00
|
|
|
|
|
|
|
if (nvml_init (hashcat_ctx) == -1)
|
|
|
|
{
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (hwmon_ctx->hm_nvml);
|
2016-10-09 20:41:55 +00:00
|
|
|
|
|
|
|
hwmon_ctx->hm_nvml = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-25 12:45:17 +00:00
|
|
|
if ((backend_ctx->need_nvapi == true) && (hwmon_ctx->hm_nvml)) // nvapi can't work alone, we need nvml, too
|
2016-10-09 20:41:55 +00:00
|
|
|
{
|
2017-02-14 10:48:18 +00:00
|
|
|
hwmon_ctx->hm_nvapi = (NVAPI_PTR *) hcmalloc (sizeof (NVAPI_PTR));
|
2016-10-09 20:41:55 +00:00
|
|
|
|
|
|
|
if (nvapi_init (hashcat_ctx) == -1)
|
|
|
|
{
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (hwmon_ctx->hm_nvapi);
|
2016-10-09 20:41:55 +00:00
|
|
|
|
|
|
|
hwmon_ctx->hm_nvapi = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-25 12:45:17 +00:00
|
|
|
if (backend_ctx->need_adl == true)
|
2016-10-09 20:41:55 +00:00
|
|
|
{
|
2017-02-14 10:48:18 +00:00
|
|
|
hwmon_ctx->hm_adl = (ADL_PTR *) hcmalloc (sizeof (ADL_PTR));
|
2016-10-09 20:41:55 +00:00
|
|
|
|
|
|
|
if (adl_init (hashcat_ctx) == -1)
|
|
|
|
{
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (hwmon_ctx->hm_adl);
|
2016-10-09 20:41:55 +00:00
|
|
|
|
|
|
|
hwmon_ctx->hm_adl = NULL;
|
|
|
|
}
|
2016-09-28 20:28:44 +00:00
|
|
|
}
|
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
if (backend_ctx->need_sysfs_amdgpu == true)
|
2016-11-05 22:19:13 +00:00
|
|
|
{
|
2021-07-09 18:48:10 +00:00
|
|
|
hwmon_ctx->hm_sysfs_amdgpu = (SYSFS_AMDGPU_PTR *) hcmalloc (sizeof (SYSFS_AMDGPU_PTR));
|
2016-11-05 22:19:13 +00:00
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
if (sysfs_amdgpu_init (hashcat_ctx) == false)
|
2016-11-05 22:19:13 +00:00
|
|
|
{
|
2021-07-09 18:48:10 +00:00
|
|
|
hcfree (hwmon_ctx->hm_sysfs_amdgpu);
|
2016-11-05 22:19:13 +00:00
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
hwmon_ctx->hm_sysfs_amdgpu = NULL;
|
2016-11-05 22:19:13 +00:00
|
|
|
}
|
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
// also if there's ADL, we don't need sysfs_amdgpu
|
2016-11-05 22:19:13 +00:00
|
|
|
|
|
|
|
if (hwmon_ctx->hm_adl)
|
|
|
|
{
|
2021-07-09 18:48:10 +00:00
|
|
|
hcfree (hwmon_ctx->hm_sysfs_amdgpu);
|
2016-11-05 22:19:13 +00:00
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
hwmon_ctx->hm_sysfs_amdgpu = NULL;
|
2016-11-05 22:19:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-10 06:43:15 +00:00
|
|
|
if (backend_ctx->need_sysfs_cpu == true)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_sysfs_cpu = (SYSFS_CPU_PTR *) hcmalloc (sizeof (SYSFS_CPU_PTR));
|
|
|
|
|
|
|
|
if (sysfs_cpu_init (hashcat_ctx) == false)
|
|
|
|
{
|
|
|
|
hcfree (hwmon_ctx->hm_sysfs_cpu);
|
|
|
|
|
|
|
|
hwmon_ctx->hm_sysfs_cpu = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-12 18:13:31 +00:00
|
|
|
#if defined(__APPLE__)
|
|
|
|
if (backend_ctx->need_iokit == true)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_iokit = (IOKIT_PTR *) hcmalloc (sizeof (IOKIT_PTR));
|
|
|
|
|
|
|
|
if (iokit_init (hashcat_ctx) == false)
|
|
|
|
{
|
|
|
|
hcfree (hwmon_ctx->hm_iokit);
|
|
|
|
|
|
|
|
hwmon_ctx->hm_iokit = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-09-28 20:28:44 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
|
|
|
{
|
2016-10-09 20:41:55 +00:00
|
|
|
if (hm_NVML_nvmlInit (hashcat_ctx) == 0)
|
2016-09-28 20:28:44 +00:00
|
|
|
{
|
2016-11-20 21:54:52 +00:00
|
|
|
HM_ADAPTER_NVML *nvmlGPUHandle = (HM_ADAPTER_NVML *) hccalloc (DEVICES_MAX, sizeof (HM_ADAPTER_NVML));
|
2016-09-28 20:28:44 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
int tmp_in = hm_get_adapter_index_nvml (hashcat_ctx, nvmlGPUHandle);
|
2016-09-28 20:28:44 +00:00
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
for (int backend_devices_idx = 0; backend_devices_idx < backend_ctx->backend_devices_cnt; backend_devices_idx++)
|
2016-09-28 20:28:44 +00:00
|
|
|
{
|
2019-04-30 11:38:44 +00:00
|
|
|
hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx];
|
2016-12-27 13:44:12 +00:00
|
|
|
|
|
|
|
if (device_param->skipped == true) continue;
|
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < tmp_in; i++)
|
|
|
|
{
|
|
|
|
nvmlPciInfo_t pci;
|
2016-12-27 13:44:12 +00:00
|
|
|
|
2021-06-10 18:26:24 +00:00
|
|
|
if (hm_NVML_nvmlDeviceGetPciInfo (hashcat_ctx, nvmlGPUHandle[i], &pci) == -1) continue;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
|
|
|
if ((device_param->pcie_bus == pci.bus)
|
|
|
|
&& (device_param->pcie_device == (pci.device >> 3))
|
|
|
|
&& (device_param->pcie_function == (pci.device & 7)))
|
|
|
|
{
|
|
|
|
const u32 device_id = device_param->device_id;
|
|
|
|
|
|
|
|
hm_adapters_nvml[device_id].nvml = nvmlGPUHandle[i];
|
2016-12-27 13:44:12 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
hm_adapters_nvml[device_id].buslanes_get_supported = true;
|
|
|
|
hm_adapters_nvml[device_id].corespeed_get_supported = true;
|
|
|
|
hm_adapters_nvml[device_id].fanspeed_get_supported = true;
|
|
|
|
hm_adapters_nvml[device_id].memoryspeed_get_supported = true;
|
|
|
|
hm_adapters_nvml[device_id].temperature_get_supported = true;
|
|
|
|
hm_adapters_nvml[device_id].threshold_shutdown_get_supported = true;
|
|
|
|
hm_adapters_nvml[device_id].threshold_slowdown_get_supported = true;
|
|
|
|
hm_adapters_nvml[device_id].utilization_get_supported = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
|
|
|
if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue;
|
2016-12-27 13:44:12 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (device_param->opencl_device_vendor_id != VENDOR_ID_NV) continue;
|
2016-12-27 13:44:12 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
for (int i = 0; i < tmp_in; i++)
|
2016-12-27 13:44:12 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
nvmlPciInfo_t pci;
|
|
|
|
|
2021-06-10 18:26:24 +00:00
|
|
|
if (hm_NVML_nvmlDeviceGetPciInfo (hashcat_ctx, nvmlGPUHandle[i], &pci) == -1) continue;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
|
|
|
if ((device_param->pcie_bus == pci.bus)
|
|
|
|
&& (device_param->pcie_device == (pci.device >> 3))
|
|
|
|
&& (device_param->pcie_function == (pci.device & 7)))
|
|
|
|
{
|
|
|
|
const u32 device_id = device_param->device_id;
|
|
|
|
|
|
|
|
hm_adapters_nvml[device_id].nvml = nvmlGPUHandle[i];
|
|
|
|
|
|
|
|
hm_adapters_nvml[device_id].buslanes_get_supported = true;
|
|
|
|
hm_adapters_nvml[device_id].corespeed_get_supported = true;
|
|
|
|
hm_adapters_nvml[device_id].fanspeed_get_supported = true;
|
|
|
|
hm_adapters_nvml[device_id].memoryspeed_get_supported = true;
|
|
|
|
hm_adapters_nvml[device_id].temperature_get_supported = true;
|
|
|
|
hm_adapters_nvml[device_id].threshold_shutdown_get_supported = true;
|
|
|
|
hm_adapters_nvml[device_id].threshold_slowdown_get_supported = true;
|
|
|
|
hm_adapters_nvml[device_id].utilization_get_supported = true;
|
|
|
|
}
|
2016-12-27 13:44:12 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-28 20:28:44 +00:00
|
|
|
}
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (nvmlGPUHandle);
|
2016-09-28 20:28:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hwmon_ctx->hm_nvapi)
|
|
|
|
{
|
2016-10-09 20:41:55 +00:00
|
|
|
if (hm_NvAPI_Initialize (hashcat_ctx) == 0)
|
2016-09-28 20:28:44 +00:00
|
|
|
{
|
2016-12-27 16:41:29 +00:00
|
|
|
HM_ADAPTER_NVAPI *nvGPUHandle = (HM_ADAPTER_NVAPI *) hccalloc (NVAPI_MAX_PHYSICAL_GPUS, sizeof (HM_ADAPTER_NVAPI));
|
2016-09-28 20:28:44 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
int tmp_in = hm_get_adapter_index_nvapi (hashcat_ctx, nvGPUHandle);
|
2016-09-28 20:28:44 +00:00
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
for (int backend_devices_idx = 0; backend_devices_idx < backend_ctx->backend_devices_cnt; backend_devices_idx++)
|
2016-09-28 20:28:44 +00:00
|
|
|
{
|
2019-04-30 11:38:44 +00:00
|
|
|
hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx];
|
2016-12-27 16:41:29 +00:00
|
|
|
|
|
|
|
if (device_param->skipped == true) continue;
|
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < tmp_in; i++)
|
|
|
|
{
|
|
|
|
NvU32 BusId = 0;
|
|
|
|
NvU32 BusSlotId = 0;
|
2016-12-27 16:41:29 +00:00
|
|
|
|
2021-06-10 18:26:24 +00:00
|
|
|
if (hm_NvAPI_GPU_GetBusId (hashcat_ctx, nvGPUHandle[i], &BusId) == -1) continue;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-06-10 18:26:24 +00:00
|
|
|
if (hm_NvAPI_GPU_GetBusSlotId (hashcat_ctx, nvGPUHandle[i], &BusSlotId) == -1) continue;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
|
|
|
if ((device_param->pcie_bus == BusId)
|
|
|
|
&& (device_param->pcie_device == (BusSlotId >> 3))
|
|
|
|
&& (device_param->pcie_function == (BusSlotId & 7)))
|
|
|
|
{
|
|
|
|
const u32 device_id = device_param->device_id;
|
2016-12-27 16:41:29 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
hm_adapters_nvapi[device_id].nvapi = nvGPUHandle[i];
|
2016-12-27 16:41:29 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
hm_adapters_nvapi[device_id].fanpolicy_get_supported = true;
|
|
|
|
hm_adapters_nvapi[device_id].throttle_get_supported = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
|
|
|
if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue;
|
2016-12-27 16:41:29 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (device_param->opencl_device_vendor_id != VENDOR_ID_NV) continue;
|
2016-12-27 16:41:29 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
for (int i = 0; i < tmp_in; i++)
|
2016-12-27 16:41:29 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
NvU32 BusId = 0;
|
|
|
|
NvU32 BusSlotId = 0;
|
|
|
|
|
2021-06-10 18:26:24 +00:00
|
|
|
if (hm_NvAPI_GPU_GetBusId (hashcat_ctx, nvGPUHandle[i], &BusId) == -1) continue;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-06-10 18:26:24 +00:00
|
|
|
if (hm_NvAPI_GPU_GetBusSlotId (hashcat_ctx, nvGPUHandle[i], &BusSlotId) == -1) continue;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
|
|
|
if ((device_param->pcie_bus == BusId)
|
|
|
|
&& (device_param->pcie_device == (BusSlotId >> 3))
|
|
|
|
&& (device_param->pcie_function == (BusSlotId & 7)))
|
|
|
|
{
|
|
|
|
const u32 device_id = device_param->device_id;
|
2016-12-27 16:41:29 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
hm_adapters_nvapi[device_id].nvapi = nvGPUHandle[i];
|
2016-12-27 16:41:29 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
hm_adapters_nvapi[device_id].fanpolicy_get_supported = true;
|
|
|
|
hm_adapters_nvapi[device_id].throttle_get_supported = true;
|
|
|
|
}
|
2016-12-27 16:41:29 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-28 20:28:44 +00:00
|
|
|
}
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (nvGPUHandle);
|
2016-09-28 20:28:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hwmon_ctx->hm_adl)
|
|
|
|
{
|
2016-10-09 20:41:55 +00:00
|
|
|
if (hm_ADL_Main_Control_Create (hashcat_ctx, ADL_Main_Memory_Alloc, 0) == 0)
|
2016-09-28 20:28:44 +00:00
|
|
|
{
|
|
|
|
// total number of adapters
|
|
|
|
|
2016-12-28 09:51:39 +00:00
|
|
|
int tmp_in;
|
2016-09-28 20:28:44 +00:00
|
|
|
|
2017-02-14 11:30:15 +00:00
|
|
|
if (get_adapters_num_adl (hashcat_ctx, &tmp_in) == -1)
|
|
|
|
{
|
|
|
|
FREE_ADAPTERS;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2016-09-28 20:28:44 +00:00
|
|
|
|
|
|
|
// adapter info
|
|
|
|
|
2016-12-28 09:51:39 +00:00
|
|
|
LPAdapterInfo lpAdapterInfo = (LPAdapterInfo) hccalloc (tmp_in, sizeof (AdapterInfo));
|
2016-10-13 08:07:04 +00:00
|
|
|
|
2021-06-10 18:26:24 +00:00
|
|
|
if (hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx, lpAdapterInfo, tmp_in * sizeof (AdapterInfo)) == -1)
|
2017-02-14 11:30:15 +00:00
|
|
|
{
|
|
|
|
FREE_ADAPTERS;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2016-09-28 20:28:44 +00:00
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
for (int backend_devices_idx = 0; backend_devices_idx < backend_ctx->backend_devices_cnt; backend_devices_idx++)
|
2016-12-28 09:51:39 +00:00
|
|
|
{
|
2019-04-30 11:38:44 +00:00
|
|
|
hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx];
|
2016-09-28 20:28:44 +00:00
|
|
|
|
2016-12-28 09:51:39 +00:00
|
|
|
if (device_param->skipped == true) continue;
|
2016-09-28 20:28:44 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (device_param->is_cuda == true)
|
2016-12-28 09:51:39 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
// nothing to do
|
|
|
|
}
|
2016-09-28 20:28:44 +00:00
|
|
|
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((device_param->is_opencl == true) || (device_param->is_hip == true))
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
|
|
|
if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue;
|
2016-12-28 09:51:39 +00:00
|
|
|
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((device_param->opencl_device_vendor_id != VENDOR_ID_AMD) && (device_param->opencl_device_vendor_id != VENDOR_ID_AMD_USE_HIP)) continue;
|
2016-12-28 09:51:39 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
for (int i = 0; i < tmp_in; i++)
|
|
|
|
{
|
|
|
|
if ((device_param->pcie_bus == lpAdapterInfo[i].iBusNumber)
|
|
|
|
&& (device_param->pcie_device == (lpAdapterInfo[i].iDeviceNumber >> 3))
|
|
|
|
&& (device_param->pcie_function == (lpAdapterInfo[i].iDeviceNumber & 7)))
|
|
|
|
{
|
|
|
|
const u32 device_id = device_param->device_id;
|
|
|
|
|
|
|
|
int od_supported = 0;
|
|
|
|
int od_enabled = 0;
|
|
|
|
int od_version = 0;
|
|
|
|
|
2021-07-26 05:48:56 +00:00
|
|
|
hm_ADL2_Overdrive_Caps (hashcat_ctx, lpAdapterInfo[i].iAdapterIndex, &od_supported, &od_enabled, &od_version);
|
|
|
|
|
|
|
|
if (od_version < 8) od_version = 5;
|
2019-05-01 13:52:56 +00:00
|
|
|
|
|
|
|
hm_adapters_adl[device_id].od_version = od_version;
|
|
|
|
|
|
|
|
hm_adapters_adl[device_id].adl = lpAdapterInfo[i].iAdapterIndex;
|
|
|
|
|
|
|
|
hm_adapters_adl[device_id].buslanes_get_supported = true;
|
|
|
|
hm_adapters_adl[device_id].corespeed_get_supported = true;
|
|
|
|
hm_adapters_adl[device_id].fanspeed_get_supported = true;
|
|
|
|
hm_adapters_adl[device_id].fanpolicy_get_supported = true;
|
|
|
|
hm_adapters_adl[device_id].memoryspeed_get_supported = true;
|
|
|
|
hm_adapters_adl[device_id].temperature_get_supported = true;
|
|
|
|
hm_adapters_adl[device_id].threshold_slowdown_get_supported = true;
|
|
|
|
hm_adapters_adl[device_id].utilization_get_supported = true;
|
|
|
|
}
|
2016-12-28 09:51:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-28 20:28:44 +00:00
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (lpAdapterInfo);
|
2016-09-28 20:28:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
if (hwmon_ctx->hm_sysfs_amdgpu || hwmon_ctx->hm_iokit)
|
2016-11-05 22:19:13 +00:00
|
|
|
{
|
2019-09-10 00:52:08 +00:00
|
|
|
if (true)
|
2016-11-05 22:19:13 +00:00
|
|
|
{
|
2019-04-30 11:38:44 +00:00
|
|
|
for (int backend_devices_idx = 0; backend_devices_idx < backend_ctx->backend_devices_cnt; backend_devices_idx++)
|
2016-11-05 22:19:13 +00:00
|
|
|
{
|
2019-04-30 11:38:44 +00:00
|
|
|
hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx];
|
2016-11-05 22:19:13 +00:00
|
|
|
|
2021-06-12 18:13:31 +00:00
|
|
|
if (device_param->skipped == true) continue;
|
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
|
|
|
// nothing to do
|
|
|
|
}
|
|
|
|
|
2022-02-15 21:20:03 +00:00
|
|
|
#if defined (__APPLE__)
|
|
|
|
if (device_param->is_metal == true)
|
|
|
|
{
|
|
|
|
const u32 device_id = device_param->device_id;
|
|
|
|
|
|
|
|
if ((device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) && (hwmon_ctx->hm_iokit))
|
|
|
|
{
|
|
|
|
hm_adapters_iokit[device_id].buslanes_get_supported = false;
|
|
|
|
hm_adapters_iokit[device_id].corespeed_get_supported = false;
|
|
|
|
hm_adapters_iokit[device_id].fanspeed_get_supported = true;
|
|
|
|
hm_adapters_iokit[device_id].fanpolicy_get_supported = false;
|
|
|
|
hm_adapters_iokit[device_id].memoryspeed_get_supported = false;
|
|
|
|
hm_adapters_iokit[device_id].temperature_get_supported = true;
|
|
|
|
hm_adapters_iokit[device_id].utilization_get_supported = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((device_param->is_opencl == true) || (device_param->is_hip == true))
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-05-08 10:14:07 +00:00
|
|
|
const u32 device_id = device_param->device_id;
|
2016-11-05 22:19:13 +00:00
|
|
|
|
2021-06-12 18:13:31 +00:00
|
|
|
if ((device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) && (hwmon_ctx->hm_iokit))
|
|
|
|
{
|
|
|
|
hm_adapters_iokit[device_id].buslanes_get_supported = false;
|
|
|
|
hm_adapters_iokit[device_id].corespeed_get_supported = false;
|
|
|
|
hm_adapters_iokit[device_id].fanspeed_get_supported = true;
|
|
|
|
hm_adapters_iokit[device_id].fanpolicy_get_supported = false;
|
|
|
|
hm_adapters_iokit[device_id].memoryspeed_get_supported = false;
|
|
|
|
hm_adapters_iokit[device_id].temperature_get_supported = true;
|
2022-02-15 21:20:03 +00:00
|
|
|
hm_adapters_iokit[device_id].utilization_get_supported = true;
|
2021-06-12 18:13:31 +00:00
|
|
|
}
|
|
|
|
|
2021-05-08 10:14:07 +00:00
|
|
|
if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue;
|
2016-11-11 22:48:43 +00:00
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
if (hwmon_ctx->hm_sysfs_amdgpu)
|
2021-06-12 18:13:31 +00:00
|
|
|
{
|
2021-07-09 18:48:10 +00:00
|
|
|
hm_adapters_sysfs_amdgpu[device_id].buslanes_get_supported = true;
|
|
|
|
hm_adapters_sysfs_amdgpu[device_id].corespeed_get_supported = true;
|
|
|
|
hm_adapters_sysfs_amdgpu[device_id].fanspeed_get_supported = true;
|
|
|
|
hm_adapters_sysfs_amdgpu[device_id].fanpolicy_get_supported = true;
|
|
|
|
hm_adapters_sysfs_amdgpu[device_id].memoryspeed_get_supported = true;
|
|
|
|
hm_adapters_sysfs_amdgpu[device_id].temperature_get_supported = true;
|
|
|
|
hm_adapters_sysfs_amdgpu[device_id].utilization_get_supported = true;
|
2021-06-12 18:13:31 +00:00
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
2016-11-05 22:19:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-10 06:43:15 +00:00
|
|
|
if (hwmon_ctx->hm_sysfs_cpu)
|
|
|
|
{
|
|
|
|
if (true)
|
|
|
|
{
|
|
|
|
for (int backend_devices_idx = 0; backend_devices_idx < backend_ctx->backend_devices_cnt; backend_devices_idx++)
|
|
|
|
{
|
|
|
|
hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx];
|
|
|
|
|
|
|
|
if (device_param->skipped == true) continue;
|
|
|
|
|
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
|
|
|
// nothing to do
|
|
|
|
}
|
|
|
|
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((device_param->is_opencl == true) || (device_param->is_hip == true))
|
2021-07-10 06:43:15 +00:00
|
|
|
{
|
|
|
|
const u32 device_id = device_param->device_id;
|
|
|
|
|
|
|
|
if ((device_param->opencl_device_type & CL_DEVICE_TYPE_CPU) == 0) continue;
|
|
|
|
|
|
|
|
if (hwmon_ctx->hm_sysfs_cpu)
|
|
|
|
{
|
|
|
|
hm_adapters_sysfs_cpu[device_id].buslanes_get_supported = false;
|
|
|
|
hm_adapters_sysfs_cpu[device_id].corespeed_get_supported = false;
|
|
|
|
hm_adapters_sysfs_cpu[device_id].fanspeed_get_supported = false;
|
|
|
|
hm_adapters_sysfs_cpu[device_id].fanpolicy_get_supported = false;
|
|
|
|
hm_adapters_sysfs_cpu[device_id].memoryspeed_get_supported = false;
|
|
|
|
hm_adapters_sysfs_cpu[device_id].temperature_get_supported = true;
|
2021-07-10 12:24:51 +00:00
|
|
|
hm_adapters_sysfs_cpu[device_id].utilization_get_supported = true;
|
2021-07-10 06:43:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-12 18:13:31 +00:00
|
|
|
#if defined(__APPLE__)
|
|
|
|
if (backend_ctx->need_iokit == true)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_iokit = (IOKIT_PTR *) hcmalloc (sizeof (IOKIT_PTR));
|
|
|
|
|
|
|
|
if (iokit_init (hashcat_ctx) == false)
|
|
|
|
{
|
|
|
|
hcfree (hwmon_ctx->hm_iokit);
|
|
|
|
|
|
|
|
hwmon_ctx->hm_iokit = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-07-10 06:43:15 +00:00
|
|
|
if (hwmon_ctx->hm_adl == NULL && hwmon_ctx->hm_nvml == NULL && hwmon_ctx->hm_sysfs_amdgpu == NULL && hwmon_ctx->hm_sysfs_cpu == NULL && hwmon_ctx->hm_iokit == NULL)
|
2016-09-28 20:28:44 +00:00
|
|
|
{
|
2017-02-14 11:30:15 +00:00
|
|
|
FREE_ADAPTERS;
|
2017-02-14 10:48:18 +00:00
|
|
|
|
2016-09-28 20:28:44 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* looks like we have some manageable device
|
|
|
|
*/
|
|
|
|
|
2016-09-28 13:26:56 +00:00
|
|
|
hwmon_ctx->enabled = true;
|
|
|
|
|
2016-09-28 20:28:44 +00:00
|
|
|
/**
|
|
|
|
* HM devices: copy
|
|
|
|
*/
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
for (int backend_devices_idx = 0; backend_devices_idx < backend_ctx->backend_devices_cnt; backend_devices_idx++)
|
2016-09-28 20:28:44 +00:00
|
|
|
{
|
2019-04-30 11:38:44 +00:00
|
|
|
hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx];
|
2016-09-28 20:28:44 +00:00
|
|
|
|
2016-11-18 09:09:03 +00:00
|
|
|
if (device_param->skipped == true) continue;
|
2016-09-28 20:28:44 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
const u32 device_id = device_param->device_id;
|
2016-09-28 20:28:44 +00:00
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].adl = 0;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].sysfs_amdgpu = 0;
|
2021-07-10 06:43:15 +00:00
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].sysfs_cpu = 0;
|
2021-07-09 18:48:10 +00:00
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].iokit = 0;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].nvapi = 0;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].nvml = 0;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].od_version = 0;
|
2021-06-12 18:13:31 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (device_param->is_cuda == true)
|
2016-09-28 20:28:44 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].nvapi = hm_adapters_nvapi[device_id].nvapi;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].nvml = hm_adapters_nvml[device_id].nvml;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (hwmon_ctx->hm_nvml)
|
2016-11-21 14:58:44 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_nvml[device_id].buslanes_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_nvml[device_id].corespeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_nvml[device_id].fanspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_nvml[device_id].fanpolicy_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_nvml[device_id].memoryspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_nvml[device_id].temperature_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_nvml[device_id].threshold_shutdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_nvml[device_id].threshold_slowdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_nvml[device_id].throttle_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_nvml[device_id].utilization_get_supported;
|
2016-11-21 14:58:44 +00:00
|
|
|
}
|
|
|
|
|
2019-05-01 13:52:56 +00:00
|
|
|
if (hwmon_ctx->hm_nvapi)
|
2016-11-21 14:58:44 +00:00
|
|
|
{
|
2019-05-01 13:52:56 +00:00
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_nvapi[device_id].buslanes_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_nvapi[device_id].corespeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_nvapi[device_id].fanspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_nvapi[device_id].fanpolicy_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_nvapi[device_id].memoryspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_nvapi[device_id].temperature_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_nvapi[device_id].threshold_shutdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_nvapi[device_id].threshold_slowdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_nvapi[device_id].throttle_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_nvapi[device_id].utilization_get_supported;
|
2016-11-21 14:58:44 +00:00
|
|
|
}
|
2016-09-28 20:28:44 +00:00
|
|
|
}
|
|
|
|
|
2022-02-15 21:20:03 +00:00
|
|
|
if (device_param->is_metal == true)
|
|
|
|
{
|
|
|
|
if (hwmon_ctx->hm_iokit)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].iokit = hm_adapters_iokit[device_id].iokit;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_iokit[device_id].buslanes_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_iokit[device_id].corespeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_iokit[device_id].fanspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_iokit[device_id].fanpolicy_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_iokit[device_id].memoryspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_iokit[device_id].temperature_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_iokit[device_id].threshold_shutdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_iokit[device_id].threshold_slowdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_iokit[device_id].throttle_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_iokit[device_id].utilization_get_supported;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((device_param->is_opencl == true) || (device_param->is_hip == true))
|
2016-09-28 20:28:44 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)
|
2021-06-12 18:13:31 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
#if defined(__APPLE__)
|
|
|
|
if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE)
|
2021-06-12 18:13:31 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_iokit)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].iokit = hm_adapters_iokit[device_id].iokit;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_iokit[device_id].buslanes_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_iokit[device_id].corespeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_iokit[device_id].fanspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_iokit[device_id].fanpolicy_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_iokit[device_id].memoryspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_iokit[device_id].temperature_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_iokit[device_id].threshold_shutdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_iokit[device_id].threshold_slowdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_iokit[device_id].throttle_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_iokit[device_id].utilization_get_supported;
|
|
|
|
}
|
2021-06-12 18:13:31 +00:00
|
|
|
}
|
2021-07-08 07:04:14 +00:00
|
|
|
#endif
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2021-07-10 06:43:15 +00:00
|
|
|
if (hwmon_ctx->hm_sysfs_cpu)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_sysfs_cpu[device_id].buslanes_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_sysfs_cpu[device_id].corespeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_sysfs_cpu[device_id].fanspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_sysfs_cpu[device_id].fanpolicy_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_sysfs_cpu[device_id].memoryspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_sysfs_cpu[device_id].temperature_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_sysfs_cpu[device_id].threshold_shutdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_sysfs_cpu[device_id].threshold_slowdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_sysfs_cpu[device_id].throttle_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_sysfs_cpu[device_id].utilization_get_supported;
|
|
|
|
}
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)
|
|
|
|
{
|
|
|
|
#if defined(__APPLE__)
|
|
|
|
if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_iokit)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].iokit = hm_adapters_iokit[device_id].iokit;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_iokit[device_id].buslanes_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_iokit[device_id].corespeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_iokit[device_id].fanspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_iokit[device_id].fanpolicy_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_iokit[device_id].memoryspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_iokit[device_id].temperature_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_iokit[device_id].threshold_shutdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_iokit[device_id].threshold_slowdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_iokit[device_id].throttle_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_iokit[device_id].utilization_get_supported;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
2021-07-08 07:04:14 +00:00
|
|
|
#endif
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-14 06:23:39 +00:00
|
|
|
if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) || (device_param->opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP))
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-09 18:48:10 +00:00
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].adl = hm_adapters_adl[device_id].adl;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].sysfs_amdgpu = hm_adapters_sysfs_amdgpu[device_id].sysfs_amdgpu;
|
2016-11-21 14:58:44 +00:00
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (hwmon_ctx->hm_adl)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].od_version = hm_adapters_adl[device_id].od_version;
|
|
|
|
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_adl[device_id].buslanes_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_adl[device_id].corespeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_adl[device_id].fanspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_adl[device_id].fanpolicy_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_adl[device_id].memoryspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_adl[device_id].temperature_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_adl[device_id].threshold_shutdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_adl[device_id].threshold_slowdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_adl[device_id].throttle_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_adl[device_id].utilization_get_supported;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
if (hwmon_ctx->hm_sysfs_amdgpu)
|
2021-07-08 07:04:14 +00:00
|
|
|
{
|
2021-07-09 18:48:10 +00:00
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_sysfs_amdgpu[device_id].buslanes_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_sysfs_amdgpu[device_id].corespeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_sysfs_amdgpu[device_id].fanspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_sysfs_amdgpu[device_id].fanpolicy_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_sysfs_amdgpu[device_id].memoryspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_sysfs_amdgpu[device_id].temperature_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_sysfs_amdgpu[device_id].threshold_shutdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_sysfs_amdgpu[device_id].threshold_slowdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_sysfs_amdgpu[device_id].throttle_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_sysfs_amdgpu[device_id].utilization_get_supported;
|
2021-07-08 07:04:14 +00:00
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
|
|
|
|
2021-07-08 07:04:14 +00:00
|
|
|
if (device_param->opencl_device_vendor_id == VENDOR_ID_NV)
|
2019-05-01 13:52:56 +00:00
|
|
|
{
|
2021-07-08 07:04:14 +00:00
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].nvapi = hm_adapters_nvapi[device_id].nvapi;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].nvml = hm_adapters_nvml[device_id].nvml;
|
|
|
|
|
|
|
|
if (hwmon_ctx->hm_nvml)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_nvml[device_id].buslanes_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_nvml[device_id].corespeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_nvml[device_id].fanspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_nvml[device_id].fanpolicy_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_nvml[device_id].memoryspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_nvml[device_id].temperature_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_nvml[device_id].threshold_shutdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_nvml[device_id].threshold_slowdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_nvml[device_id].throttle_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_nvml[device_id].utilization_get_supported;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hwmon_ctx->hm_nvapi)
|
|
|
|
{
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_nvapi[device_id].buslanes_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_nvapi[device_id].corespeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_nvapi[device_id].fanspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_nvapi[device_id].fanpolicy_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_nvapi[device_id].memoryspeed_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_nvapi[device_id].temperature_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_nvapi[device_id].threshold_shutdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_nvapi[device_id].threshold_slowdown_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_nvapi[device_id].throttle_get_supported;
|
|
|
|
hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_nvapi[device_id].utilization_get_supported;
|
|
|
|
}
|
2019-05-01 13:52:56 +00:00
|
|
|
}
|
2016-11-21 14:58:44 +00:00
|
|
|
}
|
2016-09-28 20:28:44 +00:00
|
|
|
}
|
2016-11-21 14:58:44 +00:00
|
|
|
|
|
|
|
// by calling the different functions here this will disable them in case they will error out
|
|
|
|
// this will also reduce the error itself printed to the user to a single print on startup
|
|
|
|
|
2019-04-30 11:38:44 +00:00
|
|
|
hm_get_buslanes_with_devices_idx (hashcat_ctx, backend_devices_idx);
|
|
|
|
hm_get_corespeed_with_devices_idx (hashcat_ctx, backend_devices_idx);
|
|
|
|
hm_get_fanpolicy_with_devices_idx (hashcat_ctx, backend_devices_idx);
|
|
|
|
hm_get_fanspeed_with_devices_idx (hashcat_ctx, backend_devices_idx);
|
|
|
|
hm_get_memoryspeed_with_devices_idx (hashcat_ctx, backend_devices_idx);
|
|
|
|
hm_get_temperature_with_devices_idx (hashcat_ctx, backend_devices_idx);
|
|
|
|
hm_get_threshold_shutdown_with_devices_idx (hashcat_ctx, backend_devices_idx);
|
|
|
|
hm_get_threshold_slowdown_with_devices_idx (hashcat_ctx, backend_devices_idx);
|
|
|
|
hm_get_throttle_with_devices_idx (hashcat_ctx, backend_devices_idx);
|
|
|
|
hm_get_utilization_with_devices_idx (hashcat_ctx, backend_devices_idx);
|
2016-09-28 20:28:44 +00:00
|
|
|
}
|
|
|
|
|
2017-02-14 11:30:15 +00:00
|
|
|
FREE_ADAPTERS;
|
2016-09-28 21:07:25 +00:00
|
|
|
|
2016-09-28 13:26:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-10-06 09:10:00 +00:00
|
|
|
void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
|
2016-09-28 13:26:56 +00:00
|
|
|
{
|
2017-12-01 14:19:10 +00:00
|
|
|
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
|
2016-10-06 09:10:00 +00:00
|
|
|
|
2016-10-01 22:00:21 +00:00
|
|
|
if (hwmon_ctx->enabled == false) return;
|
2016-09-28 13:26:56 +00:00
|
|
|
|
2016-09-28 20:28:44 +00:00
|
|
|
// unload shared libraries
|
|
|
|
|
|
|
|
if (hwmon_ctx->hm_nvml)
|
|
|
|
{
|
2016-10-09 20:41:55 +00:00
|
|
|
hm_NVML_nvmlShutdown (hashcat_ctx);
|
2016-09-28 20:28:44 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
nvml_close (hashcat_ctx);
|
2016-09-28 20:28:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hwmon_ctx->hm_nvapi)
|
|
|
|
{
|
2016-10-09 20:41:55 +00:00
|
|
|
hm_NvAPI_Unload (hashcat_ctx);
|
2016-09-28 20:28:44 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
nvapi_close (hashcat_ctx);
|
2016-09-28 20:28:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hwmon_ctx->hm_adl)
|
|
|
|
{
|
2016-10-09 20:41:55 +00:00
|
|
|
hm_ADL_Main_Control_Destroy (hashcat_ctx);
|
2016-09-28 20:28:44 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
adl_close (hashcat_ctx);
|
2016-09-28 20:28:44 +00:00
|
|
|
}
|
|
|
|
|
2021-07-09 18:48:10 +00:00
|
|
|
if (hwmon_ctx->hm_sysfs_amdgpu)
|
2016-11-05 22:19:13 +00:00
|
|
|
{
|
2021-07-09 18:48:10 +00:00
|
|
|
sysfs_amdgpu_close (hashcat_ctx);
|
2016-11-05 22:19:13 +00:00
|
|
|
}
|
|
|
|
|
2021-07-10 06:43:15 +00:00
|
|
|
if (hwmon_ctx->hm_sysfs_cpu)
|
|
|
|
{
|
|
|
|
sysfs_cpu_close (hashcat_ctx);
|
|
|
|
}
|
|
|
|
|
2021-06-12 18:13:31 +00:00
|
|
|
#if defined (__APPLE__)
|
|
|
|
if (hwmon_ctx->hm_iokit)
|
|
|
|
{
|
|
|
|
iokit_close (hashcat_ctx);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-09-28 20:28:44 +00:00
|
|
|
// free memory
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (hwmon_ctx->hm_device);
|
2016-09-28 13:26:56 +00:00
|
|
|
|
2016-10-01 22:00:21 +00:00
|
|
|
memset (hwmon_ctx, 0, sizeof (hwmon_ctx_t));
|
2016-09-28 13:26:56 +00:00
|
|
|
}
|