From 82eacc88bfe7278837b94f7f5b2a5d93144118a4 Mon Sep 17 00:00:00 2001 From: Jitendra Sharma Date: Sat, 21 Sep 2024 22:22:17 +0000 Subject: [PATCH] refactor: Move all constants in sysman namespace - Use inline constexpr for declaring global variables - Avoid using Macros - Use string_view type instead of std::string Signed-off-by: Jitendra Sharma --- .../firmware/linux/sysman_os_firmware_imp.cpp | 2 +- .../windows/sysman_os_firmware_imp.cpp | 2 +- .../linux/sysman_os_global_operations_imp.cpp | 12 +-- .../sysman_global_operations_imp.cpp | 4 +- .../api/pci/linux/sysman_os_pci_imp.cpp | 12 +-- .../sysman_kmd_interface_i915_prelim.cpp | 2 +- .../sysman_kmd_interface_i915_upstream.cpp | 2 +- .../kmd_interface/sysman_kmd_interface_xe.cpp | 2 +- .../bmg/sysman_product_helper_bmg.cpp | 12 +-- .../bmg/sysman_product_helper_bmg.cpp | 14 ++- level_zero/sysman/source/sysman_const.h | 98 ++++++++++--------- .../sysman_product_helper_memory_tests.cpp | 6 +- .../sysman_product_helper_pci_tests.cpp | 8 +- 13 files changed, 91 insertions(+), 85 deletions(-) diff --git a/level_zero/sysman/source/api/firmware/linux/sysman_os_firmware_imp.cpp b/level_zero/sysman/source/api/firmware/linux/sysman_os_firmware_imp.cpp index f7649d35a1..bfc3231062 100644 --- a/level_zero/sysman/source/api/firmware/linux/sysman_os_firmware_imp.cpp +++ b/level_zero/sysman/source/api/firmware/linux/sysman_os_firmware_imp.cpp @@ -56,7 +56,7 @@ void OsFirmware::getSupportedFwTypes(std::vector &supportedFwTypes, void LinuxFirmwareImp::osGetFwProperties(zes_firmware_properties_t *pProperties) { if (ZE_RESULT_SUCCESS != getFirmwareVersion(osFwType, pProperties)) { - strncpy_s(static_cast(pProperties->version), ZES_STRING_PROPERTY_SIZE, unknown.c_str(), ZES_STRING_PROPERTY_SIZE - 1); + strncpy_s(static_cast(pProperties->version), ZES_STRING_PROPERTY_SIZE, unknown.data(), ZES_STRING_PROPERTY_SIZE - 1); } pProperties->canControl = true; // Assuming that user has permission to flash the firmware } diff --git a/level_zero/sysman/source/api/firmware/windows/sysman_os_firmware_imp.cpp b/level_zero/sysman/source/api/firmware/windows/sysman_os_firmware_imp.cpp index 095327cea6..7a0355b0bf 100644 --- a/level_zero/sysman/source/api/firmware/windows/sysman_os_firmware_imp.cpp +++ b/level_zero/sysman/source/api/firmware/windows/sysman_os_firmware_imp.cpp @@ -27,7 +27,7 @@ ze_result_t WddmFirmwareImp::getFirmwareVersion(std::string fwType, zes_firmware void WddmFirmwareImp::osGetFwProperties(zes_firmware_properties_t *pProperties) { if (ZE_RESULT_SUCCESS != getFirmwareVersion(osFwType, pProperties)) { - strncpy_s(static_cast(pProperties->version), ZES_STRING_PROPERTY_SIZE, unknown.c_str(), ZES_STRING_PROPERTY_SIZE); + strncpy_s(static_cast(pProperties->version), ZES_STRING_PROPERTY_SIZE, unknown.data(), ZES_STRING_PROPERTY_SIZE); } pProperties->canControl = true; // Assuming that user has permission to flash the firmware } diff --git a/level_zero/sysman/source/api/global_operations/linux/sysman_os_global_operations_imp.cpp b/level_zero/sysman/source/api/global_operations/linux/sysman_os_global_operations_imp.cpp index 62770edde0..c93c6475e1 100644 --- a/level_zero/sysman/source/api/global_operations/linux/sysman_os_global_operations_imp.cpp +++ b/level_zero/sysman/source/api/global_operations/linux/sysman_os_global_operations_imp.cpp @@ -119,13 +119,13 @@ void LinuxGlobalOperationsImp::getBrandName(char (&brandName)[ZES_STRING_PROPERT std::string strVal; ze_result_t result = pSysfsAccess->read(subsystemVendorFile, strVal); if (ZE_RESULT_SUCCESS != result) { - std::strncpy(brandName, unknown.c_str(), ZES_STRING_PROPERTY_SIZE); + std::strncpy(brandName, unknown.data(), ZES_STRING_PROPERTY_SIZE); return; } if (strVal.compare(intelPciId) == 0) { - std::strncpy(brandName, vendorIntel.c_str(), ZES_STRING_PROPERTY_SIZE); + std::strncpy(brandName, vendorIntel.data(), ZES_STRING_PROPERTY_SIZE); } else { - std::strncpy(brandName, unknown.c_str(), ZES_STRING_PROPERTY_SIZE); + std::strncpy(brandName, unknown.data(), ZES_STRING_PROPERTY_SIZE); } } @@ -147,13 +147,13 @@ void LinuxGlobalOperationsImp::getVendorName(char (&vendorName)[ZES_STRING_PROPE std::string strVal; ze_result_t result = pSysfsAccess->read(vendorFile, strVal); if (ZE_RESULT_SUCCESS != result) { - std::strncpy(vendorName, unknown.c_str(), ZES_STRING_PROPERTY_SIZE); + std::strncpy(vendorName, unknown.data(), ZES_STRING_PROPERTY_SIZE); return; } if (strVal.compare(intelPciId) == 0) { - std::strncpy(vendorName, vendorIntel.c_str(), ZES_STRING_PROPERTY_SIZE); + std::strncpy(vendorName, vendorIntel.data(), ZES_STRING_PROPERTY_SIZE); } else { - std::strncpy(vendorName, unknown.c_str(), ZES_STRING_PROPERTY_SIZE); + std::strncpy(vendorName, unknown.data(), ZES_STRING_PROPERTY_SIZE); } } diff --git a/level_zero/sysman/source/api/global_operations/sysman_global_operations_imp.cpp b/level_zero/sysman/source/api/global_operations/sysman_global_operations_imp.cpp index 7f537ca3ed..3bb7df38e4 100644 --- a/level_zero/sysman/source/api/global_operations/sysman_global_operations_imp.cpp +++ b/level_zero/sysman/source/api/global_operations/sysman_global_operations_imp.cpp @@ -118,11 +118,11 @@ ze_result_t GlobalOperationsImp::deviceGetProperties(zes_device_properties_t *pP pOsGlobalOperations->getBrandName(pProperties->brandName); memset(pProperties->boardNumber, 0, ZES_STRING_PROPERTY_SIZE); if (!pOsGlobalOperations->getBoardNumber(pProperties->boardNumber)) { - memcpy_s(pProperties->boardNumber, ZES_STRING_PROPERTY_SIZE, unknown.c_str(), unknown.length() + 1); + memcpy_s(pProperties->boardNumber, ZES_STRING_PROPERTY_SIZE, unknown.data(), unknown.length() + 1); } memset(pProperties->serialNumber, 0, ZES_STRING_PROPERTY_SIZE); if (!pOsGlobalOperations->getSerialNumber(pProperties->serialNumber)) { - memcpy_s(pProperties->serialNumber, ZES_STRING_PROPERTY_SIZE, unknown.c_str(), unknown.length() + 1); + memcpy_s(pProperties->serialNumber, ZES_STRING_PROPERTY_SIZE, unknown.data(), unknown.length() + 1); } return ZE_RESULT_SUCCESS; diff --git a/level_zero/sysman/source/api/pci/linux/sysman_os_pci_imp.cpp b/level_zero/sysman/source/api/pci/linux/sysman_os_pci_imp.cpp index ef264b4882..dc0a07da80 100644 --- a/level_zero/sysman/source/api/pci/linux/sysman_os_pci_imp.cpp +++ b/level_zero/sysman/source/api/pci/linux/sysman_os_pci_imp.cpp @@ -81,8 +81,8 @@ void LinuxPciImp::getMaxLinkCaps(double &maxLinkSpeed, int32_t &maxLinkWidth) { } uint16_t linkCaps = L0::Sysman::PciUtil::getWordFromConfig(linkCapPos, configMemory.data()); - maxLinkSpeed = convertPciGenToLinkSpeed(BITS(linkCaps, 0, 4)); - maxLinkWidth = BITS(linkCaps, 4, 6); + maxLinkSpeed = convertPciGenToLinkSpeed(bits(linkCaps, 0, 4)); + maxLinkWidth = bits(linkCaps, 4, 6); return; } @@ -189,7 +189,7 @@ uint16_t LinuxPciImp::getLinkCapabilityPos(uint8_t *configMem) { id = L0::Sysman::PciUtil::getByteFromConfig(pos + PCI_CAP_LIST_ID, configMem); if (id == PCI_CAP_ID_EXP) { capRegister = L0::Sysman::PciUtil::getWordFromConfig(pos + PCI_CAP_FLAGS, configMem); - type = BITS(capRegister, 4, 4); + type = bits(capRegister, 4, 4); // Root Complex Integrated end point and // Root Complex Event collector will not implement link capabilities @@ -258,11 +258,11 @@ bool LinuxPciImp::resizableBarEnabled(uint32_t barIndex) { // Only first Control register(at offset 008h, as shown above), could tell about number of resizable Bars controlRegister = L0::Sysman::PciUtil::getDwordFromConfig(rebarCapabilityPos + PCI_REBAR_CTRL, configMemory.data()); - nBars = BITS(controlRegister, 5, 3); // control register's bits 5,6 and 7 contain number of resizable bars information + nBars = bits(controlRegister, 5, 3); // control register's bits 5,6 and 7 contain number of resizable bars information for (auto barNumber = 0u; barNumber < nBars; barNumber++) { uint32_t barId = 0; controlRegister = L0::Sysman::PciUtil::getDwordFromConfig(rebarCapabilityPos + PCI_REBAR_CTRL, configMemory.data()); - barId = BITS(controlRegister, 0, 3); // Control register's bit 0,1,2 tells the index of bar + barId = bits(controlRegister, 0, 3); // Control register's bit 0,1,2 tells the index of bar if (barId == barIndex) { isBarResizable = true; break; @@ -286,7 +286,7 @@ bool LinuxPciImp::resizableBarEnabled(uint32_t barIndex) { // Control register's bit 8 to 13 indicates current BAR size in encoded form. // Example, real value of current size could be 2^currentSize MB - auto currentSize = BITS(controlRegister, 8, 6); + auto currentSize = bits(controlRegister, 8, 6); // If current size is equal to larget possible BAR size, it indicates resizable BAR is enabled. return (currentSize == largestPossibleBarSize); diff --git a/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface_i915_prelim.cpp b/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface_i915_prelim.cpp index ffe249174b..b4d11c646c 100644 --- a/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface_i915_prelim.cpp +++ b/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface_i915_prelim.cpp @@ -166,7 +166,7 @@ void SysmanKmdInterfaceI915Prelim::getDriverVersion(char (&driverVersion)[ZES_ST ze_result_t result = pFsAccess->read(agamaVersionFile, strVal); if (ZE_RESULT_SUCCESS != result) { NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed to read driver version from %s and returning error:0x%x \n", __FUNCTION__, agamaVersionFile.c_str(), result); - std::strncpy(driverVersion, unknown.c_str(), ZES_STRING_PROPERTY_SIZE); + std::strncpy(driverVersion, unknown.data(), ZES_STRING_PROPERTY_SIZE); } else { std::strncpy(driverVersion, strVal.c_str(), ZES_STRING_PROPERTY_SIZE); } diff --git a/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface_i915_upstream.cpp b/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface_i915_upstream.cpp index 406de8eb70..3d842bc193 100644 --- a/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface_i915_upstream.cpp +++ b/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface_i915_upstream.cpp @@ -133,7 +133,7 @@ void SysmanKmdInterfaceI915Upstream::getDriverVersion(char (&driverVersion)[ZES_ ze_result_t result = pFsAccess->read(srcVersionFile, strVal); if (ZE_RESULT_SUCCESS != result) { NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed to read driver version from %s and returning error:0x%x\n", __FUNCTION__, srcVersionFile.c_str(), result); - std::strncpy(driverVersion, unknown.c_str(), ZES_STRING_PROPERTY_SIZE); + std::strncpy(driverVersion, unknown.data(), ZES_STRING_PROPERTY_SIZE); } else { std::strncpy(driverVersion, strVal.c_str(), ZES_STRING_PROPERTY_SIZE); } diff --git a/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface_xe.cpp b/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface_xe.cpp index c13160fa0f..73b7485fb2 100644 --- a/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface_xe.cpp +++ b/level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface_xe.cpp @@ -140,7 +140,7 @@ void SysmanKmdInterfaceXe::getDriverVersion(char (&driverVersion)[ZES_STRING_PRO ze_result_t result = pFsAccess->read(srcVersionFile, strVal); if (ZE_RESULT_SUCCESS != result) { NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed to read driver version from %s and returning error:0x%x\n", __FUNCTION__, srcVersionFile.c_str(), result); - std::strncpy(driverVersion, unknown.c_str(), ZES_STRING_PROPERTY_SIZE); + std::strncpy(driverVersion, unknown.data(), ZES_STRING_PROPERTY_SIZE); } else { std::strncpy(driverVersion, strVal.c_str(), ZES_STRING_PROPERTY_SIZE); } diff --git a/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/bmg/sysman_product_helper_bmg.cpp b/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/bmg/sysman_product_helper_bmg.cpp index feab9d44b4..b8007a2771 100644 --- a/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/bmg/sysman_product_helper_bmg.cpp +++ b/level_zero/sysman/source/shared/linux/product_helper/xe2_hpg_core/bmg/sysman_product_helper_bmg.cpp @@ -305,7 +305,7 @@ static ze_result_t getPciStatsValues(zes_pci_stats_t *pStats, std::mapspeed.gen = -1; pStats->speed.width = -1; @@ -493,7 +493,7 @@ static ze_result_t getMemoryBandwidthTimestamp(const std::maptimestamp = PACK_INTO_64BIT(timeStampH, timeStampL); + pBandwidth->timestamp = packInto64Bit(timeStampH, timeStampL); return ZE_RESULT_SUCCESS; } @@ -514,7 +514,7 @@ static ze_result_t getCounterValues(const std::vector(valueH) << 32) | static_cast(valueL)) - constexpr static auto gfxProduct = IGFX_BMG; static std::map> guidToKeyOffsetMap = { @@ -396,7 +394,7 @@ ze_result_t SysmanProductHelperHw::getPciStats(zes_pci_stats_t *pSta "readValue call failed for register key rx_byte_count_msb\n"); return status; } - pStats->rxCounter = PACK_INTO_64BIT(rxCounterH, rxCounterL); + pStats->rxCounter = packInto64Bit(rxCounterH, rxCounterL); // tx counter calculation uint32_t txCounterL = 0; @@ -414,7 +412,7 @@ ze_result_t SysmanProductHelperHw::getPciStats(zes_pci_stats_t *pSta "readValue call failed for register key tx_byte_count_msb\n"); return status; } - pStats->txCounter = PACK_INTO_64BIT(txCounterH, txCounterL); + pStats->txCounter = packInto64Bit(txCounterH, txCounterL); // packet counter calculation uint32_t rxPacketCounterL = 0; @@ -449,7 +447,7 @@ ze_result_t SysmanProductHelperHw::getPciStats(zes_pci_stats_t *pSta return status; } - pStats->packetCounter = PACK_INTO_64BIT(txPacketCounterH, txPacketCounterL) + PACK_INTO_64BIT(rxPacketCounterH, rxPacketCounterL); + pStats->packetCounter = packInto64Bit(txPacketCounterH, txPacketCounterL) + packInto64Bit(rxPacketCounterH, rxPacketCounterL); pStats->timestamp = SysmanDevice::getSysmanTimestamp(); return status; @@ -524,7 +522,7 @@ ze_result_t SysmanProductHelperHw::getMemoryBandWidth(zes_mem_bandwi return status; } - uint64_t readCounter = PACK_INTO_64BIT(readRegisterH, readRegisterL); + uint64_t readCounter = packInto64Bit(readRegisterH, readRegisterL); pBandwidth->readCounter += readCounter; } @@ -546,7 +544,7 @@ ze_result_t SysmanProductHelperHw::getMemoryBandWidth(zes_mem_bandwi return status; } - uint64_t writeCounter = PACK_INTO_64BIT(writeRegisterH, writeRegisterL); + uint64_t writeCounter = packInto64Bit(writeRegisterH, writeRegisterL); pBandwidth->writeCounter += writeCounter; } @@ -581,7 +579,7 @@ ze_result_t SysmanProductHelperHw::getMemoryBandWidth(zes_mem_bandwi return status; } - pBandwidth->timestamp = PACK_INTO_64BIT(timeStampH, timeStampL); + pBandwidth->timestamp = packInto64Bit(timeStampH, timeStampL); return status; } diff --git a/level_zero/sysman/source/sysman_const.h b/level_zero/sysman/source/sysman_const.h index 53ffd0776f..8a39648877 100644 --- a/level_zero/sysman/source/sysman_const.h +++ b/level_zero/sysman/source/sysman_const.h @@ -10,29 +10,31 @@ #include #include -#include -const std::string vendorIntel("Intel(R) Corporation"); -const std::string unknown("unknown"); -const std::string intelPciId("0x8086"); -const std::string guid64BitMemoryCounters("0xb15a0ede"); -constexpr uint32_t mbpsToBytesPerSecond = 125000; -constexpr double milliVoltsFactor = 1000.0; -constexpr uint32_t maxRasErrorCategoryCount = 7; -constexpr uint32_t maxRasErrorCategoryExpCount = 10; - -constexpr double maxPerformanceFactor = 100; -constexpr double halfOfMaxPerformanceFactor = 50; -constexpr double minPerformanceFactor = 0; - -constexpr uint32_t numSocTemperatureEntries = 7; // entries would be PCH or GT_TEMP, DRAM, SA, PSF, DE, PCIE, TYPEC -constexpr uint32_t numCoreTemperatureEntries = 4; // entries would be CORE0, CORE1, CORE2, CORE3 -constexpr uint32_t numComputeTemperatureEntries = 3; // entries would be IA, GT and LLC -constexpr uint32_t invalidMaxTemperature = 125; -constexpr uint32_t invalidMinTemperature = 10; -constexpr uint32_t vendorIdIntel = 0x8086; +#include namespace L0 { namespace Sysman { + +inline constexpr std::string_view vendorIntel("Intel(R) Corporation"); +inline constexpr std::string_view unknown("unknown"); +inline constexpr std::string_view intelPciId("0x8086"); +inline constexpr std::string_view guid64BitMemoryCounters("0xb15a0ede"); +inline constexpr uint32_t mbpsToBytesPerSecond = 125000; +inline constexpr double milliVoltsFactor = 1000.0; +inline constexpr uint32_t maxRasErrorCategoryCount = 7; +inline constexpr uint32_t maxRasErrorCategoryExpCount = 10; + +inline constexpr double maxPerformanceFactor = 100; +inline constexpr double halfOfMaxPerformanceFactor = 50; +inline constexpr double minPerformanceFactor = 0; + +inline constexpr uint32_t numSocTemperatureEntries = 7; // entries would be PCH or GT_TEMP, DRAM, SA, PSF, DE, PCIE, TYPEC +inline constexpr uint32_t numCoreTemperatureEntries = 4; // entries would be CORE0, CORE1, CORE2, CORE3 +inline constexpr uint32_t numComputeTemperatureEntries = 3; // entries would be IA, GT and LLC +inline constexpr uint32_t invalidMaxTemperature = 125; +inline constexpr uint32_t invalidMinTemperature = 10; +inline constexpr uint32_t vendorIdIntel = 0x8086; + struct SteadyClock { typedef std::chrono::duration duration; typedef duration::rep rep; @@ -44,15 +46,12 @@ struct SteadyClock { } }; -} // namespace Sysman -} // namespace L0 - namespace PciLinkSpeeds { -constexpr double pci2Dot5GigaTransfersPerSecond = 2.5; -constexpr double pci5GigaTransfersPerSecond = 5.0; -constexpr double pci8GigaTransfersPerSecond = 8.0; -constexpr double pci16GigaTransfersPerSecond = 16.0; -constexpr double pci32GigaTransfersPerSecond = 32.0; +inline constexpr double pci2Dot5GigaTransfersPerSecond = 2.5; +inline constexpr double pci5GigaTransfersPerSecond = 5.0; +inline constexpr double pci8GigaTransfersPerSecond = 8.0; +inline constexpr double pci16GigaTransfersPerSecond = 16.0; +inline constexpr double pci32GigaTransfersPerSecond = 32.0; } // namespace PciLinkSpeeds enum PciGenerations { @@ -63,30 +62,39 @@ enum PciGenerations { PciGen5, }; -constexpr uint8_t maxPciBars = 6; +inline constexpr uint8_t maxPciBars = 6; // Linux kernel would report 255 link width, as an indication of unknown. -constexpr uint32_t unknownPcieLinkWidth = 255u; +inline constexpr uint32_t unknownPcieLinkWidth = 255u; -constexpr uint32_t microSecondsToNanoSeconds = 1000u; +inline constexpr uint32_t microSecondsToNanoSeconds = 1000u; -constexpr uint64_t convertJouleToMicroJoule = 1000000u; -constexpr uint64_t minTimeoutModeHeartbeat = 5000u; -constexpr uint64_t minTimeoutInMicroSeconds = 1000u; -constexpr uint16_t milliSecsToMicroSecs = 1000; -constexpr uint32_t milliFactor = 1000u; -constexpr uint32_t microFactor = milliFactor * milliFactor; -constexpr uint64_t gigaUnitTransferToUnitTransfer = 1000 * 1000 * 1000; -constexpr uint64_t megaBytesToBytes = 1000 * 1000; +inline constexpr uint64_t convertJouleToMicroJoule = 1000000u; +inline constexpr uint64_t minTimeoutModeHeartbeat = 5000u; +inline constexpr uint64_t minTimeoutInMicroSeconds = 1000u; +inline constexpr uint16_t milliSecsToMicroSecs = 1000; +inline constexpr uint32_t milliFactor = 1000u; +inline constexpr uint32_t microFactor = milliFactor * milliFactor; +inline constexpr uint64_t gigaUnitTransferToUnitTransfer = 1000 * 1000 * 1000; +inline constexpr uint64_t megaBytesToBytes = 1000 * 1000; -constexpr int32_t memoryBusWidth = 128; // bus width in bytes -constexpr int32_t numMemoryChannels = 8; -constexpr uint32_t unknownMemoryType = UINT32_MAX; -#define BITS(x, at, width) (((x) >> (at)) & ((1 << (width)) - 1)) -#define PACK_INTO_64BIT(msb, lsb) ((static_cast(msb) << 32) | static_cast(lsb)) +inline constexpr int32_t memoryBusWidth = 128; // bus width in bytes +inline constexpr int32_t numMemoryChannels = 8; +inline constexpr uint32_t unknownMemoryType = UINT32_MAX; -const std::map sysfsEngineMapToLevel0EngineType = { +inline constexpr uint32_t bits(uint32_t x, uint32_t at, uint32_t width) { + return (((x) >> (at)) & ((1 << (width)) - 1)); +} + +inline constexpr uint64_t packInto64Bit(uint32_t msb, uint32_t lsb) { + return ((static_cast(msb) << 32) | static_cast(lsb)); +} + +const std::map sysfsEngineMapToLevel0EngineType = { {"rcs", ZES_ENGINE_TYPE_FLAG_RENDER}, {"ccs", ZES_ENGINE_TYPE_FLAG_COMPUTE}, {"bcs", ZES_ENGINE_TYPE_FLAG_DMA}, {"vcs", ZES_ENGINE_TYPE_FLAG_MEDIA}, {"vecs", ZES_ENGINE_TYPE_FLAG_OTHER}}; + +} // namespace Sysman +} // namespace L0 diff --git a/level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/sysman_product_helper_memory_tests.cpp b/level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/sysman_product_helper_memory_tests.cpp index c8d7655084..5db71993a0 100644 --- a/level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/sysman_product_helper_memory_tests.cpp +++ b/level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/sysman_product_helper_memory_tests.cpp @@ -1157,15 +1157,15 @@ HWTEST2_F(SysmanProductHelperMemoryTest, GivenSysmanProductHelperInstanceWhenCal zes_mem_bandwidth_t memBandwidth; EXPECT_EQ(ZE_RESULT_SUCCESS, pSysmanProductHelper->getMemoryBandwidth(&memBandwidth, pLinuxSysmanImp, subdeviceId)); - uint64_t outputReadCounter = PACK_INTO_64BIT(readCounterUpper, readCounterLower); + uint64_t outputReadCounter = packInto64Bit(readCounterUpper, readCounterLower); outputReadCounter = (outputReadCounter * transactionSize) / microFactor; EXPECT_EQ(outputReadCounter, memBandwidth.readCounter); - uint64_t outputWriteCounter = PACK_INTO_64BIT(writeCounterUpper, writeCounterLower); + uint64_t outputWriteCounter = packInto64Bit(writeCounterUpper, writeCounterLower); outputWriteCounter = (outputWriteCounter * transactionSize) / microFactor; EXPECT_EQ(outputWriteCounter, memBandwidth.writeCounter); - uint64_t outputTimestamp = PACK_INTO_64BIT(timeStampUpper, timeStampLower); + uint64_t outputTimestamp = packInto64Bit(timeStampUpper, timeStampLower); EXPECT_EQ(outputTimestamp, memBandwidth.timestamp); uint64_t outputMaxBandwidth = vramBandwidth; diff --git a/level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/sysman_product_helper_pci_tests.cpp b/level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/sysman_product_helper_pci_tests.cpp index a0f99f4539..3cc55c572f 100644 --- a/level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/sysman_product_helper_pci_tests.cpp +++ b/level_zero/sysman/test/unit_tests/sources/shared/linux/product_helper/sysman_product_helper_pci_tests.cpp @@ -227,14 +227,14 @@ HWTEST2_F(SysmanProductHelperPciTest, GivenSysmanProductHelperInstanceWhenGetPci zes_pci_stats_t stats; EXPECT_EQ(ZE_RESULT_SUCCESS, pSysmanProductHelper->getPciStats(&stats, pLinuxSysmanImp)); - uint64_t mockRxCounter = PACK_INTO_64BIT(mockRxCounterMsb, mockRxCounterLsb); + uint64_t mockRxCounter = packInto64Bit(mockRxCounterMsb, mockRxCounterLsb); EXPECT_EQ(mockRxCounter, stats.rxCounter); - uint64_t mockTxCounter = PACK_INTO_64BIT(mockTxCounterMsb, mockTxCounterLsb); + uint64_t mockTxCounter = packInto64Bit(mockTxCounterMsb, mockTxCounterLsb); EXPECT_EQ(mockTxCounter, stats.txCounter); - uint64_t mockRxPacketCounter = PACK_INTO_64BIT(mockRxPacketCounterMsb, mockRxPacketCounterLsb); - uint64_t mockTxPacketCounter = PACK_INTO_64BIT(mockTxPacketCounterMsb, mockTxPacketCounterLsb); + uint64_t mockRxPacketCounter = packInto64Bit(mockRxPacketCounterMsb, mockRxPacketCounterLsb); + uint64_t mockTxPacketCounter = packInto64Bit(mockTxPacketCounterMsb, mockTxPacketCounterLsb); EXPECT_EQ(mockRxPacketCounter + mockTxPacketCounter, stats.packetCounter); }