Redesign ULT by mocking sysfs and implementing for pci

Change-Id: I5ee2219208d05c125d1fce1a4a5b992bc8c4646e
This commit is contained in:
Mraghuwa
2020-05-21 12:15:07 +05:30
committed by sys_ocldev
parent e25eb4057c
commit b6ccfed471
11 changed files with 267 additions and 221 deletions

View File

@@ -7,6 +7,7 @@
set(L0_SRCS_TOOLS_SYSMAN_PCI_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/os_pci_imp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_pci_imp.h
)
if(UNIX)

View File

@@ -5,45 +5,20 @@
*
*/
#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/source/os_interface/linux/os_interface.h"
#include "level_zero/tools/source/sysman/pci/linux/os_pci_imp.h"
#include "level_zero/core/source/device/device.h"
#include "level_zero/tools/source/sysman/linux/fs_access.h"
#include "sysman/linux/os_sysman_imp.h"
#include "sysman/pci/os_pci.h"
#include "sysman/pci/pci_imp.h"
#include <unistd.h>
namespace L0 {
constexpr uint8_t maxPciBars = 6;
class LinuxPciImp : public OsPci {
public:
ze_result_t getPciBdf(std::string &bdf) override;
ze_result_t getMaxLinkSpeed(double &maxLinkSpeed) override;
ze_result_t getMaxLinkWidth(uint32_t &maxLinkwidth) override;
ze_result_t getLinkGen(uint32_t &linkGen) override;
ze_result_t initializeBarProperties(std::vector<zet_pci_bar_properties_t *> &pBarProperties) override;
LinuxPciImp(OsSysman *pOsSysman);
~LinuxPciImp() override = default;
// Don't allow copies of the LinuxPciImp object
LinuxPciImp(const LinuxPciImp &obj) = delete;
LinuxPciImp &operator=(const LinuxPciImp &obj) = delete;
private:
SysfsAccess *pSysfsAccess;
static const std::string deviceDir;
static const std::string resourceFile;
static const std::string maxLinkSpeedFile;
static const std::string maxLinkWidthFile;
};
const std::string LinuxPciImp::deviceDir("device");
const std::string LinuxPciImp::resourceFile("device/resource");
const std::string LinuxPciImp::maxLinkSpeedFile("device/max_link_speed");
const std::string LinuxPciImp::maxLinkWidthFile("device/max_link_width");
constexpr uint8_t maxPciBars = 6;
ze_result_t LinuxPciImp::getPciBdf(std::string &bdf) {
std::string bdfDir;

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/helpers/non_copyable_or_moveable.h"
#include "sysman/pci/os_pci.h"
namespace L0 {
class SysfsAccess;
class LinuxPciImp : public NEO::NonCopyableClass, public OsPci {
public:
ze_result_t getPciBdf(std::string &bdf) override;
ze_result_t getMaxLinkSpeed(double &maxLinkSpeed) override;
ze_result_t getMaxLinkWidth(uint32_t &maxLinkwidth) override;
ze_result_t getLinkGen(uint32_t &linkGen) override;
ze_result_t initializeBarProperties(std::vector<zet_pci_bar_properties_t *> &pBarProperties) override;
LinuxPciImp() = default;
LinuxPciImp(OsSysman *pOsSysman);
~LinuxPciImp() override = default;
protected:
SysfsAccess *pSysfsAccess = nullptr;
private:
static const std::string deviceDir;
static const std::string resourceFile;
static const std::string maxLinkSpeedFile;
static const std::string maxLinkWidthFile;
};
} // namespace L0

View File

@@ -9,7 +9,9 @@
#include "shared/source/helpers/basic_math.h"
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/helpers/string.h"
#include <cstring>
namespace L0 {
//
@@ -91,9 +93,13 @@ void PciImp::init() {
}
PciImp::~PciImp() {
for (zet_pci_bar_properties_t *pProperties : pciBarProperties) {
delete pProperties;
pProperties = nullptr;
}
if (nullptr != pOsPci) {
delete pOsPci;
pOsPci = nullptr;
}
}
} // namespace L0