1 /* 2 * Copyright (C) 2021 Intel Corporation 3 * 4 * SPDX-License-Identifier: MIT 5 * 6 */ 7 8 #pragma once 9 #include "shared/source/helpers/non_copyable_or_moveable.h" 10 #include "shared/source/os_interface/linux/sys_calls.h" 11 12 #include "level_zero/core/source/device/device.h" 13 #include "level_zero/tools/source/sysman/linux/fs_access.h" 14 15 #include <fcntl.h> 16 #include <map> 17 #include <sys/stat.h> 18 #include <sys/types.h> 19 20 namespace L0 { 21 22 class PlatformMonitoringTech : NEO::NonCopyableOrMovableClass { 23 public: 24 PlatformMonitoringTech() = delete; 25 PlatformMonitoringTech(FsAccess *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId); 26 virtual ~PlatformMonitoringTech(); 27 28 virtual ze_result_t readValue(const std::string key, uint32_t &value); 29 virtual ze_result_t readValue(const std::string key, uint64_t &value); 30 static ze_result_t enumerateRootTelemIndex(FsAccess *pFsAccess, std::string &rootPciPathOfGpuDevice); 31 static void create(const std::vector<ze_device_handle_t> &deviceHandles, 32 FsAccess *pFsAccess, std::string &rootPciPathOfGpuDevice, 33 std::map<uint32_t, L0::PlatformMonitoringTech *> &mapOfSubDeviceIdToPmtObject); 34 35 protected: 36 static uint32_t rootDeviceTelemNodeIndex; 37 std::string telemetryDeviceEntry; 38 std::map<std::string, uint64_t> keyOffsetMap; 39 ze_result_t getKeyOffsetMap(std::string guid, std::map<std::string, uint64_t> &keyOffsetMap); 40 ze_result_t init(FsAccess *pFsAccess, const std::string &rootPciPathOfGpuDevice); 41 static void doInitPmtObject(FsAccess *pFsAccess, uint32_t subdeviceId, PlatformMonitoringTech *pPmt, const std::string &rootPciPathOfGpuDevice, 42 std::map<uint32_t, L0::PlatformMonitoringTech *> &mapOfSubDeviceIdToPmtObject); 43 decltype(&NEO::SysCalls::open) openFunction = NEO::SysCalls::open; 44 decltype(&NEO::SysCalls::close) closeFunction = NEO::SysCalls::close; 45 decltype(&NEO::SysCalls::pread) preadFunction = NEO::SysCalls::pread; 46 47 private: 48 static const std::string baseTelemSysFS; 49 static const std::string telem; 50 uint64_t baseOffset = 0; 51 uint32_t subdeviceId = 0; 52 ze_bool_t isSubdevice = 0; 53 }; 54 55 } // namespace L0 56