feature: Add ECC support using igsc_gfsp_heci_cmd

Related-To: NEO-13444

Signed-off-by: shubham kumar <shubham.kumar@intel.com>
This commit is contained in:
shubham kumar 2025-05-10 18:03:02 +00:00 committed by Compute-Runtime-Automation
parent e7db2d9ba7
commit 82aedea8ca
19 changed files with 880 additions and 226 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2023 Intel Corporation * Copyright (C) 2023-2025 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -37,34 +37,29 @@ ze_result_t EccImp::deviceEccAvailable(ze_bool_t *pAvailable) {
if (pFwInterface == nullptr) { if (pFwInterface == nullptr) {
ze_result_t result = getEccFwUtilInterface(pFwInterface); ze_result_t result = getEccFwUtilInterface(pFwInterface);
if (result != ZE_RESULT_SUCCESS) { if (result != ZE_RESULT_SUCCESS) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed while getting EccFwUtilInterface() and returning error:0x%x \n", __FUNCTION__, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); return result;
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
} }
} }
*pAvailable = false; return pFwInterface->fwGetEccAvailable(pAvailable);
uint8_t currentState = 0;
uint8_t pendingState = 0;
ze_result_t result = pFwInterface->fwGetEccConfig(&currentState, &pendingState);
if (ZE_RESULT_SUCCESS == result) {
if ((currentState != eccStateNone) && (pendingState != eccStateNone)) {
*pAvailable = true;
}
}
return result;
} }
ze_result_t EccImp::deviceEccConfigurable(ze_bool_t *pConfigurable) { ze_result_t EccImp::deviceEccConfigurable(ze_bool_t *pConfigurable) {
return deviceEccAvailable(pConfigurable); if (pFwInterface == nullptr) {
ze_result_t result = getEccFwUtilInterface(pFwInterface);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
}
return pFwInterface->fwGetEccConfigurable(pConfigurable);
} }
ze_result_t EccImp::getEccState(zes_device_ecc_properties_t *pState) { ze_result_t EccImp::getEccState(zes_device_ecc_properties_t *pState) {
if (pFwInterface == nullptr) { if (pFwInterface == nullptr) {
ze_result_t result = getEccFwUtilInterface(pFwInterface); ze_result_t result = getEccFwUtilInterface(pFwInterface);
if (result != ZE_RESULT_SUCCESS) { if (result != ZE_RESULT_SUCCESS) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed while getting EccFwUtilInterface() and returning error \n", __FUNCTION__, ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); return result;
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
} }
} }
@ -72,7 +67,6 @@ ze_result_t EccImp::getEccState(zes_device_ecc_properties_t *pState) {
uint8_t pendingState = 0; uint8_t pendingState = 0;
ze_result_t result = pFwInterface->fwGetEccConfig(&currentState, &pendingState); ze_result_t result = pFwInterface->fwGetEccConfig(&currentState, &pendingState);
if (result != ZE_RESULT_SUCCESS) { if (result != ZE_RESULT_SUCCESS) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed to get ecc configuration and returning error:0x%x \n", __FUNCTION__, result);
return result; return result;
} }
pState->currentState = getEccState(currentState); pState->currentState = getEccState(currentState);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2022-2024 Intel Corporation * Copyright (C) 2022-2025 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -28,6 +28,8 @@ class FirmwareUtil {
virtual ze_result_t fwSupportedDiagTests(std::vector<std::string> &supportedDiagTests) = 0; virtual ze_result_t fwSupportedDiagTests(std::vector<std::string> &supportedDiagTests) = 0;
virtual ze_result_t fwRunDiagTests(std::string &osDiagType, zes_diag_result_t *pDiagResult) = 0; virtual ze_result_t fwRunDiagTests(std::string &osDiagType, zes_diag_result_t *pDiagResult) = 0;
virtual ze_result_t fwGetMemoryErrorCount(zes_ras_error_type_t type, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count) = 0; virtual ze_result_t fwGetMemoryErrorCount(zes_ras_error_type_t type, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count) = 0;
virtual ze_result_t fwGetEccAvailable(ze_bool_t *pAvailable) = 0;
virtual ze_result_t fwGetEccConfigurable(ze_bool_t *pConfigurable) = 0;
virtual ze_result_t fwGetEccConfig(uint8_t *currentState, uint8_t *pendingState) = 0; virtual ze_result_t fwGetEccConfig(uint8_t *currentState, uint8_t *pendingState) = 0;
virtual ze_result_t fwSetEccConfig(uint8_t newState, uint8_t *currentState, uint8_t *pendingState) = 0; virtual ze_result_t fwSetEccConfig(uint8_t newState, uint8_t *currentState, uint8_t *pendingState) = 0;
virtual void getDeviceSupportedFwTypes(std::vector<std::string> &fwTypes) = 0; virtual void getDeviceSupportedFwTypes(std::vector<std::string> &fwTypes) = 0;

View File

@ -74,14 +74,13 @@ typedef int (*pIgscIfrRunMemPPRTest)(struct igsc_device_handle *handle,
uint32_t *pendingReset, uint32_t *pendingReset,
uint32_t *errorCode); uint32_t *errorCode);
typedef int (*pIgscGetEccConfig)(struct igsc_device_handle *handle, typedef int (*pIgscGfspHeciCmd)(struct igsc_device_handle *handle,
uint8_t *curEccState, uint32_t gfspCmd,
uint8_t *penEccState); uint8_t *inBuffer,
size_t inBufferSize,
typedef int (*pIgscSetEccConfig)(struct igsc_device_handle *handle, uint8_t *outBuffer,
uint8_t reqEccState, size_t outBufferSize,
uint8_t *curEccState, size_t *actualOutBufferSize);
uint8_t *penEccState);
extern pIgscDeviceInitByDevice deviceInitByDevice; extern pIgscDeviceInitByDevice deviceInitByDevice;
extern pIgscDeviceGetDeviceInfo deviceGetDeviceInfo; extern pIgscDeviceGetDeviceInfo deviceGetDeviceInfo;
@ -100,8 +99,7 @@ extern pIgscIafPscUpdate iafPscUpdate;
extern pIgscGfspMemoryErrors gfspMemoryErrors; extern pIgscGfspMemoryErrors gfspMemoryErrors;
extern pIgscGfspCountTiles gfspCountTiles; extern pIgscGfspCountTiles gfspCountTiles;
extern pIgscIfrRunMemPPRTest deviceIfrRunMemPPRTest; extern pIgscIfrRunMemPPRTest deviceIfrRunMemPPRTest;
extern pIgscGetEccConfig getEccConfig; extern pIgscGfspHeciCmd gfspHeciCmd;
extern pIgscSetEccConfig setEccConfig;
extern void firmwareFlashProgressFunc(uint32_t done, uint32_t total, void *ctx); extern void firmwareFlashProgressFunc(uint32_t done, uint32_t total, void *ctx);
@ -110,6 +108,38 @@ typedef struct {
std::mutex fwProgressLock; std::mutex fwProgressLock;
} FlashProgressInfo; } FlashProgressInfo;
namespace GfspHeciConstants {
enum Cmd {
setEccConfigurationCmd8 = 0x8,
getEccConfigurationCmd9 = 0x9,
setEccConfigurationCmd15 = 0xf,
getEccConfigurationCmd16 = 0x10
};
enum SetEccCmd15BytePostition {
request = 0,
response = 0
};
enum SetEccCmd8BytePostition {
setRequest = 0,
responseCurrentState = 0,
responsePendingState = 1
};
enum GetEccCmd16BytePostition {
eccAvailable = 0,
eccCurrentState = 4,
eccConfigurable = 8,
eccPendingState = 12
};
enum GetEccCmd9BytePostition {
currentState = 0,
pendingState = 1
};
} // namespace GfspHeciConstants
class FirmwareUtilImp : public FirmwareUtil, NEO::NonCopyableAndNonMovableClass { class FirmwareUtilImp : public FirmwareUtil, NEO::NonCopyableAndNonMovableClass {
public: public:
FirmwareUtilImp(uint16_t domain, uint8_t bus, uint8_t device, uint8_t function); FirmwareUtilImp(uint16_t domain, uint8_t bus, uint8_t device, uint8_t function);
@ -122,6 +152,8 @@ class FirmwareUtilImp : public FirmwareUtil, NEO::NonCopyableAndNonMovableClass
ze_result_t fwSupportedDiagTests(std::vector<std::string> &supportedDiagTests) override; ze_result_t fwSupportedDiagTests(std::vector<std::string> &supportedDiagTests) override;
ze_result_t fwRunDiagTests(std::string &osDiagType, zes_diag_result_t *pDiagResult) override; ze_result_t fwRunDiagTests(std::string &osDiagType, zes_diag_result_t *pDiagResult) override;
ze_result_t fwGetMemoryErrorCount(zes_ras_error_type_t type, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count) override; ze_result_t fwGetMemoryErrorCount(zes_ras_error_type_t type, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count) override;
ze_result_t fwGetEccAvailable(ze_bool_t *pAvailable) override;
ze_result_t fwGetEccConfigurable(ze_bool_t *pConfigurable) override;
ze_result_t fwGetEccConfig(uint8_t *currentState, uint8_t *pendingState) override; ze_result_t fwGetEccConfig(uint8_t *currentState, uint8_t *pendingState) override;
ze_result_t fwSetEccConfig(uint8_t newState, uint8_t *currentState, uint8_t *pendingState) override; ze_result_t fwSetEccConfig(uint8_t newState, uint8_t *currentState, uint8_t *pendingState) override;
void getDeviceSupportedFwTypes(std::vector<std::string> &fwTypes) override; void getDeviceSupportedFwTypes(std::vector<std::string> &fwTypes) override;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020-2024 Intel Corporation * Copyright (C) 2020-2025 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -10,6 +10,9 @@
#include "level_zero/sysman/source/shared/firmware_util/sysman_firmware_util_imp.h" #include "level_zero/sysman/source/shared/firmware_util/sysman_firmware_util_imp.h"
static std::vector<std ::string> deviceSupportedFirmwareTypes = {"GSC", "OptionROM", "PSC"}; static std::vector<std ::string> deviceSupportedFirmwareTypes = {"GSC", "OptionROM", "PSC"};
static constexpr uint8_t eccStateNone = 0xFF;
constexpr uint8_t maxGfspHeciOutBuffer = UINT8_MAX;
constexpr uint8_t maxGfspHeciInBuffer = 4;
namespace L0 { namespace L0 {
namespace Sysman { namespace Sysman {
@ -20,8 +23,7 @@ const std::string fwGfspMemoryErrors = "igsc_gfsp_memory_errors";
const std::string fwGfspGetHealthIndicator = "igsc_gfsp_get_health_indicator"; const std::string fwGfspGetHealthIndicator = "igsc_gfsp_get_health_indicator";
const std::string fwGfspCountTiles = "igsc_gfsp_count_tiles"; const std::string fwGfspCountTiles = "igsc_gfsp_count_tiles";
const std::string fwDeviceIfrRunMemPPRTest = "igsc_ifr_run_mem_ppr_test"; const std::string fwDeviceIfrRunMemPPRTest = "igsc_ifr_run_mem_ppr_test";
const std::string fwEccConfigGet = "igsc_ecc_config_get"; const std::string fwGfspHeciCmd = "igsc_gfsp_heci_cmd";
const std::string fwEccConfigSet = "igsc_ecc_config_set";
pIgscIfrGetStatusExt deviceIfrGetStatusExt; pIgscIfrGetStatusExt deviceIfrGetStatusExt;
pIgscIafPscUpdate iafPscUpdate; pIgscIafPscUpdate iafPscUpdate;
@ -29,8 +31,7 @@ pIgscGfspMemoryErrors gfspMemoryErrors;
pIgscGfspCountTiles gfspCountTiles; pIgscGfspCountTiles gfspCountTiles;
pIgscGfspGetHealthIndicator gfspGetHealthIndicator; pIgscGfspGetHealthIndicator gfspGetHealthIndicator;
pIgscIfrRunMemPPRTest deviceIfrRunMemPPRTest; pIgscIfrRunMemPPRTest deviceIfrRunMemPPRTest;
pIgscGetEccConfig getEccConfig; pIgscGfspHeciCmd gfspHeciCmd;
pIgscSetEccConfig setEccConfig;
ze_result_t FirmwareUtilImp::fwIfrApplied(bool &ifrStatus) { ze_result_t FirmwareUtilImp::fwIfrApplied(bool &ifrStatus) {
uint32_t supportedTests = 0; // Bitmap holding the tests supported on the platform uint32_t supportedTests = 0; // Bitmap holding the tests supported on the platform
@ -143,26 +144,129 @@ void FirmwareUtilImp::fwGetMemoryHealthIndicator(zes_mem_health_t *health) {
ze_result_t FirmwareUtilImp::fwGetEccConfig(uint8_t *currentState, uint8_t *pendingState) { ze_result_t FirmwareUtilImp::fwGetEccConfig(uint8_t *currentState, uint8_t *pendingState) {
const std::lock_guard<std::mutex> lock(this->fwLock); const std::lock_guard<std::mutex> lock(this->fwLock);
getEccConfig = reinterpret_cast<pIgscGetEccConfig>(libraryHandle->getProcAddress(fwEccConfigGet)); gfspHeciCmd = reinterpret_cast<pIgscGfspHeciCmd>(libraryHandle->getProcAddress(fwGfspHeciCmd));
if (getEccConfig != nullptr) { if (gfspHeciCmd != nullptr) {
int ret = getEccConfig(&fwDeviceHandle, currentState, pendingState); std::vector<uint8_t> outBuf(maxGfspHeciOutBuffer, 0);
if (ret != IGSC_SUCCESS) { size_t receivedSize = 0;
return ZE_RESULT_ERROR_UNINITIALIZED; // Need to call gfspHeciCmd 0x10 cmd first and if not available, fallback and call 0x9.
int ret = gfspHeciCmd(&fwDeviceHandle, GfspHeciConstants::Cmd::getEccConfigurationCmd16, nullptr, 0, outBuf.data(), maxGfspHeciOutBuffer, &receivedSize);
if (ret == IGSC_SUCCESS) {
*currentState = outBuf[GfspHeciConstants::GetEccCmd16BytePostition::eccCurrentState] & 0x1;
*pendingState = outBuf[GfspHeciConstants::GetEccCmd16BytePostition::eccPendingState] & 0x1;
return ZE_RESULT_SUCCESS;
} }
return ZE_RESULT_SUCCESS; receivedSize = 0;
std::fill(outBuf.begin(), outBuf.end(), 0);
ret = gfspHeciCmd(&fwDeviceHandle, GfspHeciConstants::Cmd::getEccConfigurationCmd9, nullptr, 0, outBuf.data(), maxGfspHeciOutBuffer, &receivedSize);
if (ret == IGSC_SUCCESS) {
*currentState = outBuf[GfspHeciConstants::GetEccCmd9BytePostition::currentState];
*pendingState = outBuf[GfspHeciConstants::GetEccCmd9BytePostition::pendingState];
return ZE_RESULT_SUCCESS;
}
return ZE_RESULT_ERROR_UNINITIALIZED;
}
return ZE_RESULT_ERROR_UNINITIALIZED;
}
ze_result_t FirmwareUtilImp::fwGetEccAvailable(ze_bool_t *pAvailable) {
*pAvailable = false;
const std::lock_guard<std::mutex> lock(this->fwLock);
gfspHeciCmd = reinterpret_cast<pIgscGfspHeciCmd>(libraryHandle->getProcAddress(fwGfspHeciCmd));
if (gfspHeciCmd != nullptr) {
std::vector<uint8_t> outBuf(maxGfspHeciOutBuffer, 0);
size_t receivedSize = 0;
// Need to call gfspHeciCmd 0x10 cmd first and if not available, fallback and call 0x9.
int ret = gfspHeciCmd(&fwDeviceHandle, GfspHeciConstants::Cmd::getEccConfigurationCmd16, nullptr, 0, outBuf.data(), maxGfspHeciOutBuffer, &receivedSize);
if (ret == IGSC_SUCCESS) {
*pAvailable = outBuf[GfspHeciConstants::GetEccCmd16BytePostition::eccAvailable] & 0x1;
return ZE_RESULT_SUCCESS;
}
receivedSize = 0;
std::fill(outBuf.begin(), outBuf.end(), 0);
ret = gfspHeciCmd(&fwDeviceHandle, GfspHeciConstants::Cmd::getEccConfigurationCmd9, nullptr, 0, outBuf.data(), maxGfspHeciOutBuffer, &receivedSize);
if (ret == IGSC_SUCCESS) {
uint8_t currentState = outBuf[GfspHeciConstants::GetEccCmd9BytePostition::currentState];
uint8_t pendingState = outBuf[GfspHeciConstants::GetEccCmd9BytePostition::pendingState];
if ((currentState != eccStateNone) && (pendingState != eccStateNone)) {
*pAvailable = true;
}
return ZE_RESULT_SUCCESS;
}
return ZE_RESULT_ERROR_UNINITIALIZED;
}
return ZE_RESULT_ERROR_UNINITIALIZED;
}
ze_result_t FirmwareUtilImp::fwGetEccConfigurable(ze_bool_t *pConfigurable) {
*pConfigurable = false;
const std::lock_guard<std::mutex> lock(this->fwLock);
gfspHeciCmd = reinterpret_cast<pIgscGfspHeciCmd>(libraryHandle->getProcAddress(fwGfspHeciCmd));
if (gfspHeciCmd != nullptr) {
std::vector<uint8_t> outBuf(maxGfspHeciOutBuffer, 0);
size_t receivedSize = 0;
// Need to call gfspHeciCmd 0x10 cmd first and if not available, fallback and call 0x9.
int ret = gfspHeciCmd(&fwDeviceHandle, GfspHeciConstants::Cmd::getEccConfigurationCmd16, nullptr, 0, outBuf.data(), maxGfspHeciOutBuffer, &receivedSize);
if (ret == IGSC_SUCCESS) {
*pConfigurable = outBuf[GfspHeciConstants::GetEccCmd16BytePostition::eccConfigurable] & 0x1;
return ZE_RESULT_SUCCESS;
}
receivedSize = 0;
std::fill(outBuf.begin(), outBuf.end(), 0);
ret = gfspHeciCmd(&fwDeviceHandle, GfspHeciConstants::Cmd::getEccConfigurationCmd9, nullptr, 0, outBuf.data(), maxGfspHeciOutBuffer, &receivedSize);
if (ret == IGSC_SUCCESS) {
uint8_t currentState = outBuf[GfspHeciConstants::GetEccCmd9BytePostition::currentState];
uint8_t pendingState = outBuf[GfspHeciConstants::GetEccCmd9BytePostition::pendingState];
if ((currentState != eccStateNone) && (pendingState != eccStateNone)) {
*pConfigurable = true;
}
return ZE_RESULT_SUCCESS;
}
return ZE_RESULT_ERROR_UNINITIALIZED;
} }
return ZE_RESULT_ERROR_UNINITIALIZED; return ZE_RESULT_ERROR_UNINITIALIZED;
} }
ze_result_t FirmwareUtilImp::fwSetEccConfig(uint8_t newState, uint8_t *currentState, uint8_t *pendingState) { ze_result_t FirmwareUtilImp::fwSetEccConfig(uint8_t newState, uint8_t *currentState, uint8_t *pendingState) {
const std::lock_guard<std::mutex> lock(this->fwLock); std::unique_lock<std::mutex> lock(this->fwLock);
setEccConfig = reinterpret_cast<pIgscSetEccConfig>(libraryHandle->getProcAddress(fwEccConfigSet)); gfspHeciCmd = reinterpret_cast<pIgscGfspHeciCmd>(libraryHandle->getProcAddress(fwGfspHeciCmd));
if (setEccConfig != nullptr) { if (gfspHeciCmd != nullptr) {
int ret = setEccConfig(&fwDeviceHandle, newState, currentState, pendingState); std::vector<uint8_t> inBuf(maxGfspHeciInBuffer, 0);
if (ret != IGSC_SUCCESS) { std::vector<uint8_t> outBuf(maxGfspHeciOutBuffer, 0);
return ZE_RESULT_ERROR_UNINITIALIZED; size_t receivedSize = 0;
inBuf[GfspHeciConstants::SetEccCmd15BytePostition::request] = newState;
// Need to call gfspHeciCmd 0x15 cmd first and if not available, fallback and call 0x8.
int ret = gfspHeciCmd(&fwDeviceHandle, GfspHeciConstants::Cmd::setEccConfigurationCmd15, inBuf.data(), maxGfspHeciInBuffer, outBuf.data(), maxGfspHeciOutBuffer, &receivedSize);
if (ret == IGSC_SUCCESS) {
lock.unlock();
ze_result_t status = fwGetEccConfig(currentState, pendingState);
lock.lock();
if (status != ZE_RESULT_SUCCESS) {
return status;
}
*pendingState = outBuf[GfspHeciConstants::SetEccCmd15BytePostition::response] & 0x1;
return ZE_RESULT_SUCCESS;
} }
return ZE_RESULT_SUCCESS; receivedSize = 0;
std::fill(inBuf.begin(), inBuf.end(), 0);
inBuf[GfspHeciConstants::SetEccCmd8BytePostition::setRequest] = newState;
std::fill(outBuf.begin(), outBuf.end(), 0);
ret = gfspHeciCmd(&fwDeviceHandle, GfspHeciConstants::Cmd::setEccConfigurationCmd8, inBuf.data(), maxGfspHeciInBuffer, outBuf.data(), maxGfspHeciOutBuffer, &receivedSize);
if (ret == IGSC_SUCCESS) {
*currentState = outBuf[GfspHeciConstants::SetEccCmd8BytePostition::responseCurrentState];
*pendingState = outBuf[GfspHeciConstants::SetEccCmd8BytePostition::responsePendingState];
return ZE_RESULT_SUCCESS;
}
return ZE_RESULT_ERROR_UNINITIALIZED;
} }
return ZE_RESULT_ERROR_UNINITIALIZED; return ZE_RESULT_ERROR_UNINITIALIZED;
} }

View File

@ -1073,6 +1073,11 @@ ze_result_t SysmanProductHelperHw<gfxProduct>::getPowerEnergyCounter(zes_power_e
return ZE_RESULT_SUCCESS; return ZE_RESULT_SUCCESS;
} }
template <>
bool SysmanProductHelperHw<gfxProduct>::isEccConfigurationSupported() {
return true;
}
template class SysmanProductHelperHw<gfxProduct>; template class SysmanProductHelperHw<gfxProduct>;
} // namespace Sysman } // namespace Sysman

View File

@ -60,6 +60,8 @@ struct MockDiagnosticsFwInterface : public L0::Sysman::FirmwareUtil {
ADDMETHOD_NOBASE(flashFirmware, ze_result_t, ZE_RESULT_SUCCESS, (std::string fwType, void *pImage, uint32_t size)); ADDMETHOD_NOBASE(flashFirmware, ze_result_t, ZE_RESULT_SUCCESS, (std::string fwType, void *pImage, uint32_t size));
ADDMETHOD_NOBASE(fwIfrApplied, ze_result_t, ZE_RESULT_SUCCESS, (bool &ifrStatus)); ADDMETHOD_NOBASE(fwIfrApplied, ze_result_t, ZE_RESULT_SUCCESS, (bool &ifrStatus));
ADDMETHOD_NOBASE(fwGetMemoryErrorCount, ze_result_t, ZE_RESULT_SUCCESS, (zes_ras_error_type_t category, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count)); ADDMETHOD_NOBASE(fwGetMemoryErrorCount, ze_result_t, ZE_RESULT_SUCCESS, (zes_ras_error_type_t category, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count));
ADDMETHOD_NOBASE(fwGetEccAvailable, ze_result_t, ZE_RESULT_SUCCESS, (ze_bool_t * pAvailable));
ADDMETHOD_NOBASE(fwGetEccConfigurable, ze_result_t, ZE_RESULT_SUCCESS, (ze_bool_t * pConfigurable));
ADDMETHOD_NOBASE(fwGetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t * currentState, uint8_t *pendingState)); ADDMETHOD_NOBASE(fwGetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t * currentState, uint8_t *pendingState));
ADDMETHOD_NOBASE(fwSetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t newState, uint8_t *currentState, uint8_t *pendingState)); ADDMETHOD_NOBASE(fwSetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t newState, uint8_t *currentState, uint8_t *pendingState));
ADDMETHOD_NOBASE_VOIDRETURN(getDeviceSupportedFwTypes, (std::vector<std::string> & fwTypes)); ADDMETHOD_NOBASE_VOIDRETURN(getDeviceSupportedFwTypes, (std::vector<std::string> & fwTypes));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2023-2024 Intel Corporation * Copyright (C) 2023-2025 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -20,8 +20,12 @@ namespace ult {
struct MockEccFwInterface : public L0::Sysman::FirmwareUtil { struct MockEccFwInterface : public L0::Sysman::FirmwareUtil {
ze_result_t mockFwGetEccConfigResult = ZE_RESULT_SUCCESS; ze_result_t mockFwGetEccConfigResult = ZE_RESULT_SUCCESS;
ze_result_t mockFwSetEccConfigResult = ZE_RESULT_SUCCESS; ze_result_t mockFwSetEccConfigResult = ZE_RESULT_SUCCESS;
ze_result_t mockFwGetEccAvailableResult = ZE_RESULT_SUCCESS;
ze_result_t mockFwGetEccConfigurableResult = ZE_RESULT_SUCCESS;
ze_bool_t mockSetConfig = true; ze_bool_t mockSetConfig = true;
ze_bool_t mockEccAvailable = true;
ze_bool_t mockEccConfigurable = true;
uint8_t mockCurrentState = 0; uint8_t mockCurrentState = 0;
uint8_t mockPendingState = 0; uint8_t mockPendingState = 0;
@ -50,6 +54,24 @@ struct MockEccFwInterface : public L0::Sysman::FirmwareUtil {
return ZE_RESULT_SUCCESS; return ZE_RESULT_SUCCESS;
} }
ze_result_t fwGetEccAvailable(ze_bool_t *pAvailable) override {
if (mockFwGetEccAvailableResult != ZE_RESULT_SUCCESS) {
return mockFwGetEccAvailableResult;
}
*pAvailable = mockEccAvailable;
return ZE_RESULT_SUCCESS;
}
ze_result_t fwGetEccConfigurable(ze_bool_t *pAvailable) override {
if (mockFwGetEccConfigurableResult != ZE_RESULT_SUCCESS) {
return mockFwGetEccConfigurableResult;
}
*pAvailable = mockEccConfigurable;
return ZE_RESULT_SUCCESS;
}
ADDMETHOD_NOBASE(getFwVersion, ze_result_t, ZE_RESULT_SUCCESS, (std::string fwType, std::string &firmwareVersion)); ADDMETHOD_NOBASE(getFwVersion, ze_result_t, ZE_RESULT_SUCCESS, (std::string fwType, std::string &firmwareVersion));
ADDMETHOD_NOBASE(getFlashFirmwareProgress, ze_result_t, ZE_RESULT_SUCCESS, (uint32_t * pCompletionPercent)); ADDMETHOD_NOBASE(getFlashFirmwareProgress, ze_result_t, ZE_RESULT_SUCCESS, (uint32_t * pCompletionPercent));
ADDMETHOD_NOBASE(flashFirmware, ze_result_t, ZE_RESULT_SUCCESS, (std::string fwType, void *pImage, uint32_t size)); ADDMETHOD_NOBASE(flashFirmware, ze_result_t, ZE_RESULT_SUCCESS, (std::string fwType, void *pImage, uint32_t size));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2023-2024 Intel Corporation * Copyright (C) 2023-2025 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -39,13 +39,6 @@ class ZesEccFixture : public SysmanDeviceFixture {
} }
}; };
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndFwInterfaceIsPresentWhenCallingzesDeviceEccAvailableThenVerifyApiCallSucceeds, IsDG2) {
ze_bool_t eccAvailable = false;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccAvailable(device, &eccAvailable));
EXPECT_EQ(true, eccAvailable);
}
TEST_F(ZesEccFixture, GivenValidSysmanHandleAndEccUnsupportedWhenCallingzesDeviceEccAvailableThenVerifyApiCallFails) { TEST_F(ZesEccFixture, GivenValidSysmanHandleAndEccUnsupportedWhenCallingzesDeviceEccAvailableThenVerifyApiCallFails) {
struct MockSysmanProductHelperEcc : L0::Sysman::SysmanProductHelperHw<IGFX_UNKNOWN> { struct MockSysmanProductHelperEcc : L0::Sysman::SysmanProductHelperHw<IGFX_UNKNOWN> {
MockSysmanProductHelperEcc() = default; MockSysmanProductHelperEcc() = default;
@ -59,138 +52,6 @@ TEST_F(ZesEccFixture, GivenValidSysmanHandleAndEccUnsupportedWhenCallingzesDevic
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesDeviceEccAvailable(device, &eccAvailable)); EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesDeviceEccAvailable(device, &eccAvailable));
} }
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndFwInterfaceIsPresentWhenCallingzesDeviceEccConfigurableThenVerifyApiCallSucceeds, IsDG2) {
ze_bool_t eccConfigurable = false;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccConfigurable(device, &eccConfigurable));
EXPECT_EQ(true, eccConfigurable);
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndFwInterfaceIsAbsentWhenCallingEccApiThenVerifyApiCallReturnFailure, IsDG2) {
ze_bool_t eccConfigurable = true;
ze_bool_t eccAvailable = true;
L0::Sysman::EccImp *tempEccImp = new L0::Sysman::EccImp(pOsSysman);
pLinuxSysmanImp->pFwUtilInterface = nullptr;
tempEccImp->init();
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, tempEccImp->deviceEccAvailable(&eccAvailable));
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, tempEccImp->deviceEccConfigurable(&eccConfigurable));
zes_device_ecc_desc_t newState = {};
zes_device_ecc_properties_t props = {};
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, tempEccImp->setEccState(&newState, &props));
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, tempEccImp->getEccState(&props));
delete tempEccImp;
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndFwGetEccConfigFailsWhenCallingzesDeviceEccConfigurableAndAvailableThenVerifyApiCallReturnsFailure, IsDG2) {
ze_bool_t eccConfigurable = true;
ze_bool_t eccAvailable = true;
pMockFwInterface->mockFwGetEccConfigResult = ZE_RESULT_ERROR_UNINITIALIZED;
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, zesDeviceEccAvailable(device, &eccAvailable));
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, zesDeviceEccConfigurable(device, &eccConfigurable));
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndCurrentStateIsNoneWhenCallingzesDeviceEccConfigurableAndAvailableThenNotSupportedEccIsReturned, IsDG2) {
ze_bool_t eccConfigurable = true;
ze_bool_t eccAvailable = true;
pMockFwInterface->mockCurrentState = eccStateNone;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccAvailable(device, &eccAvailable));
EXPECT_EQ(false, eccAvailable);
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccConfigurable(device, &eccConfigurable));
EXPECT_EQ(false, eccConfigurable);
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndPendingStateIsNoneWhenCallingzesDeviceEccConfigurableAndAvailableThenNotSupportedEccIsReturned, IsDG2) {
ze_bool_t eccConfigurable = true;
ze_bool_t eccAvailable = true;
pMockFwInterface->mockPendingState = eccStateNone;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccAvailable(device, &eccAvailable));
EXPECT_EQ(false, eccAvailable);
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccConfigurable(device, &eccConfigurable));
EXPECT_EQ(false, eccConfigurable);
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndFwInterfaceIsPresentWhenCallingzesDeviceGetEccStateThenApiCallSucceeds, IsDG2) {
zes_device_ecc_properties_t props = {};
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetEccState(device, &props));
EXPECT_EQ(ZES_DEVICE_ECC_STATE_DISABLED, props.currentState);
EXPECT_EQ(ZES_DEVICE_ECC_STATE_DISABLED, props.pendingState);
EXPECT_EQ(ZES_DEVICE_ACTION_NONE, props.pendingAction);
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndFwGetEccConfigFailsWhenCallingzesDeviceGetEccStateThenApiCallReturnFailure, IsDG2) {
zes_device_ecc_properties_t props = {};
pMockFwInterface->mockFwGetEccConfigResult = ZE_RESULT_ERROR_UNINITIALIZED;
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, zesDeviceGetEccState(device, &props));
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndFwInterfaceIsPresentWhenCallingzesDeviceSetEccStateThenApiCallSucceeds, IsDG2) {
zes_device_ecc_desc_t newState = {ZES_STRUCTURE_TYPE_DEVICE_STATE, nullptr, ZES_DEVICE_ECC_STATE_ENABLED};
zes_device_ecc_properties_t props = {};
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceSetEccState(device, &newState, &props));
newState.state = ZES_DEVICE_ECC_STATE_DISABLED;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceSetEccState(device, &newState, &props));
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndFwInterfaceIsPresentWhenCallingzesDeviceSetEccStateWithInvalidEnumThenFailureIsReturned, IsDG2) {
zes_device_ecc_desc_t newState = {ZES_STRUCTURE_TYPE_DEVICE_STATE, nullptr, ZES_DEVICE_ECC_STATE_UNAVAILABLE};
zes_device_ecc_properties_t props = {};
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ENUMERATION, zesDeviceSetEccState(device, &newState, &props));
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndFwSetEccConfigFailsWhenCallingzesDeviceSetEccStateThenFailureIsReturned, IsDG2) {
zes_device_ecc_desc_t newState = {ZES_STRUCTURE_TYPE_DEVICE_STATE, nullptr, ZES_DEVICE_ECC_STATE_ENABLED};
zes_device_ecc_properties_t props = {};
pMockFwInterface->mockFwSetEccConfigResult = ZE_RESULT_ERROR_UNINITIALIZED;
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, zesDeviceSetEccState(device, &newState, &props));
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleWhenCallingEccSetStateAndEccGetStateThenVerifyApiCallSuccedsAndValidStatesAreReturned, IsDG2) {
zes_device_ecc_desc_t newState = {ZES_STRUCTURE_TYPE_DEVICE_STATE, nullptr, ZES_DEVICE_ECC_STATE_ENABLED};
zes_device_ecc_properties_t props = {};
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceSetEccState(device, &newState, &props));
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetEccState(device, &props));
EXPECT_EQ(ZES_DEVICE_ECC_STATE_ENABLED, props.pendingState);
newState.state = ZES_DEVICE_ECC_STATE_DISABLED;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceSetEccState(device, &newState, &props));
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetEccState(device, &props));
EXPECT_EQ(ZES_DEVICE_ECC_STATE_DISABLED, props.pendingState);
pMockFwInterface->mockSetConfig = false;
pMockFwInterface->mockCurrentState = eccStateNone;
pMockFwInterface->mockPendingState = eccStateNone;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceSetEccState(device, &newState, &props));
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetEccState(device, &props));
EXPECT_EQ(ZES_DEVICE_ECC_STATE_UNAVAILABLE, props.pendingState);
EXPECT_EQ(ZES_DEVICE_ECC_STATE_UNAVAILABLE, props.currentState);
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleWhenCallingEccSetStateAndEccGetStateThenVerifyApiCallSuccedsAndValidActionIsReturned, IsDG2) {
zes_device_ecc_desc_t newState = {ZES_STRUCTURE_TYPE_DEVICE_STATE, nullptr, ZES_DEVICE_ECC_STATE_ENABLED};
zes_device_ecc_properties_t props = {};
pMockFwInterface->mockCurrentState = eccStateEnable;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceSetEccState(device, &newState, &props));
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetEccState(device, &props));
EXPECT_EQ(ZES_DEVICE_ECC_STATE_ENABLED, props.pendingState);
EXPECT_EQ(ZES_DEVICE_ACTION_NONE, props.pendingAction);
newState.state = ZES_DEVICE_ECC_STATE_DISABLED;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceSetEccState(device, &newState, &props));
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetEccState(device, &props));
EXPECT_EQ(ZES_DEVICE_ECC_STATE_DISABLED, props.pendingState);
EXPECT_EQ(ZES_DEVICE_ACTION_WARM_CARD_RESET, props.pendingAction);
}
} // namespace ult } // namespace ult
} // namespace Sysman } // namespace Sysman
} // namespace L0 } // namespace L0

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2023-2024 Intel Corporation * Copyright (C) 2023-2025 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -19,9 +19,13 @@ struct EccFwInterface : public L0::Sysman::FirmwareUtil {
ze_result_t mockFwGetEccConfigResult = ZE_RESULT_SUCCESS; ze_result_t mockFwGetEccConfigResult = ZE_RESULT_SUCCESS;
ze_result_t mockFwSetEccConfigResult = ZE_RESULT_SUCCESS; ze_result_t mockFwSetEccConfigResult = ZE_RESULT_SUCCESS;
ze_result_t mockFwGetEccAvailableResult = ZE_RESULT_SUCCESS;
ze_result_t mockFwGetEccConfigurableResult = ZE_RESULT_SUCCESS;
ze_result_t mockFwDeviceInit = ZE_RESULT_SUCCESS; ze_result_t mockFwDeviceInit = ZE_RESULT_SUCCESS;
ze_bool_t mockSetConfig = true; ze_bool_t mockSetConfig = true;
ze_bool_t mockEccAvailable = true;
ze_bool_t mockEccConfigurable = true;
uint8_t mockCurrentState = 0; uint8_t mockCurrentState = 0;
uint8_t mockPendingState = 0; uint8_t mockPendingState = 0;
@ -54,6 +58,24 @@ struct EccFwInterface : public L0::Sysman::FirmwareUtil {
return ZE_RESULT_SUCCESS; return ZE_RESULT_SUCCESS;
} }
ze_result_t fwGetEccAvailable(ze_bool_t *pAvailable) override {
if (mockFwGetEccAvailableResult != ZE_RESULT_SUCCESS) {
return mockFwGetEccAvailableResult;
}
*pAvailable = mockEccAvailable;
return ZE_RESULT_SUCCESS;
}
ze_result_t fwGetEccConfigurable(ze_bool_t *pAvailable) override {
if (mockFwGetEccConfigurableResult != ZE_RESULT_SUCCESS) {
return mockFwGetEccConfigurableResult;
}
*pAvailable = mockEccConfigurable;
return ZE_RESULT_SUCCESS;
}
ADDMETHOD_NOBASE(getFwVersion, ze_result_t, ZE_RESULT_SUCCESS, (std::string fwType, std::string &firmwareVersion)); ADDMETHOD_NOBASE(getFwVersion, ze_result_t, ZE_RESULT_SUCCESS, (std::string fwType, std::string &firmwareVersion));
ADDMETHOD_NOBASE(getFlashFirmwareProgress, ze_result_t, ZE_RESULT_SUCCESS, (uint32_t * pCompletionPercent)); ADDMETHOD_NOBASE(getFlashFirmwareProgress, ze_result_t, ZE_RESULT_SUCCESS, (uint32_t * pCompletionPercent));
ADDMETHOD_NOBASE(flashFirmware, ze_result_t, ZE_RESULT_SUCCESS, (std::string fwType, void *pImage, uint32_t size)); ADDMETHOD_NOBASE(flashFirmware, ze_result_t, ZE_RESULT_SUCCESS, (std::string fwType, void *pImage, uint32_t size));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2023 Intel Corporation * Copyright (C) 2023-2025 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -43,16 +43,22 @@ class ZesEccFixture : public SysmanDeviceFixture {
} }
}; };
TEST_F(ZesEccFixture, GivenValidSysmanHandleAndFwInterfaceIsPresentWhenCallingzesDeviceEccAvailableThenVerifyApiCallSucceeds) { TEST_F(ZesEccFixture, GivenValidSysmanHandleAndFwInterfaceIsPresentWhenCallingzesDeviceEccAvailableTwiceThenVerifyApiCallSucceeds) {
ze_bool_t eccAvailable = false; ze_bool_t eccAvailable = false;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccAvailable(pSysmanDevice->toHandle(), &eccAvailable));
EXPECT_EQ(true, eccAvailable);
eccAvailable = false;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccAvailable(pSysmanDevice->toHandle(), &eccAvailable)); EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccAvailable(pSysmanDevice->toHandle(), &eccAvailable));
EXPECT_EQ(true, eccAvailable); EXPECT_EQ(true, eccAvailable);
} }
TEST_F(ZesEccFixture, GivenValidSysmanHandleAndFwInterfaceIsPresentWhenCallingzesDeviceEccConfigurableThenVerifyApiCallSucceeds) { TEST_F(ZesEccFixture, GivenValidSysmanHandleAndFwInterfaceIsPresentWhenCallingzesDeviceEccConfigurableTwiceThenVerifyApiCallSucceeds) {
ze_bool_t eccConfigurable = false; ze_bool_t eccConfigurable = false;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccConfigurable(pSysmanDevice->toHandle(), &eccConfigurable));
EXPECT_EQ(true, eccConfigurable);
eccConfigurable = false;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccConfigurable(pSysmanDevice->toHandle(), &eccConfigurable)); EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccConfigurable(pSysmanDevice->toHandle(), &eccConfigurable));
EXPECT_EQ(true, eccConfigurable); EXPECT_EQ(true, eccConfigurable);
} }
@ -76,7 +82,8 @@ TEST_F(ZesEccFixture, GivenValidSysmanHandleAndFwInterfaceIsAbsentWhenCallingEcc
TEST_F(ZesEccFixture, GivenValidSysmanHandleAndFwGetEccConfigFailsWhenCallingzesDeviceEccConfigurableAndAvailableThenVerifyApiCallReturnsFailure) { TEST_F(ZesEccFixture, GivenValidSysmanHandleAndFwGetEccConfigFailsWhenCallingzesDeviceEccConfigurableAndAvailableThenVerifyApiCallReturnsFailure) {
ze_bool_t eccConfigurable = true; ze_bool_t eccConfigurable = true;
ze_bool_t eccAvailable = true; ze_bool_t eccAvailable = true;
pMockFwInterface->mockFwGetEccConfigResult = ZE_RESULT_ERROR_UNINITIALIZED; pMockFwInterface->mockFwGetEccAvailableResult = ZE_RESULT_ERROR_UNINITIALIZED;
pMockFwInterface->mockFwGetEccConfigurableResult = ZE_RESULT_ERROR_UNINITIALIZED;
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, zesDeviceEccAvailable(pSysmanDevice->toHandle(), &eccAvailable)); EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, zesDeviceEccAvailable(pSysmanDevice->toHandle(), &eccAvailable));
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, zesDeviceEccConfigurable(pSysmanDevice->toHandle(), &eccConfigurable)); EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, zesDeviceEccConfigurable(pSysmanDevice->toHandle(), &eccConfigurable));
@ -85,18 +92,8 @@ TEST_F(ZesEccFixture, GivenValidSysmanHandleAndFwGetEccConfigFailsWhenCallingzes
TEST_F(ZesEccFixture, GivenValidSysmanHandleAndCurrentStateIsNoneWhenCallingzesDeviceEccConfigurableAndAvailableThenNotSupportedEccIsReturned) { TEST_F(ZesEccFixture, GivenValidSysmanHandleAndCurrentStateIsNoneWhenCallingzesDeviceEccConfigurableAndAvailableThenNotSupportedEccIsReturned) {
ze_bool_t eccConfigurable = true; ze_bool_t eccConfigurable = true;
ze_bool_t eccAvailable = true; ze_bool_t eccAvailable = true;
pMockFwInterface->mockCurrentState = eccStateNone; pMockFwInterface->mockEccAvailable = false;
pMockFwInterface->mockEccConfigurable = false;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccAvailable(pSysmanDevice->toHandle(), &eccAvailable));
EXPECT_EQ(false, eccAvailable);
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccConfigurable(pSysmanDevice->toHandle(), &eccConfigurable));
EXPECT_EQ(false, eccConfigurable);
}
TEST_F(ZesEccFixture, GivenValidSysmanHandleAndPendingStateIsNoneWhenCallingzesDeviceEccConfigurableAndAvailableThenNotSupportedEccIsReturned) {
ze_bool_t eccConfigurable = true;
ze_bool_t eccAvailable = true;
pMockFwInterface->mockPendingState = eccStateNone;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccAvailable(pSysmanDevice->toHandle(), &eccAvailable)); EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccAvailable(pSysmanDevice->toHandle(), &eccAvailable));
EXPECT_EQ(false, eccAvailable); EXPECT_EQ(false, eccAvailable);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2023-2024 Intel Corporation * Copyright (C) 2023-2025 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -252,6 +252,8 @@ struct MockEventsFwInterface : public L0::Sysman::FirmwareUtil {
ADDMETHOD_NOBASE(fwSupportedDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::vector<std::string> & supportedDiagTests)); ADDMETHOD_NOBASE(fwSupportedDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::vector<std::string> & supportedDiagTests));
ADDMETHOD_NOBASE(fwRunDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::string & osDiagType, zes_diag_result_t *pResult)); ADDMETHOD_NOBASE(fwRunDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::string & osDiagType, zes_diag_result_t *pResult));
ADDMETHOD_NOBASE(fwGetMemoryErrorCount, ze_result_t, ZE_RESULT_SUCCESS, (zes_ras_error_type_t category, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count)); ADDMETHOD_NOBASE(fwGetMemoryErrorCount, ze_result_t, ZE_RESULT_SUCCESS, (zes_ras_error_type_t category, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count));
ADDMETHOD_NOBASE(fwGetEccAvailable, ze_result_t, ZE_RESULT_SUCCESS, (ze_bool_t * pAvailable));
ADDMETHOD_NOBASE(fwGetEccConfigurable, ze_result_t, ZE_RESULT_SUCCESS, (ze_bool_t * pConfigurable));
ADDMETHOD_NOBASE(fwGetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t * currentState, uint8_t *pendingState)); ADDMETHOD_NOBASE(fwGetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t * currentState, uint8_t *pendingState));
ADDMETHOD_NOBASE(fwSetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t newState, uint8_t *currentState, uint8_t *pendingState)); ADDMETHOD_NOBASE(fwSetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t newState, uint8_t *currentState, uint8_t *pendingState));
ADDMETHOD_NOBASE_VOIDRETURN(getDeviceSupportedFwTypes, (std::vector<std::string> & fwTypes)); ADDMETHOD_NOBASE_VOIDRETURN(getDeviceSupportedFwTypes, (std::vector<std::string> & fwTypes));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020-2024 Intel Corporation * Copyright (C) 2020-2025 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -124,6 +124,8 @@ struct MockFirmwareInterface : public FirmwareInterface {
ADDMETHOD_NOBASE(fwSupportedDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::vector<std::string> & supportedDiagTests)); ADDMETHOD_NOBASE(fwSupportedDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::vector<std::string> & supportedDiagTests));
ADDMETHOD_NOBASE(fwRunDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::string & osDiagType, zes_diag_result_t *pResult)); ADDMETHOD_NOBASE(fwRunDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::string & osDiagType, zes_diag_result_t *pResult));
ADDMETHOD_NOBASE(fwGetMemoryErrorCount, ze_result_t, ZE_RESULT_SUCCESS, (zes_ras_error_type_t category, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count)); ADDMETHOD_NOBASE(fwGetMemoryErrorCount, ze_result_t, ZE_RESULT_SUCCESS, (zes_ras_error_type_t category, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count));
ADDMETHOD_NOBASE(fwGetEccAvailable, ze_result_t, ZE_RESULT_SUCCESS, (ze_bool_t * pAvailable));
ADDMETHOD_NOBASE(fwGetEccConfigurable, ze_result_t, ZE_RESULT_SUCCESS, (ze_bool_t * pConfigurable));
ADDMETHOD_NOBASE(fwGetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t * currentState, uint8_t *pendingState)); ADDMETHOD_NOBASE(fwGetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t * currentState, uint8_t *pendingState));
ADDMETHOD_NOBASE(fwSetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t newState, uint8_t *currentState, uint8_t *pendingState)); ADDMETHOD_NOBASE(fwSetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t newState, uint8_t *currentState, uint8_t *pendingState));
ADDMETHOD_NOBASE_VOIDRETURN(fwGetMemoryHealthIndicator, (zes_mem_health_t * health)); ADDMETHOD_NOBASE_VOIDRETURN(fwGetMemoryHealthIndicator, (zes_mem_health_t * health));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2023-2024 Intel Corporation * Copyright (C) 2023-2025 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -60,6 +60,8 @@ struct FirmwareInterface : public L0::Sysman::FirmwareUtil {
ADDMETHOD_NOBASE(fwSupportedDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::vector<std::string> & supportedDiagTests)); ADDMETHOD_NOBASE(fwSupportedDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::vector<std::string> & supportedDiagTests));
ADDMETHOD_NOBASE(fwRunDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::string & osDiagType, zes_diag_result_t *pResult)); ADDMETHOD_NOBASE(fwRunDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::string & osDiagType, zes_diag_result_t *pResult));
ADDMETHOD_NOBASE(fwGetMemoryErrorCount, ze_result_t, ZE_RESULT_SUCCESS, (zes_ras_error_type_t category, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count)); ADDMETHOD_NOBASE(fwGetMemoryErrorCount, ze_result_t, ZE_RESULT_SUCCESS, (zes_ras_error_type_t category, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count));
ADDMETHOD_NOBASE(fwGetEccAvailable, ze_result_t, ZE_RESULT_SUCCESS, (ze_bool_t * pAvailable));
ADDMETHOD_NOBASE(fwGetEccConfigurable, ze_result_t, ZE_RESULT_SUCCESS, (ze_bool_t * pConfigurable));
ADDMETHOD_NOBASE(fwGetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t * currentState, uint8_t *pendingState)); ADDMETHOD_NOBASE(fwGetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t * currentState, uint8_t *pendingState));
ADDMETHOD_NOBASE(fwSetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t newState, uint8_t *currentState, uint8_t *pendingState)); ADDMETHOD_NOBASE(fwSetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t newState, uint8_t *currentState, uint8_t *pendingState));
ADDMETHOD_NOBASE_VOIDRETURN(fwGetMemoryHealthIndicator, (zes_mem_health_t * health)); ADDMETHOD_NOBASE_VOIDRETURN(fwGetMemoryHealthIndicator, (zes_mem_health_t * health));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2022-2024 Intel Corporation * Copyright (C) 2022-2025 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -31,6 +31,8 @@ struct MockFwUtilInterface : public L0::Sysman::FirmwareUtil {
ADDMETHOD_NOBASE(fwSupportedDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::vector<std::string> & supportedDiagTests)); ADDMETHOD_NOBASE(fwSupportedDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::vector<std::string> & supportedDiagTests));
ADDMETHOD_NOBASE(fwRunDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::string & osDiagType, zes_diag_result_t *pResult)); ADDMETHOD_NOBASE(fwRunDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::string & osDiagType, zes_diag_result_t *pResult));
ADDMETHOD_NOBASE(fwGetMemoryErrorCount, ze_result_t, ZE_RESULT_SUCCESS, (zes_ras_error_type_t category, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count)); ADDMETHOD_NOBASE(fwGetMemoryErrorCount, ze_result_t, ZE_RESULT_SUCCESS, (zes_ras_error_type_t category, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count));
ADDMETHOD_NOBASE(fwGetEccAvailable, ze_result_t, ZE_RESULT_SUCCESS, (ze_bool_t * pAvailable));
ADDMETHOD_NOBASE(fwGetEccConfigurable, ze_result_t, ZE_RESULT_SUCCESS, (ze_bool_t * pConfigurable));
ADDMETHOD_NOBASE(fwGetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t * currentState, uint8_t *pendingState)); ADDMETHOD_NOBASE(fwGetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t * currentState, uint8_t *pendingState));
ADDMETHOD_NOBASE(fwSetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t newState, uint8_t *currentState, uint8_t *pendingState)); ADDMETHOD_NOBASE(fwSetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t newState, uint8_t *currentState, uint8_t *pendingState));
ADDMETHOD_NOBASE_VOIDRETURN(getDeviceSupportedFwTypes, (std::vector<std::string> & fwTypes)); ADDMETHOD_NOBASE_VOIDRETURN(getDeviceSupportedFwTypes, (std::vector<std::string> & fwTypes));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2022-2024 Intel Corporation * Copyright (C) 2022-2025 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -11,18 +11,31 @@
#include "level_zero/sysman/source/shared/firmware_util/sysman_firmware_util_imp.h" #include "level_zero/sysman/source/shared/firmware_util/sysman_firmware_util_imp.h"
#include "level_zero/sysman/test/unit_tests/sources/firmware_util/mock_fw_util_fixture.h" #include "level_zero/sysman/test/unit_tests/sources/firmware_util/mock_fw_util_fixture.h"
#include <algorithm>
namespace L0 { namespace L0 {
extern L0::Sysman::pIgscIfrGetStatusExt L0::Sysman::deviceIfrGetStatusExt; extern L0::Sysman::pIgscIfrGetStatusExt L0::Sysman::deviceIfrGetStatusExt;
extern L0::Sysman::pIgscIfrRunMemPPRTest L0::Sysman::deviceIfrRunMemPPRTest; extern L0::Sysman::pIgscIfrRunMemPPRTest L0::Sysman::deviceIfrRunMemPPRTest;
extern L0::Sysman::pIgscGetEccConfig getEccConfig; extern L0::Sysman::pIgscGfspHeciCmd gfspHeciCmd;
extern L0::Sysman::pIgscSetEccConfig setEccConfig;
namespace Sysman { namespace Sysman {
namespace ult { namespace ult {
constexpr static uint32_t mockMaxTileCount = 2; constexpr static uint32_t mockMaxTileCount = 2;
static int mockMemoryHealthIndicator = IGSC_HEALTH_INDICATOR_HEALTHY; static int mockMemoryHealthIndicator = IGSC_HEALTH_INDICATOR_HEALTHY;
std::vector<uint32_t> mockSupportedHeciCmds = {GfspHeciConstants::Cmd::getEccConfigurationCmd16, GfspHeciConstants::Cmd::setEccConfigurationCmd15};
uint8_t mockEccCurrentState = 1;
uint8_t mockEccPendingState = 1;
uint8_t mockEccHeciCmd16Val = 1;
void restoreEccMockVars() {
mockSupportedHeciCmds.clear();
mockSupportedHeciCmds.insert(mockSupportedHeciCmds.end(), {GfspHeciConstants::Cmd::getEccConfigurationCmd16, GfspHeciConstants::Cmd::setEccConfigurationCmd15});
mockEccCurrentState = 1;
mockEccPendingState = 1;
mockEccHeciCmd16Val = 1;
}
int mockDeviceIfrGetStatusExt(struct igsc_device_handle *handle, uint32_t *supportedTests, uint32_t *hwCapabilities, uint32_t *ifrApplied, uint32_t *prevErrors, uint32_t *pendingReset) { int mockDeviceIfrGetStatusExt(struct igsc_device_handle *handle, uint32_t *supportedTests, uint32_t *hwCapabilities, uint32_t *ifrApplied, uint32_t *prevErrors, uint32_t *pendingReset) {
return 0; return 0;
@ -32,19 +45,11 @@ int mockdeviceIfrRunMemPPRTest(struct igsc_device_handle *handle, uint32_t *stat
return 0; return 0;
} }
static inline int mockEccConfigGetSuccess(struct igsc_device_handle *handle, uint8_t *currentState, uint8_t *pendingState) { static inline int mockEccConfigGetSuccess(struct igsc_device_handle *handle, uint32_t gfspCmd, uint8_t *inBuffer, size_t inBufferSize, uint8_t *outBuffer, size_t outBufferSize, size_t *actualOutBufferSize) {
return 0; return 0;
} }
static inline int mockEccConfigSetSuccess(struct igsc_device_handle *handle, uint8_t newState, uint8_t *currentState, uint8_t *pendingState) { static inline int mockEccConfigGetFailure(struct igsc_device_handle *handle, uint32_t gfspCmd, uint8_t *inBuffer, size_t inBufferSize, uint8_t *outBuffer, size_t outBufferSize, size_t *actualOutBufferSize) {
return 0;
}
static inline int mockEccConfigGetFailure(struct igsc_device_handle *handle, uint8_t *currentState, uint8_t *pendingState) {
return -1;
}
static inline int mockEccConfigSetFailure(struct igsc_device_handle *handle, uint8_t newState, uint8_t *currentState, uint8_t *pendingState) {
return -1; return -1;
} }
@ -66,6 +71,71 @@ static inline int mockGetHealthIndicatorFailure(struct igsc_device_handle *handl
return -1; return -1;
} }
static int mockGetEccAvailable(struct igsc_device_handle *handle, uint32_t gfspCmd, uint8_t *inBuffer, size_t inBufferSize, uint8_t *outBuffer, size_t outBufferSize, size_t *actualOutBufferSize) {
if (std::find(mockSupportedHeciCmds.begin(), mockSupportedHeciCmds.end(), gfspCmd) == mockSupportedHeciCmds.end()) {
return IGSC_ERROR_NOT_SUPPORTED;
}
switch (gfspCmd) {
case GfspHeciConstants::Cmd::getEccConfigurationCmd16:
outBuffer[GfspHeciConstants::GetEccCmd16BytePostition::eccAvailable] = mockEccHeciCmd16Val;
return IGSC_SUCCESS;
case GfspHeciConstants::Cmd::getEccConfigurationCmd9:
outBuffer[GfspHeciConstants::GetEccCmd9BytePostition::currentState] = mockEccCurrentState;
outBuffer[GfspHeciConstants::GetEccCmd9BytePostition::pendingState] = mockEccPendingState;
return IGSC_SUCCESS;
default:
return IGSC_ERROR_NOT_SUPPORTED;
}
}
static int mockGetEccConfigurable(struct igsc_device_handle *handle, uint32_t gfspCmd, uint8_t *inBuffer, size_t inBufferSize, uint8_t *outBuffer, size_t outBufferSize, size_t *actualOutBufferSize) {
if (std::find(mockSupportedHeciCmds.begin(), mockSupportedHeciCmds.end(), gfspCmd) == mockSupportedHeciCmds.end()) {
return IGSC_ERROR_NOT_SUPPORTED;
}
switch (gfspCmd) {
case GfspHeciConstants::Cmd::getEccConfigurationCmd16:
outBuffer[GfspHeciConstants::GetEccCmd16BytePostition::eccConfigurable] = mockEccHeciCmd16Val;
return IGSC_SUCCESS;
case GfspHeciConstants::Cmd::getEccConfigurationCmd9:
outBuffer[GfspHeciConstants::GetEccCmd9BytePostition::currentState] = mockEccCurrentState;
outBuffer[GfspHeciConstants::GetEccCmd9BytePostition::pendingState] = mockEccPendingState;
return IGSC_SUCCESS;
default:
return IGSC_ERROR_NOT_SUPPORTED;
}
}
static int mockGetEccConfig(struct igsc_device_handle *handle, uint32_t gfspCmd, uint8_t *inBuffer, size_t inBufferSize, uint8_t *outBuffer, size_t outBufferSize, size_t *actualOutBufferSize) {
if (std::find(mockSupportedHeciCmds.begin(), mockSupportedHeciCmds.end(), gfspCmd) == mockSupportedHeciCmds.end()) {
return IGSC_ERROR_NOT_SUPPORTED;
}
switch (gfspCmd) {
case GfspHeciConstants::Cmd::getEccConfigurationCmd16:
outBuffer[GfspHeciConstants::GetEccCmd16BytePostition::eccCurrentState] = mockEccCurrentState;
outBuffer[GfspHeciConstants::GetEccCmd16BytePostition::eccPendingState] = mockEccPendingState;
return IGSC_SUCCESS;
case GfspHeciConstants::Cmd::getEccConfigurationCmd9:
outBuffer[GfspHeciConstants::GetEccCmd9BytePostition::currentState] = mockEccCurrentState;
outBuffer[GfspHeciConstants::GetEccCmd9BytePostition::pendingState] = mockEccPendingState;
return IGSC_SUCCESS;
case GfspHeciConstants::Cmd::setEccConfigurationCmd15:
outBuffer[GfspHeciConstants::SetEccCmd15BytePostition::response] = inBuffer[GfspHeciConstants::SetEccCmd15BytePostition::request];
return IGSC_SUCCESS;
case GfspHeciConstants::Cmd::setEccConfigurationCmd8:
outBuffer[GfspHeciConstants::SetEccCmd8BytePostition::responsePendingState] = inBuffer[GfspHeciConstants::SetEccCmd8BytePostition::setRequest];
outBuffer[GfspHeciConstants::SetEccCmd8BytePostition::responseCurrentState] = mockEccCurrentState;
return IGSC_SUCCESS;
default:
return IGSC_ERROR_NOT_SUPPORTED;
}
}
TEST(FwStatusExtTest, GivenIFRWasSetWhenFirmwareUtilChecksIFRThenIFRStatusIsUpdated) { TEST(FwStatusExtTest, GivenIFRWasSetWhenFirmwareUtilChecksIFRThenIFRStatusIsUpdated) {
VariableBackup<decltype(L0::Sysman::deviceIfrGetStatusExt)> mockDeviceIfrGetStatusExt(&L0::Sysman::deviceIfrGetStatusExt, [](struct igsc_device_handle *handle, uint32_t *supportedTests, uint32_t *hwCapabilities, uint32_t *ifrApplied, uint32_t *prevErrors, uint32_t *pendingReset) -> int { VariableBackup<decltype(L0::Sysman::deviceIfrGetStatusExt)> mockDeviceIfrGetStatusExt(&L0::Sysman::deviceIfrGetStatusExt, [](struct igsc_device_handle *handle, uint32_t *supportedTests, uint32_t *hwCapabilities, uint32_t *ifrApplied, uint32_t *prevErrors, uint32_t *pendingReset) -> int {
@ -169,8 +239,7 @@ TEST(FwEccTest, GivenFwEccConfigCallFailsWhenCallingFirmwareUtilSetAndGetEccThen
public: public:
~IgscEccMockOsLibrary() override = default; ~IgscEccMockOsLibrary() override = default;
void *getProcAddress(const std::string &procName) override { void *getProcAddress(const std::string &procName) override {
eccFuncMap["igsc_ecc_config_get"] = reinterpret_cast<void *>(&mockEccConfigGetFailure); eccFuncMap["igsc_gfsp_heci_cmd"] = reinterpret_cast<void *>(&mockEccConfigGetFailure);
eccFuncMap["igsc_ecc_config_set"] = reinterpret_cast<void *>(&mockEccConfigSetFailure);
auto it = eccFuncMap.find(procName); auto it = eccFuncMap.find(procName);
if (eccFuncMap.end() == it) { if (eccFuncMap.end() == it) {
return nullptr; return nullptr;
@ -211,8 +280,7 @@ TEST(LinuxFwEccTest, GivenValidFwUtilMethodWhenCallingFirmwareUtilSetAndGetEccTh
public: public:
~IgscEccMockOsLibrary() override = default; ~IgscEccMockOsLibrary() override = default;
void *getProcAddress(const std::string &procName) override { void *getProcAddress(const std::string &procName) override {
eccFuncMap["igsc_ecc_config_get"] = reinterpret_cast<void *>(&mockEccConfigGetSuccess); eccFuncMap["igsc_gfsp_heci_cmd"] = reinterpret_cast<void *>(&mockEccConfigGetSuccess);
eccFuncMap["igsc_ecc_config_set"] = reinterpret_cast<void *>(&mockEccConfigSetSuccess);
auto it = eccFuncMap.find(procName); auto it = eccFuncMap.find(procName);
if (eccFuncMap.end() == it) { if (eccFuncMap.end() == it) {
return nullptr; return nullptr;
@ -474,6 +542,356 @@ TEST(FwUtilImpProgressTest, GivenFirmwareUtilImpAndNullContextWhenSettingProgres
delete pFwUtilImp; delete pFwUtilImp;
} }
TEST(LinuxFwEccTest, GivenHeciCmd16IsSupportedThenWhenCallingFwGetEccAvailableSucessIsReturned) {
restoreEccMockVars();
L0::Sysman::FirmwareUtilImp *pFwUtilImp = new L0::Sysman::FirmwareUtilImp(0, 0, 0, 0);
MockFwUtilOsLibrary *osLibHandle = new MockFwUtilOsLibrary();
osLibHandle->funcMap["igsc_gfsp_heci_cmd"] = reinterpret_cast<void *>(&mockGetEccAvailable);
pFwUtilImp->libraryHandle = static_cast<OsLibrary *>(osLibHandle);
mockSupportedHeciCmds.clear();
mockSupportedHeciCmds.push_back(GfspHeciConstants::Cmd::getEccConfigurationCmd16);
ze_bool_t pAvailable;
std::vector<uint8_t> possibleEccStates = {0, 1};
for (auto iterEccAvailableStates : possibleEccStates) {
mockEccHeciCmd16Val = iterEccAvailableStates;
auto ret = pFwUtilImp->fwGetEccAvailable(&pAvailable);
EXPECT_EQ(pAvailable, mockEccHeciCmd16Val);
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
}
delete pFwUtilImp->libraryHandle;
pFwUtilImp->libraryHandle = nullptr;
delete pFwUtilImp;
}
TEST(LinuxFwEccTest, GivenHeciCmd16IsNotSupportedBut9IsSupportedThenWhenCallingFwGetEccAvailableSucessIsReturned) {
restoreEccMockVars();
L0::Sysman::FirmwareUtilImp *pFwUtilImp = new L0::Sysman::FirmwareUtilImp(0, 0, 0, 0);
MockFwUtilOsLibrary *osLibHandle = new MockFwUtilOsLibrary();
osLibHandle->funcMap["igsc_gfsp_heci_cmd"] = reinterpret_cast<void *>(&mockGetEccAvailable);
pFwUtilImp->libraryHandle = static_cast<OsLibrary *>(osLibHandle);
mockSupportedHeciCmds.clear();
mockSupportedHeciCmds.push_back(GfspHeciConstants::Cmd::getEccConfigurationCmd9);
ze_bool_t pAvailable;
auto ret = pFwUtilImp->fwGetEccAvailable(&pAvailable);
EXPECT_TRUE(pAvailable);
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
delete pFwUtilImp->libraryHandle;
pFwUtilImp->libraryHandle = nullptr;
delete pFwUtilImp;
}
TEST(LinuxFwEccTest, GivenHeciCmd16IsNotSupportedBut9IsSupportedAndEccStateIsNoneThenWhenCallingFwGetEccAvailableCorrectReturnValueIsReturned) {
restoreEccMockVars();
L0::Sysman::FirmwareUtilImp *pFwUtilImp = new L0::Sysman::FirmwareUtilImp(0, 0, 0, 0);
MockFwUtilOsLibrary *osLibHandle = new MockFwUtilOsLibrary();
osLibHandle->funcMap["igsc_gfsp_heci_cmd"] = reinterpret_cast<void *>(&mockGetEccAvailable);
pFwUtilImp->libraryHandle = static_cast<OsLibrary *>(osLibHandle);
ze_bool_t pAvailable;
mockSupportedHeciCmds.clear();
mockSupportedHeciCmds.push_back(GfspHeciConstants::Cmd::getEccConfigurationCmd9);
mockEccCurrentState = 0xff;
mockEccPendingState = 0x1;
auto ret = pFwUtilImp->fwGetEccAvailable(&pAvailable);
EXPECT_FALSE(pAvailable);
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
mockEccCurrentState = 0x1;
mockEccPendingState = 0xff;
ret = pFwUtilImp->fwGetEccAvailable(&pAvailable);
EXPECT_FALSE(pAvailable);
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
delete pFwUtilImp->libraryHandle;
pFwUtilImp->libraryHandle = nullptr;
delete pFwUtilImp;
}
TEST(LinuxFwEccTest, GivenHeciCmd9AndCmd16AreUnsupportedWhenCallingFwGetEccAvailableThenUninitializedIsReturned) {
restoreEccMockVars();
L0::Sysman::FirmwareUtilImp *pFwUtilImp = new L0::Sysman::FirmwareUtilImp(0, 0, 0, 0);
MockFwUtilOsLibrary *osLibHandle = new MockFwUtilOsLibrary();
osLibHandle->funcMap["igsc_gfsp_heci_cmd"] = reinterpret_cast<void *>(&mockGetEccConfigurable);
pFwUtilImp->libraryHandle = static_cast<OsLibrary *>(osLibHandle);
mockSupportedHeciCmds.clear();
mockSupportedHeciCmds.push_back(0xff);
ze_bool_t pAvailable;
auto ret = pFwUtilImp->fwGetEccAvailable(&pAvailable);
EXPECT_FALSE(pAvailable);
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, ret);
delete pFwUtilImp->libraryHandle;
pFwUtilImp->libraryHandle = nullptr;
delete pFwUtilImp;
}
TEST(LinuxFwEccTest, GivenHeciCmd16IsSupportedThenWhenCallingFwGetEccConfigurableSucessIsReturned) {
restoreEccMockVars();
L0::Sysman::FirmwareUtilImp *pFwUtilImp = new L0::Sysman::FirmwareUtilImp(0, 0, 0, 0);
MockFwUtilOsLibrary *osLibHandle = new MockFwUtilOsLibrary();
osLibHandle->funcMap["igsc_gfsp_heci_cmd"] = reinterpret_cast<void *>(&mockGetEccConfigurable);
pFwUtilImp->libraryHandle = static_cast<OsLibrary *>(osLibHandle);
mockSupportedHeciCmds.clear();
mockSupportedHeciCmds.push_back(GfspHeciConstants::Cmd::getEccConfigurationCmd16);
ze_bool_t pConfigurable;
std::vector<uint8_t> possibleEccStates = {0, 1};
for (auto iterEccConfigurableStates : possibleEccStates) {
mockEccHeciCmd16Val = iterEccConfigurableStates;
auto ret = pFwUtilImp->fwGetEccConfigurable(&pConfigurable);
EXPECT_EQ(pConfigurable, mockEccHeciCmd16Val);
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
}
delete pFwUtilImp->libraryHandle;
pFwUtilImp->libraryHandle = nullptr;
delete pFwUtilImp;
}
TEST(LinuxFwEccTest, GivenHeciCmd16IsNotSupportedBut9IsSupportedThenWhenCallingFwGetEccConfigurableSucessIsReturned) {
restoreEccMockVars();
L0::Sysman::FirmwareUtilImp *pFwUtilImp = new L0::Sysman::FirmwareUtilImp(0, 0, 0, 0);
MockFwUtilOsLibrary *osLibHandle = new MockFwUtilOsLibrary();
osLibHandle->funcMap["igsc_gfsp_heci_cmd"] = reinterpret_cast<void *>(&mockGetEccConfigurable);
pFwUtilImp->libraryHandle = static_cast<OsLibrary *>(osLibHandle);
mockSupportedHeciCmds.clear();
mockSupportedHeciCmds.push_back(GfspHeciConstants::Cmd::getEccConfigurationCmd9);
ze_bool_t pConfigurable;
auto ret = pFwUtilImp->fwGetEccConfigurable(&pConfigurable);
EXPECT_TRUE(pConfigurable);
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
delete pFwUtilImp->libraryHandle;
pFwUtilImp->libraryHandle = nullptr;
delete pFwUtilImp;
}
TEST(LinuxFwEccTest, GivenHeciCmd16IsNotSupportedBut9IsSupportedAndEccStateIsNoneThenWhenCallingFwGetEccConfigurableCorrectReturnValueIsReturned) {
restoreEccMockVars();
L0::Sysman::FirmwareUtilImp *pFwUtilImp = new L0::Sysman::FirmwareUtilImp(0, 0, 0, 0);
MockFwUtilOsLibrary *osLibHandle = new MockFwUtilOsLibrary();
osLibHandle->funcMap["igsc_gfsp_heci_cmd"] = reinterpret_cast<void *>(&mockGetEccConfigurable);
pFwUtilImp->libraryHandle = static_cast<OsLibrary *>(osLibHandle);
ze_bool_t pConfigurable;
mockSupportedHeciCmds.clear();
mockSupportedHeciCmds.push_back(GfspHeciConstants::Cmd::getEccConfigurationCmd9);
mockEccCurrentState = 0xff;
mockEccPendingState = 0x1;
auto ret = pFwUtilImp->fwGetEccConfigurable(&pConfigurable);
EXPECT_FALSE(pConfigurable);
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
mockEccCurrentState = 0x1;
mockEccPendingState = 0xff;
ret = pFwUtilImp->fwGetEccConfigurable(&pConfigurable);
EXPECT_FALSE(pConfigurable);
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
delete pFwUtilImp->libraryHandle;
pFwUtilImp->libraryHandle = nullptr;
delete pFwUtilImp;
}
TEST(LinuxFwEccTest, GivenHeciCmd9AndCmd16AreUnsupportedWhenCallingFwGetEccConfigurableThenUninitializedIsReturned) {
restoreEccMockVars();
L0::Sysman::FirmwareUtilImp *pFwUtilImp = new L0::Sysman::FirmwareUtilImp(0, 0, 0, 0);
MockFwUtilOsLibrary *osLibHandle = new MockFwUtilOsLibrary();
osLibHandle->funcMap["igsc_gfsp_heci_cmd"] = reinterpret_cast<void *>(&mockGetEccConfigurable);
pFwUtilImp->libraryHandle = static_cast<OsLibrary *>(osLibHandle);
mockSupportedHeciCmds.clear();
mockSupportedHeciCmds.push_back(0xff);
ze_bool_t pConfigurable;
auto ret = pFwUtilImp->fwGetEccConfigurable(&pConfigurable);
EXPECT_FALSE(pConfigurable);
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, ret);
delete pFwUtilImp->libraryHandle;
pFwUtilImp->libraryHandle = nullptr;
delete pFwUtilImp;
}
TEST(LinuxFwEccTest, GivenHeciCmd16IsSupportedThenWhenCallingFwGetEccConfigSucessIsReturned) {
restoreEccMockVars();
L0::Sysman::FirmwareUtilImp *pFwUtilImp = new L0::Sysman::FirmwareUtilImp(0, 0, 0, 0);
MockFwUtilOsLibrary *osLibHandle = new MockFwUtilOsLibrary();
osLibHandle->funcMap["igsc_gfsp_heci_cmd"] = reinterpret_cast<void *>(&mockGetEccConfig);
pFwUtilImp->libraryHandle = static_cast<OsLibrary *>(osLibHandle);
mockSupportedHeciCmds.clear();
mockSupportedHeciCmds.push_back(GfspHeciConstants::Cmd::getEccConfigurationCmd16);
mockEccCurrentState = 1;
mockEccPendingState = 1;
uint8_t currentState;
uint8_t pendingState;
auto ret = pFwUtilImp->fwGetEccConfig(&currentState, &pendingState);
EXPECT_EQ(currentState, mockEccCurrentState);
EXPECT_EQ(pendingState, mockEccPendingState);
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
delete pFwUtilImp->libraryHandle;
pFwUtilImp->libraryHandle = nullptr;
delete pFwUtilImp;
}
TEST(LinuxFwEccTest, GivenHeciCmd16IsNotSupportedBut9IsSupportedThenWhenCallingFwGetEccConfigSucessIsReturned) {
restoreEccMockVars();
L0::Sysman::FirmwareUtilImp *pFwUtilImp = new L0::Sysman::FirmwareUtilImp(0, 0, 0, 0);
MockFwUtilOsLibrary *osLibHandle = new MockFwUtilOsLibrary();
osLibHandle->funcMap["igsc_gfsp_heci_cmd"] = reinterpret_cast<void *>(&mockGetEccConfig);
pFwUtilImp->libraryHandle = static_cast<OsLibrary *>(osLibHandle);
mockSupportedHeciCmds.clear();
mockSupportedHeciCmds.push_back(GfspHeciConstants::Cmd::getEccConfigurationCmd9);
uint8_t currentState;
uint8_t pendingState;
std::vector<uint8_t> possibleEccStates = {0, 1, 0xff};
for (auto iterCurrentState : possibleEccStates) {
for (auto iterPendingState : possibleEccStates) {
mockEccCurrentState = iterCurrentState;
mockEccPendingState = iterPendingState;
auto ret = pFwUtilImp->fwGetEccConfig(&currentState, &pendingState);
EXPECT_EQ(currentState, mockEccCurrentState);
EXPECT_EQ(pendingState, mockEccPendingState);
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
}
}
delete pFwUtilImp->libraryHandle;
pFwUtilImp->libraryHandle = nullptr;
delete pFwUtilImp;
}
TEST(LinuxFwEccTest, GivenUnavailableHeciFunctionPointersWhenCallingEccMethodsThenFailureIsReturned) {
restoreEccMockVars();
L0::Sysman::FirmwareUtilImp *pFwUtilImp = new L0::Sysman::FirmwareUtilImp(0, 0, 0, 0);
MockFwUtilOsLibrary *osLibHandle = new MockFwUtilOsLibrary();
pFwUtilImp->libraryHandle = static_cast<OsLibrary *>(osLibHandle);
ze_bool_t pAvailable;
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, pFwUtilImp->fwGetEccAvailable(&pAvailable));
ze_bool_t pConfigurable;
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, pFwUtilImp->fwGetEccConfigurable(&pConfigurable));
uint8_t currentState;
uint8_t pendingState;
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, pFwUtilImp->fwGetEccConfig(&currentState, &pendingState));
uint8_t newState = 1;
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, pFwUtilImp->fwSetEccConfig(newState, &currentState, &pendingState));
delete pFwUtilImp->libraryHandle;
pFwUtilImp->libraryHandle = nullptr;
delete pFwUtilImp;
}
TEST(LinuxFwEccTest, GivenHeciCmd15IsSupportedThenWhenCallingFwSetEccConfigSucessIsReturned) {
restoreEccMockVars();
L0::Sysman::FirmwareUtilImp *pFwUtilImp = new L0::Sysman::FirmwareUtilImp(0, 0, 0, 0);
MockFwUtilOsLibrary *osLibHandle = new MockFwUtilOsLibrary();
osLibHandle->funcMap["igsc_gfsp_heci_cmd"] = reinterpret_cast<void *>(&mockGetEccConfig);
pFwUtilImp->libraryHandle = static_cast<OsLibrary *>(osLibHandle);
mockSupportedHeciCmds.clear();
mockSupportedHeciCmds.push_back(GfspHeciConstants::Cmd::getEccConfigurationCmd16);
mockSupportedHeciCmds.push_back(GfspHeciConstants::Cmd::setEccConfigurationCmd15);
mockEccCurrentState = 0;
uint8_t currentState;
uint8_t pendingState;
uint8_t newState = 1;
auto ret = pFwUtilImp->fwSetEccConfig(newState, &currentState, &pendingState);
EXPECT_EQ(currentState, mockEccCurrentState);
EXPECT_EQ(pendingState, newState);
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
delete pFwUtilImp->libraryHandle;
pFwUtilImp->libraryHandle = nullptr;
delete pFwUtilImp;
}
TEST(LinuxFwEccTest, GivenHeciCmd15IsSupportedThenWhenCallingFwSetEccConfigAndFwGetEccConfigFailsThenFailureReturned) {
restoreEccMockVars();
L0::Sysman::FirmwareUtilImp *pFwUtilImp = new L0::Sysman::FirmwareUtilImp(0, 0, 0, 0);
MockFwUtilOsLibrary *osLibHandle = new MockFwUtilOsLibrary();
osLibHandle->funcMap["igsc_gfsp_heci_cmd"] = reinterpret_cast<void *>(&mockGetEccConfig);
pFwUtilImp->libraryHandle = static_cast<OsLibrary *>(osLibHandle);
mockSupportedHeciCmds.clear();
mockSupportedHeciCmds.push_back(0xff);
mockSupportedHeciCmds.push_back(GfspHeciConstants::Cmd::setEccConfigurationCmd15);
mockEccCurrentState = 0;
uint8_t currentState;
uint8_t pendingState;
uint8_t newState = 1;
auto ret = pFwUtilImp->fwSetEccConfig(newState, &currentState, &pendingState);
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, ret);
delete pFwUtilImp->libraryHandle;
pFwUtilImp->libraryHandle = nullptr;
delete pFwUtilImp;
}
TEST(LinuxFwEccTest, GivenHeciSetCommandsAreNotSupportedThenWhenCallingFwSetEccConfigFailureReturned) {
restoreEccMockVars();
L0::Sysman::FirmwareUtilImp *pFwUtilImp = new L0::Sysman::FirmwareUtilImp(0, 0, 0, 0);
MockFwUtilOsLibrary *osLibHandle = new MockFwUtilOsLibrary();
osLibHandle->funcMap["igsc_gfsp_heci_cmd"] = reinterpret_cast<void *>(&mockGetEccConfig);
pFwUtilImp->libraryHandle = static_cast<OsLibrary *>(osLibHandle);
mockSupportedHeciCmds.clear();
mockSupportedHeciCmds.push_back(0xff);
mockEccCurrentState = 0;
uint8_t currentState;
uint8_t pendingState;
uint8_t newState = 1;
auto ret = pFwUtilImp->fwSetEccConfig(newState, &currentState, &pendingState);
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, ret);
delete pFwUtilImp->libraryHandle;
pFwUtilImp->libraryHandle = nullptr;
delete pFwUtilImp;
}
TEST(LinuxFwEccTest, GivenHeciCmd15IsNotSupportedButCmd8IsSupportedThenWhenCallingFwSetEccConfigSucessIsReturned) {
restoreEccMockVars();
L0::Sysman::FirmwareUtilImp *pFwUtilImp = new L0::Sysman::FirmwareUtilImp(0, 0, 0, 0);
MockFwUtilOsLibrary *osLibHandle = new MockFwUtilOsLibrary();
osLibHandle->funcMap["igsc_gfsp_heci_cmd"] = reinterpret_cast<void *>(&mockGetEccConfig);
pFwUtilImp->libraryHandle = static_cast<OsLibrary *>(osLibHandle);
mockSupportedHeciCmds.clear();
mockSupportedHeciCmds.push_back(GfspHeciConstants::Cmd::getEccConfigurationCmd9);
mockSupportedHeciCmds.push_back(GfspHeciConstants::Cmd::setEccConfigurationCmd8);
mockEccCurrentState = 0;
uint8_t currentState;
uint8_t pendingState;
uint8_t newState = 1;
auto ret = pFwUtilImp->fwSetEccConfig(newState, &currentState, &pendingState);
EXPECT_EQ(currentState, mockEccCurrentState);
EXPECT_EQ(pendingState, newState);
EXPECT_EQ(ZE_RESULT_SUCCESS, ret);
delete pFwUtilImp->libraryHandle;
pFwUtilImp->libraryHandle = nullptr;
delete pFwUtilImp;
}
} // namespace ult } // namespace ult
} // namespace Sysman } // namespace Sysman
} // namespace L0 } // namespace L0

View File

@ -603,6 +603,8 @@ struct MockGlobalOpsFwInterface : public L0::Sysman::FirmwareUtil {
ADDMETHOD_NOBASE(fwSupportedDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::vector<std::string> & supportedDiagTests)); ADDMETHOD_NOBASE(fwSupportedDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::vector<std::string> & supportedDiagTests));
ADDMETHOD_NOBASE(fwRunDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::string & osDiagType, zes_diag_result_t *pResult)); ADDMETHOD_NOBASE(fwRunDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::string & osDiagType, zes_diag_result_t *pResult));
ADDMETHOD_NOBASE(fwGetMemoryErrorCount, ze_result_t, ZE_RESULT_SUCCESS, (zes_ras_error_type_t category, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count)); ADDMETHOD_NOBASE(fwGetMemoryErrorCount, ze_result_t, ZE_RESULT_SUCCESS, (zes_ras_error_type_t category, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count));
ADDMETHOD_NOBASE(fwGetEccAvailable, ze_result_t, ZE_RESULT_SUCCESS, (ze_bool_t * pAvailable));
ADDMETHOD_NOBASE(fwGetEccConfigurable, ze_result_t, ZE_RESULT_SUCCESS, (ze_bool_t * pConfigurable));
ADDMETHOD_NOBASE(fwGetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t * currentState, uint8_t *pendingState)); ADDMETHOD_NOBASE(fwGetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t * currentState, uint8_t *pendingState));
ADDMETHOD_NOBASE(fwSetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t newState, uint8_t *currentState, uint8_t *pendingState)); ADDMETHOD_NOBASE(fwSetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t newState, uint8_t *currentState, uint8_t *pendingState));
ADDMETHOD_NOBASE_VOIDRETURN(getDeviceSupportedFwTypes, (std::vector<std::string> & fwTypes)); ADDMETHOD_NOBASE_VOIDRETURN(getDeviceSupportedFwTypes, (std::vector<std::string> & fwTypes));

View File

@ -667,6 +667,8 @@ struct MockRasFwInterface : public L0::Sysman::FirmwareUtil {
ADDMETHOD_NOBASE(fwSupportedDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::vector<std::string> & supportedDiagTests)); ADDMETHOD_NOBASE(fwSupportedDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::vector<std::string> & supportedDiagTests));
ADDMETHOD_NOBASE(fwRunDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::string & osDiagType, zes_diag_result_t *pResult)); ADDMETHOD_NOBASE(fwRunDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::string & osDiagType, zes_diag_result_t *pResult));
ADDMETHOD_NOBASE_VOIDRETURN(getDeviceSupportedFwTypes, (std::vector<std::string> & fwTypes)); ADDMETHOD_NOBASE_VOIDRETURN(getDeviceSupportedFwTypes, (std::vector<std::string> & fwTypes));
ADDMETHOD_NOBASE(fwGetEccAvailable, ze_result_t, ZE_RESULT_SUCCESS, (ze_bool_t * pAvailable));
ADDMETHOD_NOBASE(fwGetEccConfigurable, ze_result_t, ZE_RESULT_SUCCESS, (ze_bool_t * pConfigurable));
ADDMETHOD_NOBASE(fwGetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t * currentState, uint8_t *pendingState)); ADDMETHOD_NOBASE(fwGetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t * currentState, uint8_t *pendingState));
ADDMETHOD_NOBASE(fwSetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t newState, uint8_t *currentState, uint8_t *pendingState)); ADDMETHOD_NOBASE(fwSetEccConfig, ze_result_t, ZE_RESULT_SUCCESS, (uint8_t newState, uint8_t *currentState, uint8_t *pendingState));
ADDMETHOD_NOBASE_VOIDRETURN(fwGetMemoryHealthIndicator, (zes_mem_health_t * health)); ADDMETHOD_NOBASE_VOIDRETURN(fwGetMemoryHealthIndicator, (zes_mem_health_t * health));

