| 1 |
/* |
| 2 |
* Copyright (C) 2020-2023 Intel Corporation |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MIT |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
#pragma once |
| 9 |
|
| 10 |
#include "level_zero/sysman/source/api/frequency/windows/sysman_os_frequency_imp.h" |
| 11 |
#include "level_zero/sysman/test/unit_tests/sources/windows/mock_kmd_sys_manager.h" |
| 12 |
|
| 13 |
namespace L0 { |
| 14 |
namespace Sysman { |
| 15 |
namespace ult { |
| 16 |
|
| 17 |
struct MockFrequencyKmdSysManager : public MockKmdSysManager { |
| 18 |
uint32_t mockNumberOfDomains = 3; |
| 19 |
uint32_t mockSupportedDomains = 7; |
| 20 |
uint32_t mockDomainType[3] = {ZES_FREQ_DOMAIN_GPU, ZES_FREQ_DOMAIN_MEMORY, ZES_FREQ_DOMAIN_MEDIA}; |
| 21 |
bool mockGPUCanControl[3] = {true, false, false}; |
| 22 |
bool mockGPUCannotControl[3] = {false, false, false}; |
| 23 |
uint32_t mockMinFrequencyRange = 400; |
| 24 |
uint32_t mockMaxFrequencyRange = 1200; |
| 25 |
uint32_t mockRpn[3] = {400, 0, 400}; |
| 26 |
uint32_t mockRp0[3] = {1200, 0, 1200}; |
| 27 |
uint32_t mockRequestedFrequency = 600; |
| 28 |
uint32_t mockTdpFrequency = 0; |
| 29 |
uint32_t mockResolvedFrequency[3] = {600, 4200, 600}; |
| 30 |
uint32_t mockEfficientFrequency = 400; |
| 31 |
uint32_t mockCurrentVoltage = 1100; |
| 32 |
uint32_t mockThrottleReasons = 0; |
| 33 |
uint32_t mockIccMax = 1025; |
| 34 |
uint32_t mockTjMax = 105; |
| 35 |
|
| 36 |
uint32_t mockIsExtendedModeSupported[3] = {0, 0, 0}; |
| 37 |
uint32_t mockIsFixedModeSupported[3] = {0, 0, 0}; |
| 38 |
uint32_t mockIsHighVoltModeCapable[3] = {0, 0, 0}; |
| 39 |
uint32_t mockIsHighVoltModeEnabled[3] = {0, 0, 0}; |
| 40 |
uint32_t mockIsIccMaxSupported = 1; |
| 41 |
uint32_t mockIsOcSupported[3] = {0, 0, 0}; |
| 42 |
uint32_t mockIsTjMaxSupported = 1; |
| 43 |
uint32_t mockMaxFactoryDefaultFrequency[3] = {600, 4200, 600}; |
| 44 |
uint32_t mockMaxFactoryDefaultVoltage[3] = {1200, 1300, 1200}; |
| 45 |
uint32_t mockMaxOcFrequency[3] = {1800, 4500, 1800}; |
| 46 |
uint32_t mockMaxOcVoltage[3] = {1300, 1400, 1300}; |
| 47 |
uint32_t mockFixedMode[3] = {0, 0, 0}; |
| 48 |
uint32_t mockVoltageMode[3] = {0, 0, 0}; |
| 49 |
uint32_t mockHighVoltageSupported[3] = {0, 0, 0}; |
| 50 |
uint32_t mockHighVoltageEnabled[3] = {0, 0, 0}; |
| 51 |
uint32_t mockFrequencyTarget[3] = {0, 0, 0}; |
| 52 |
uint32_t mockVoltageTarget[3] = {0, 0, 0}; |
| 53 |
uint32_t mockVoltageOffset[3] = {0, 0, 0}; |
| 54 |
|
| 55 |
void getFrequencyProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) override { |
| 56 |
uint8_t *pBuffer = reinterpret_cast<uint8_t *>(pResponse); |
| 57 |
pBuffer += sizeof(KmdSysman::GfxSysmanReqHeaderOut); |
| 58 |
|
| 59 |
KmdSysman::GeneralDomainsType domain = static_cast<KmdSysman::GeneralDomainsType>(pRequest->inCommandParam); |
| 60 |
|
| 61 |
if (domain < KmdSysman::GeneralDomainsType::GeneralDomainDGPU || domain >= KmdSysman::GeneralDomainsType::GeneralDomainMaxTypes) { |
| 62 |
pResponse->outDataSize = 0; |
| 63 |
pResponse->outReturnCode = KmdSysman::KmdSysmanFail; |
| 64 |
return; |
| 65 |
} |
| 66 |
|
| 67 |
switch (pRequest->inRequestId) { |
| 68 |
case KmdSysman::Requests::Frequency::NumFrequencyDomains: { |
| 69 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 70 |
*pValue = mockNumberOfDomains; |
| 71 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 72 |
pResponse->outDataSize = sizeof(uint32_t); |
| 73 |
} break; |
| 74 |
case KmdSysman::Requests::Frequency::SupportedFreqDomains: { |
| 75 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 76 |
*pValue = mockSupportedDomains; |
| 77 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 78 |
pResponse->outDataSize = sizeof(uint32_t); |
| 79 |
} break; |
| 80 |
case KmdSysman::Requests::Frequency::ExtendedOcSupported: { |
| 81 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 82 |
*pValue = mockIsExtendedModeSupported[domain]; |
| 83 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 84 |
pResponse->outDataSize = sizeof(uint32_t); |
| 85 |
} break; |
| 86 |
case KmdSysman::Requests::Frequency::CanControlFrequency: { |
| 87 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 88 |
*pValue = allowSetCalls ? mockGPUCanControl[domain] : mockGPUCannotControl[domain]; |
| 89 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 90 |
pResponse->outDataSize = sizeof(uint32_t); |
| 91 |
} break; |
| 92 |
case KmdSysman::Requests::Frequency::FixedModeSupported: { |
| 93 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 94 |
*pValue = mockFixedMode[domain]; |
| 95 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 96 |
pResponse->outDataSize = sizeof(uint32_t); |
| 97 |
} break; |
| 98 |
case KmdSysman::Requests::Frequency::HighVoltageModeSupported: { |
| 99 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 100 |
*pValue = mockHighVoltageSupported[domain]; |
| 101 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 102 |
pResponse->outDataSize = sizeof(uint32_t); |
| 103 |
} break; |
| 104 |
case KmdSysman::Requests::Frequency::HighVoltageEnabled: { |
| 105 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 106 |
*pValue = mockHighVoltageEnabled[domain]; |
| 107 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 108 |
pResponse->outDataSize = sizeof(uint32_t); |
| 109 |
} break; |
| 110 |
case KmdSysman::Requests::Frequency::FrequencyOcSupported: { |
| 111 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 112 |
*pValue = mockIsOcSupported[domain]; |
| 113 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 114 |
pResponse->outDataSize = sizeof(uint32_t); |
| 115 |
} break; |
| 116 |
case KmdSysman::Requests::Frequency::CurrentIccMax: { |
| 117 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 118 |
*pValue = mockIccMax; |
| 119 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 120 |
pResponse->outDataSize = sizeof(uint32_t); |
| 121 |
} break; |
| 122 |
case KmdSysman::Requests::Frequency::CurrentTjMax: { |
| 123 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 124 |
*pValue = mockTjMax; |
| 125 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 126 |
pResponse->outDataSize = sizeof(uint32_t); |
| 127 |
} break; |
| 128 |
case KmdSysman::Requests::Frequency::MaxNonOcFrequencyDefault: { |
| 129 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 130 |
*pValue = mockMaxFactoryDefaultFrequency[domain]; |
| 131 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 132 |
pResponse->outDataSize = sizeof(uint32_t); |
| 133 |
} break; |
| 134 |
case KmdSysman::Requests::Frequency::MaxNonOcVoltageDefault: { |
| 135 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 136 |
*pValue = mockMaxFactoryDefaultVoltage[domain]; |
| 137 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 138 |
pResponse->outDataSize = sizeof(uint32_t); |
| 139 |
} break; |
| 140 |
case KmdSysman::Requests::Frequency::MaxOcFrequencyDefault: { |
| 141 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 142 |
*pValue = mockMaxOcFrequency[domain]; |
| 143 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 144 |
pResponse->outDataSize = sizeof(uint32_t); |
| 145 |
} break; |
| 146 |
case KmdSysman::Requests::Frequency::MaxOcVoltageDefault: { |
| 147 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 148 |
*pValue = mockMaxOcVoltage[domain]; |
| 149 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 150 |
pResponse->outDataSize = sizeof(uint32_t); |
| 151 |
} break; |
| 152 |
case KmdSysman::Requests::Frequency::CurrentFixedMode: { |
| 153 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 154 |
*pValue = mockFixedMode[domain]; |
| 155 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 156 |
pResponse->outDataSize = sizeof(uint32_t); |
| 157 |
} break; |
| 158 |
case KmdSysman::Requests::Frequency::CurrentFrequencyTarget: { |
| 159 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 160 |
*pValue = mockFrequencyTarget[domain]; |
| 161 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 162 |
pResponse->outDataSize = sizeof(uint32_t); |
| 163 |
} break; |
| 164 |
case KmdSysman::Requests::Frequency::CurrentVoltageTarget: { |
| 165 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 166 |
*pValue = mockVoltageTarget[domain]; |
| 167 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 168 |
pResponse->outDataSize = sizeof(uint32_t); |
| 169 |
} break; |
| 170 |
case KmdSysman::Requests::Frequency::CurrentVoltageOffset: { |
| 171 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 172 |
*pValue = mockVoltageOffset[domain]; |
| 173 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 174 |
pResponse->outDataSize = sizeof(uint32_t); |
| 175 |
} break; |
| 176 |
case KmdSysman::Requests::Frequency::CurrentVoltageMode: { |
| 177 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 178 |
*pValue = mockVoltageMode[domain]; |
| 179 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 180 |
pResponse->outDataSize = sizeof(uint32_t); |
| 181 |
} break; |
| 182 |
case KmdSysman::Requests::Frequency::FrequencyThrottledEventSupported: { |
| 183 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 184 |
*pValue = 0; |
| 185 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 186 |
pResponse->outDataSize = sizeof(uint32_t); |
| 187 |
} break; |
| 188 |
case KmdSysman::Requests::Frequency::CurrentFrequencyRange: { |
| 189 |
if (domain == KmdSysman::GeneralDomainsType::GeneralDomainDGPU) { |
| 190 |
uint32_t *pMinFreq = reinterpret_cast<uint32_t *>(pBuffer); |
| 191 |
uint32_t *pMaxFreq = reinterpret_cast<uint32_t *>(pBuffer + sizeof(uint32_t)); |
| 192 |
*pMinFreq = mockMinFrequencyRange; |
| 193 |
*pMaxFreq = mockMaxFrequencyRange; |
| 194 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 195 |
pResponse->outDataSize = 2 * sizeof(uint32_t); |
| 196 |
} else if (domain == KmdSysman::GeneralDomainsType::GeneralDomainHBM) { |
| 197 |
pResponse->outDataSize = 0; |
| 198 |
pResponse->outReturnCode = KmdSysman::KmdSysmanFail; |
| 199 |
} else if (domain == KmdSysman::GeneralDomainsType::GeneralDomainMedia) { |
| 200 |
uint32_t *pMinFreq = reinterpret_cast<uint32_t *>(pBuffer); |
| 201 |
uint32_t *pMaxFreq = reinterpret_cast<uint32_t *>(pBuffer + sizeof(uint32_t)); |
| 202 |
*pMinFreq = mockMinFrequencyRange; |
| 203 |
*pMaxFreq = mockMaxFrequencyRange; |
| 204 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 205 |
pResponse->outDataSize = 2 * sizeof(uint32_t); |
| 206 |
} |
| 207 |
} break; |
| 208 |
case KmdSysman::Requests::Frequency::CurrentRequestedFrequency: { |
| 209 |
if (domain == KmdSysman::GeneralDomainsType::GeneralDomainDGPU) { |
| 210 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 211 |
*pValue = mockRequestedFrequency; |
| 212 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 213 |
pResponse->outDataSize = sizeof(uint32_t); |
| 214 |
} else if (domain == KmdSysman::GeneralDomainsType::GeneralDomainHBM) { |
| 215 |
pResponse->outDataSize = 0; |
| 216 |
pResponse->outReturnCode = KmdSysman::KmdSysmanFail; |
| 217 |
} else if (domain == KmdSysman::GeneralDomainsType::GeneralDomainMedia) { |
| 218 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 219 |
*pValue = mockRequestedFrequency; |
| 220 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 221 |
pResponse->outDataSize = sizeof(uint32_t); |
| 222 |
} |
| 223 |
} break; |
| 224 |
case KmdSysman::Requests::Frequency::CurrentTdpFrequency: { |
| 225 |
if (domain == KmdSysman::GeneralDomainsType::GeneralDomainDGPU) { |
| 226 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 227 |
*pValue = mockTdpFrequency; |
| 228 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 229 |
pResponse->outDataSize = sizeof(uint32_t); |
| 230 |
} else if (domain == KmdSysman::GeneralDomainsType::GeneralDomainHBM) { |
| 231 |
pResponse->outDataSize = 0; |
| 232 |
pResponse->outReturnCode = KmdSysman::KmdSysmanFail; |
| 233 |
} else if (domain == KmdSysman::GeneralDomainsType::GeneralDomainMedia) { |
| 234 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 235 |
*pValue = mockTdpFrequency; |
| 236 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 237 |
pResponse->outDataSize = sizeof(uint32_t); |
| 238 |
} |
| 239 |
} break; |
| 240 |
case KmdSysman::Requests::Frequency::CurrentResolvedFrequency: { |
| 241 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 242 |
*pValue = mockResolvedFrequency[domain]; |
| 243 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 244 |
pResponse->outDataSize = sizeof(uint32_t); |
| 245 |
} break; |
| 246 |
case KmdSysman::Requests::Frequency::CurrentEfficientFrequency: { |
| 247 |
if (domain == KmdSysman::GeneralDomainsType::GeneralDomainDGPU) { |
| 248 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 249 |
*pValue = mockEfficientFrequency; |
| 250 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 251 |
pResponse->outDataSize = sizeof(uint32_t); |
| 252 |
} else if (domain == KmdSysman::GeneralDomainsType::GeneralDomainHBM) { |
| 253 |
pResponse->outDataSize = 0; |
| 254 |
pResponse->outReturnCode = KmdSysman::KmdSysmanFail; |
| 255 |
} else if (domain == KmdSysman::GeneralDomainsType::GeneralDomainMedia) { |
| 256 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 257 |
*pValue = mockEfficientFrequency; |
| 258 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 259 |
pResponse->outDataSize = sizeof(uint32_t); |
| 260 |
} |
| 261 |
} break; |
| 262 |
case KmdSysman::Requests::Frequency::FrequencyRangeMaxDefault: { |
| 263 |
if (domain == KmdSysman::GeneralDomainsType::GeneralDomainDGPU) { |
| 264 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 265 |
*pValue = mockRp0[domain]; |
| 266 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 267 |
pResponse->outDataSize = sizeof(uint32_t); |
| 268 |
} else if (domain == KmdSysman::GeneralDomainsType::GeneralDomainHBM) { |
| 269 |
pResponse->outDataSize = 0; |
| 270 |
pResponse->outReturnCode = KmdSysman::KmdSysmanFail; |
| 271 |
} else if (domain == KmdSysman::GeneralDomainsType::GeneralDomainMedia) { |
| 272 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 273 |
*pValue = mockRp0[domain]; |
| 274 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 275 |
pResponse->outDataSize = sizeof(uint32_t); |
| 276 |
} |
| 277 |
} break; |
| 278 |
case KmdSysman::Requests::Frequency::FrequencyRangeMinDefault: { |
| 279 |
if (domain == KmdSysman::GeneralDomainsType::GeneralDomainDGPU) { |
| 280 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 281 |
*pValue = mockRpn[domain]; |
| 282 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 283 |
pResponse->outDataSize = sizeof(uint32_t); |
| 284 |
} else if (domain == KmdSysman::GeneralDomainsType::GeneralDomainHBM) { |
| 285 |
pResponse->outDataSize = 0; |
| 286 |
pResponse->outReturnCode = KmdSysman::KmdSysmanFail; |
| 287 |
} else if (domain == KmdSysman::GeneralDomainsType::GeneralDomainMedia) { |
| 288 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 289 |
*pValue = mockRpn[domain]; |
| 290 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 291 |
pResponse->outDataSize = sizeof(uint32_t); |
| 292 |
} |
| 293 |
} break; |
| 294 |
case KmdSysman::Requests::Frequency::CurrentVoltage: { |
| 295 |
if (domain == KmdSysman::GeneralDomainsType::GeneralDomainDGPU) { |
| 296 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 297 |
*pValue = mockCurrentVoltage; |
| 298 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 299 |
pResponse->outDataSize = sizeof(uint32_t); |
| 300 |
} else if (domain == KmdSysman::GeneralDomainsType::GeneralDomainHBM) { |
| 301 |
pResponse->outDataSize = 0; |
| 302 |
pResponse->outReturnCode = KmdSysman::KmdSysmanFail; |
| 303 |
} else if (domain == KmdSysman::GeneralDomainsType::GeneralDomainMedia) { |
| 304 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 305 |
*pValue = mockCurrentVoltage; |
| 306 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 307 |
pResponse->outDataSize = sizeof(uint32_t); |
| 308 |
} |
| 309 |
} break; |
| 310 |
case KmdSysman::Requests::Frequency::CurrentThrottleReasons: { |
| 311 |
if (domain == KmdSysman::GeneralDomainsType::GeneralDomainDGPU) { |
| 312 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 313 |
*pValue = mockThrottleReasons; |
| 314 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 315 |
pResponse->outDataSize = sizeof(uint32_t); |
| 316 |
} else if (domain == KmdSysman::GeneralDomainsType::GeneralDomainHBM) { |
| 317 |
pResponse->outDataSize = 0; |
| 318 |
pResponse->outReturnCode = KmdSysman::KmdSysmanFail; |
| 319 |
} else if (domain == KmdSysman::GeneralDomainsType::GeneralDomainMedia) { |
| 320 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 321 |
*pValue = mockThrottleReasons; |
| 322 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 323 |
pResponse->outDataSize = sizeof(uint32_t); |
| 324 |
} |
| 325 |
} break; |
| 326 |
default: { |
| 327 |
pResponse->outDataSize = 0; |
| 328 |
pResponse->outReturnCode = KmdSysman::KmdSysmanFail; |
| 329 |
} break; |
| 330 |
} |
| 331 |
} |
| 332 |
|
| 333 |
void setFrequencyProperty(KmdSysman::GfxSysmanReqHeaderIn *pRequest, KmdSysman::GfxSysmanReqHeaderOut *pResponse) override { |
| 334 |
uint8_t *pBuffer = reinterpret_cast<uint8_t *>(pRequest); |
| 335 |
pBuffer += sizeof(KmdSysman::GfxSysmanReqHeaderIn); |
| 336 |
|
| 337 |
KmdSysman::GeneralDomainsType domain = static_cast<KmdSysman::GeneralDomainsType>(pRequest->inCommandParam); |
| 338 |
|
| 339 |
if (domain < KmdSysman::GeneralDomainsType::GeneralDomainDGPU || domain >= KmdSysman::GeneralDomainsType::GeneralDomainMaxTypes) { |
| 340 |
pResponse->outDataSize = 0; |
| 341 |
pResponse->outReturnCode = KmdSysman::KmdSysmanFail; |
| 342 |
return; |
| 343 |
} |
| 344 |
switch (pRequest->inRequestId) { |
| 345 |
case KmdSysman::Requests::Frequency::CurrentFrequencyRange: { |
| 346 |
if (domain == KmdSysman::GeneralDomainsType::GeneralDomainDGPU) { |
| 347 |
uint32_t *pMinFreq = reinterpret_cast<uint32_t *>(pBuffer); |
| 348 |
uint32_t *pMaxFreq = reinterpret_cast<uint32_t *>(pBuffer + sizeof(uint32_t)); |
| 349 |
mockMinFrequencyRange = *pMinFreq; |
| 350 |
mockMaxFrequencyRange = *pMaxFreq; |
| 351 |
pResponse->outDataSize = 0; |
| 352 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 353 |
} else if (domain == KmdSysman::GeneralDomainsType::GeneralDomainHBM) { |
| 354 |
pResponse->outDataSize = 0; |
| 355 |
pResponse->outReturnCode = KmdSysman::ReturnCodes::DomainServiceNotSupported; |
| 356 |
} else if (domain == KmdSysman::GeneralDomainsType::GeneralDomainMedia) { |
| 357 |
uint32_t *pMinFreq = reinterpret_cast<uint32_t *>(pBuffer); |
| 358 |
uint32_t *pMaxFreq = reinterpret_cast<uint32_t *>(pBuffer + sizeof(uint32_t)); |
| 359 |
mockMinFrequencyRange = *pMinFreq; |
| 360 |
mockMaxFrequencyRange = *pMaxFreq; |
| 361 |
pResponse->outDataSize = 0; |
| 362 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 363 |
} |
| 364 |
} break; |
| 365 |
case KmdSysman::Requests::Frequency::CurrentFixedMode: { |
| 366 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 367 |
mockFixedMode[domain] = *pValue; |
| 368 |
pResponse->outDataSize = 0; |
| 369 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 370 |
} break; |
| 371 |
case KmdSysman::Requests::Frequency::CurrentVoltageMode: { |
| 372 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 373 |
mockVoltageMode[domain] = *pValue; |
| 374 |
pResponse->outDataSize = 0; |
| 375 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 376 |
} break; |
| 377 |
case KmdSysman::Requests::Frequency::CurrentVoltageOffset: { |
| 378 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 379 |
mockVoltageOffset[domain] = *pValue; |
| 380 |
pResponse->outDataSize = 0; |
| 381 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 382 |
} break; |
| 383 |
case KmdSysman::Requests::Frequency::CurrentVoltageTarget: { |
| 384 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 385 |
mockVoltageTarget[domain] = *pValue; |
| 386 |
pResponse->outDataSize = 0; |
| 387 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 388 |
} break; |
| 389 |
case KmdSysman::Requests::Frequency::CurrentFrequencyTarget: { |
| 390 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 391 |
mockFrequencyTarget[domain] = *pValue; |
| 392 |
pResponse->outDataSize = 0; |
| 393 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 394 |
} break; |
| 395 |
case KmdSysman::Requests::Frequency::CurrentIccMax: { |
| 396 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 397 |
mockIccMax = *pValue; |
| 398 |
pResponse->outDataSize = 0; |
| 399 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 400 |
} break; |
| 401 |
case KmdSysman::Requests::Frequency::CurrentTjMax: { |
| 402 |
uint32_t *pValue = reinterpret_cast<uint32_t *>(pBuffer); |
| 403 |
mockTjMax = *pValue; |
| 404 |
pResponse->outDataSize = 0; |
| 405 |
pResponse->outReturnCode = KmdSysman::KmdSysmanSuccess; |
| 406 |
} break; |
| 407 |
default: { |
| 408 |
pResponse->outDataSize = 0; |
| 409 |
pResponse->outReturnCode = KmdSysman::KmdSysmanFail; |
| 410 |
} break; |
| 411 |
} |
| 412 |
} |
| 413 |
}; |
| 414 |
|
| 415 |
} // namespace ult |
| 416 |
} // namespace Sysman |
| 417 |
} // namespace L0 |