View File

@ -21,6 +21,7 @@ if(UNIX)
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_init_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_init_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_engine_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_engine_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_engine_tests_xe.cpp ${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_engine_tests_xe.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sysman_product_helper_ecc_tests.cpp
) )
endif() endif()
add_subdirectories() add_subdirectories()

View File

@ -0,0 +1,182 @@
/*
* Copyright (C) 2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/driver_info.h"
#include "level_zero/sysman/source/shared/linux/product_helper/sysman_product_helper_hw.h"
#include "level_zero/sysman/test/unit_tests/sources/ecc/linux/mock_ecc.h"
namespace L0 {
namespace Sysman {
namespace ult {
using isDg2OrBmg = IsAnyProducts<IGFX_DG2, IGFX_BMG>;
class ZesEccFixture : public SysmanDeviceFixture {
protected:
L0::Sysman::SysmanDevice *device = nullptr;
std::unique_ptr<MockEccFwInterface> pMockFwInterface;
L0::Sysman::FirmwareUtil *pFwUtilInterfaceOld = nullptr;
L0::Sysman::EccImp *pEccImp;
void SetUp() override {
SysmanDeviceFixture::SetUp();
device = pSysmanDevice;
pFwUtilInterfaceOld = pLinuxSysmanImp->pFwUtilInterface;
pMockFwInterface = std::make_unique<MockEccFwInterface>();
pLinuxSysmanImp->pFwUtilInterface = pMockFwInterface.get();
pEccImp = static_cast<L0::Sysman::EccImp *>(pSysmanDeviceImp->pEcc);
}
void TearDown() override {
pEccImp = nullptr;
pLinuxSysmanImp->pFwUtilInterface = pFwUtilInterfaceOld;
SysmanDeviceFixture::TearDown();
}
};
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndFwInterfaceIsPresentWhenCallingzesDeviceEccAvailableTwiceThenVerifyApiCallSucceeds, isDg2OrBmg) {
ze_bool_t eccAvailable = false;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccAvailable(device, &eccAvailable));
EXPECT_EQ(true, eccAvailable);
eccAvailable = false;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccAvailable(device, &eccAvailable));
EXPECT_EQ(true, eccAvailable);
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndFwInterfaceIsPresentWhenCallingzesDeviceEccConfigurableTwiceThenVerifyApiCallSucceeds, isDg2OrBmg) {
ze_bool_t eccConfigurable = false;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccConfigurable(device, &eccConfigurable));
EXPECT_EQ(true, eccConfigurable);
eccConfigurable = false;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccConfigurable(device, &eccConfigurable));
EXPECT_EQ(true, eccConfigurable);
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndFwInterfaceIsAbsentWhenCallingEccApiThenVerifyApiCallReturnFailure, isDg2OrBmg) {
ze_bool_t eccConfigurable = true;
ze_bool_t eccAvailable = true;
L0::Sysman::EccImp *tempEccImp = new L0::Sysman::EccImp(pOsSysman);
pLinuxSysmanImp->pFwUtilInterface = nullptr;
tempEccImp->init();
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, tempEccImp->deviceEccAvailable(&eccAvailable));
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, tempEccImp->deviceEccConfigurable(&eccConfigurable));
zes_device_ecc_desc_t newState = {};
zes_device_ecc_properties_t props = {};
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, tempEccImp->setEccState(&newState, &props));
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, tempEccImp->getEccState(&props));
delete tempEccImp;
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndFwGetEccConfigFailsWhenCallingzesDeviceEccConfigurableAndAvailableThenVerifyApiCallReturnsFailure, isDg2OrBmg) {
ze_bool_t eccConfigurable = true;
ze_bool_t eccAvailable = true;
pMockFwInterface->mockFwGetEccAvailableResult = ZE_RESULT_ERROR_UNINITIALIZED;
pMockFwInterface->mockFwGetEccConfigurableResult = ZE_RESULT_ERROR_UNINITIALIZED;
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, zesDeviceEccAvailable(device, &eccAvailable));
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, zesDeviceEccConfigurable(device, &eccConfigurable));
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndCurrentStateIsNoneWhenCallingzesDeviceEccConfigurableAndAvailableThenNotSupportedEccIsReturned, isDg2OrBmg) {
ze_bool_t eccConfigurable = true;
ze_bool_t eccAvailable = true;
pMockFwInterface->mockEccAvailable = false;
pMockFwInterface->mockEccConfigurable = false;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccAvailable(device, &eccAvailable));
EXPECT_EQ(false, eccAvailable);
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceEccConfigurable(device, &eccConfigurable));
EXPECT_EQ(false, eccConfigurable);
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndFwInterfaceIsPresentWhenCallingzesDeviceGetEccStateThenApiCallSucceeds, isDg2OrBmg) {
zes_device_ecc_properties_t props = {};
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetEccState(device, &props));
EXPECT_EQ(ZES_DEVICE_ECC_STATE_DISABLED, props.currentState);
EXPECT_EQ(ZES_DEVICE_ECC_STATE_DISABLED, props.pendingState);
EXPECT_EQ(ZES_DEVICE_ACTION_NONE, props.pendingAction);
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndFwGetEccConfigFailsWhenCallingzesDeviceGetEccStateThenApiCallReturnFailure, isDg2OrBmg) {
zes_device_ecc_properties_t props = {};
pMockFwInterface->mockFwGetEccConfigResult = ZE_RESULT_ERROR_UNINITIALIZED;
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, zesDeviceGetEccState(device, &props));
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndFwInterfaceIsPresentWhenCallingzesDeviceSetEccStateThenApiCallSucceeds, isDg2OrBmg) {
zes_device_ecc_desc_t newState = {ZES_STRUCTURE_TYPE_DEVICE_STATE, nullptr, ZES_DEVICE_ECC_STATE_ENABLED};
zes_device_ecc_properties_t props = {};
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceSetEccState(device, &newState, &props));
newState.state = ZES_DEVICE_ECC_STATE_DISABLED;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceSetEccState(device, &newState, &props));
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndFwInterfaceIsPresentWhenCallingzesDeviceSetEccStateWithInvalidEnumThenFailureIsReturned, isDg2OrBmg) {
zes_device_ecc_desc_t newState = {ZES_STRUCTURE_TYPE_DEVICE_STATE, nullptr, ZES_DEVICE_ECC_STATE_UNAVAILABLE};
zes_device_ecc_properties_t props = {};
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ENUMERATION, zesDeviceSetEccState(device, &newState, &props));
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleAndFwSetEccConfigFailsWhenCallingzesDeviceSetEccStateThenFailureIsReturned, isDg2OrBmg) {
zes_device_ecc_desc_t newState = {ZES_STRUCTURE_TYPE_DEVICE_STATE, nullptr, ZES_DEVICE_ECC_STATE_ENABLED};
zes_device_ecc_properties_t props = {};
pMockFwInterface->mockFwSetEccConfigResult = ZE_RESULT_ERROR_UNINITIALIZED;
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, zesDeviceSetEccState(device, &newState, &props));
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleWhenCallingEccSetStateAndEccGetStateThenVerifyApiCallSuccedsAndValidStatesAreReturned, isDg2OrBmg) {
zes_device_ecc_desc_t newState = {ZES_STRUCTURE_TYPE_DEVICE_STATE, nullptr, ZES_DEVICE_ECC_STATE_ENABLED};
zes_device_ecc_properties_t props = {};
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceSetEccState(device, &newState, &props));
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetEccState(device, &props));
EXPECT_EQ(ZES_DEVICE_ECC_STATE_ENABLED, props.pendingState);
newState.state = ZES_DEVICE_ECC_STATE_DISABLED;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceSetEccState(device, &newState, &props));
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetEccState(device, &props));
EXPECT_EQ(ZES_DEVICE_ECC_STATE_DISABLED, props.pendingState);
pMockFwInterface->mockSetConfig = false;
pMockFwInterface->mockCurrentState = eccStateNone;
pMockFwInterface->mockPendingState = eccStateNone;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceSetEccState(device, &newState, &props));
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetEccState(device, &props));
EXPECT_EQ(ZES_DEVICE_ECC_STATE_UNAVAILABLE, props.pendingState);
EXPECT_EQ(ZES_DEVICE_ECC_STATE_UNAVAILABLE, props.currentState);
}
HWTEST2_F(ZesEccFixture, GivenValidSysmanHandleWhenCallingEccSetStateAndEccGetStateThenVerifyApiCallSuccedsAndValidActionIsReturned, isDg2OrBmg) {
zes_device_ecc_desc_t newState = {ZES_STRUCTURE_TYPE_DEVICE_STATE, nullptr, ZES_DEVICE_ECC_STATE_ENABLED};
zes_device_ecc_properties_t props = {};
pMockFwInterface->mockCurrentState = eccStateEnable;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceSetEccState(device, &newState, &props));
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetEccState(device, &props));
EXPECT_EQ(ZES_DEVICE_ECC_STATE_ENABLED, props.pendingState);
EXPECT_EQ(ZES_DEVICE_ACTION_NONE, props.pendingAction);
newState.state = ZES_DEVICE_ECC_STATE_DISABLED;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceSetEccState(device, &newState, &props));
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetEccState(device, &props));
EXPECT_EQ(ZES_DEVICE_ECC_STATE_DISABLED, props.pendingState);
EXPECT_EQ(ZES_DEVICE_ACTION_WARM_CARD_RESET, props.pendingAction);
}
} // namespace ult
} // namespace Sysman
} // namespace L0