mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-06 02:18:05 +08:00
feature(sysman): Added support for PCI APIs
Added support for PCI APIs in the new sysman design Added ULTs for the PCI APIs in the new sysman design Related-To: LOCI-4319 Signed-off-by: Bari, Pratik <pratik.bari@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
7b27d7cf41
commit
f9703f25b0
11
level_zero/sysman/test/unit_tests/sources/pci/CMakeLists.txt
Normal file
11
level_zero/sysman/test/unit_tests/sources/pci/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# Copyright (C) 2023 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
)
|
||||
|
||||
add_subdirectories()
|
||||
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# Copyright (C) 2023 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(L0_TESTS_SYSMAN_PCI_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
)
|
||||
|
||||
list(APPEND L0_TESTS_SYSMAN_PCI_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_pci.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysfs_pci.h
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
target_sources(${TARGET_NAME}
|
||||
PRIVATE
|
||||
${L0_TESTS_SYSMAN_PCI_LINUX}
|
||||
)
|
||||
endif()
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "level_zero/sysman/source/linux/fs_access.h"
|
||||
#include "level_zero/sysman/source/pci/linux/os_pci_imp.h"
|
||||
#include "level_zero/sysman/source/pci/pci_imp.h"
|
||||
#include "level_zero/sysman/source/sysman_const.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
const std::string deviceDir("device");
|
||||
const std::string resourceFile("device/resource");
|
||||
const std::string mockBdf = "0000:00:02.0";
|
||||
const std::string mockRealPath = "/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/" + mockBdf;
|
||||
const std::string mockRealPathConfig = mockRealPath + "/config";
|
||||
const std::string mockRealPath2LevelsUp = "/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0";
|
||||
const std::string mockRealPath2LevelsUpConfig = mockRealPath2LevelsUp + "/config";
|
||||
|
||||
const std::vector<std::string> mockReadBytes =
|
||||
{
|
||||
"0x00000000bf000000 0x00000000bfffffff 0x0000000000140204",
|
||||
"0x0000000000000000 0x0000000000000000 0x0000000000000000",
|
||||
"0x0000000080000000 0x000000008fffffff 0x000000000014220c",
|
||||
"0x0000000000000000 0x0000000000000000 0x0000000000000000",
|
||||
"0x0000000000004000 0x000000000000403f 0x0000000000040101",
|
||||
"0x0000000000000000 0x0000000000000000 0x0000000000000000",
|
||||
"0x00000000000c0000 0x00000000000dffff 0x0000000000000212",
|
||||
"0x0000000000000000 0x0000000000000000 0x0000000000000000",
|
||||
"0x0000000000000000 0x0000000000000000 0x0000000000000000",
|
||||
"0x0000000000000000 0x0000000000000000 0x0000000000000000",
|
||||
"0x0000000000000000 0x0000000000000000 0x0000000000000000",
|
||||
"0x0000000000000000 0x0000000000000000 0x0000000000000000",
|
||||
"0x0000000000000000 0x0000000000000000 0x0000000000000000",
|
||||
};
|
||||
|
||||
struct MockPciSysfsAccess : public L0::Sysman::SysfsAccess {
|
||||
|
||||
bool isStringSymLinkEmpty = false;
|
||||
|
||||
bool isRootUser() override {
|
||||
return true;
|
||||
}
|
||||
|
||||
ze_result_t getValStringSymLinkEmpty(const std::string file, std::string &val) {
|
||||
if (file.compare(deviceDir) == 0) {
|
||||
val = "/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/";
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
ze_result_t readSymLink(const std::string file, std::string &val) override {
|
||||
if (file.compare(deviceDir) == 0) {
|
||||
|
||||
if (isStringSymLinkEmpty == true) {
|
||||
return getValStringSymLinkEmpty(file, val);
|
||||
}
|
||||
|
||||
val = mockBdf;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
ze_result_t getRealPath(const std::string file, std::string &val) override {
|
||||
if (file.compare(deviceDir) == 0) {
|
||||
val = mockRealPath;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
if (file.compare("device/config") == 0) {
|
||||
val = mockRealPathConfig;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
ze_result_t read(const std::string file, std::vector<std::string> &val) override {
|
||||
if (file.compare(resourceFile) == 0) {
|
||||
val = mockReadBytes;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
MockPciSysfsAccess() = default;
|
||||
};
|
||||
|
||||
class PublicLinuxPciImp : public L0::Sysman::LinuxPciImp {
|
||||
public:
|
||||
PublicLinuxPciImp(L0::Sysman::OsSysman *pOsSysman) : L0::Sysman::LinuxPciImp(pOsSysman) {}
|
||||
using L0::Sysman::LinuxPciImp::closeFunction;
|
||||
using L0::Sysman::LinuxPciImp::configMemory;
|
||||
using L0::Sysman::LinuxPciImp::openFunction;
|
||||
using L0::Sysman::LinuxPciImp::pciCardBusConfigRead;
|
||||
using L0::Sysman::LinuxPciImp::pciExtendedConfigRead;
|
||||
using L0::Sysman::LinuxPciImp::preadFunction;
|
||||
using L0::Sysman::LinuxPciImp::pSysfsAccess;
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,654 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_fixture.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/pci/linux/mock_sysfs_pci.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
constexpr uint32_t expectedBus = 0u;
|
||||
constexpr uint32_t expectedDevice = 2u;
|
||||
constexpr uint32_t expectedFunction = 0u;
|
||||
constexpr int32_t expectedWidth = 1u;
|
||||
constexpr int32_t expectedGen = 1u;
|
||||
constexpr int64_t expectedBandwidth = 250000000u;
|
||||
constexpr int convertMegabitsPerSecondToBytesPerSecond = 125000;
|
||||
constexpr int convertGigabitToMegabit = 1000;
|
||||
constexpr double encodingGen1Gen2 = 0.8;
|
||||
constexpr double encodingGen3andAbove = 0.98461538461;
|
||||
constexpr int pciExtendedConfigSpaceSize = 4096;
|
||||
constexpr int pciConfigSpaceSize = 256;
|
||||
static int fakeFileDescriptor = 123;
|
||||
static int fakeFileDescriptor1 = 124;
|
||||
|
||||
inline static int openMock(const char *pathname, int flags) {
|
||||
if (strcmp(pathname, mockRealPathConfig.c_str()) == 0) {
|
||||
return fakeFileDescriptor;
|
||||
}
|
||||
|
||||
if (strcmp(pathname, mockRealPath2LevelsUpConfig.c_str()) == 0) {
|
||||
return fakeFileDescriptor1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
inline static int openMockReturnFailure(const char *pathname, int flags) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
inline static int closeMock(int fd) {
|
||||
if ((fd == fakeFileDescriptor) || (fd == fakeFileDescriptor1)) {
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
ssize_t preadMock(int fd, void *buf, size_t count, off_t offset) {
|
||||
uint8_t *mockBuf = static_cast<uint8_t *>(buf);
|
||||
// Sample config values
|
||||
if (fd == fakeFileDescriptor) {
|
||||
mockBuf[0x006] = 0x10;
|
||||
mockBuf[0x034] = 0x40;
|
||||
mockBuf[0x040] = 0x0d;
|
||||
mockBuf[0x041] = 0x50;
|
||||
mockBuf[0x050] = 0x10;
|
||||
mockBuf[0x051] = 0x70;
|
||||
mockBuf[0x052] = 0x90;
|
||||
mockBuf[0x070] = 0x10;
|
||||
mockBuf[0x071] = 0xac;
|
||||
mockBuf[0x072] = 0xa0;
|
||||
mockBuf[0x0ac] = 0x10;
|
||||
mockBuf[0x0b8] = 0x11;
|
||||
mockBuf[0x100] = 0x0e;
|
||||
mockBuf[0x102] = 0x01;
|
||||
mockBuf[0x103] = 0x42;
|
||||
mockBuf[0x420] = 0x15;
|
||||
mockBuf[0x422] = 0x01;
|
||||
mockBuf[0x423] = 0x22;
|
||||
mockBuf[0x425] = 0xf0;
|
||||
mockBuf[0x426] = 0x3f;
|
||||
mockBuf[0x428] = 0x22;
|
||||
mockBuf[0x429] = 0x11;
|
||||
mockBuf[0x220] = 0x24;
|
||||
mockBuf[0x222] = 0x01;
|
||||
mockBuf[0x223] = 0x32;
|
||||
mockBuf[0x320] = 0x10;
|
||||
mockBuf[0x322] = 0x01;
|
||||
mockBuf[0x323] = 0x40;
|
||||
mockBuf[0x400] = 0x18;
|
||||
mockBuf[0x402] = 0x01;
|
||||
return pciExtendedConfigSpaceSize;
|
||||
} else {
|
||||
mockBuf[0x006] = 0x10;
|
||||
mockBuf[0x034] = 0x40;
|
||||
mockBuf[0x040] = 0x0d;
|
||||
mockBuf[0x041] = 0x50;
|
||||
mockBuf[0x050] = 0x10;
|
||||
mockBuf[0x051] = 0x70;
|
||||
mockBuf[0x052] = 0x90;
|
||||
mockBuf[0x070] = 0x10;
|
||||
mockBuf[0x071] = 0xac;
|
||||
mockBuf[0x072] = 0xa0;
|
||||
mockBuf[0x0ac] = 0x10;
|
||||
mockBuf[0x0b8] = 0x11;
|
||||
return pciConfigSpaceSize;
|
||||
}
|
||||
}
|
||||
|
||||
ssize_t preadMockHeaderFailure(int fd, void *buf, size_t count, off_t offset) {
|
||||
if (fd == fakeFileDescriptor) {
|
||||
return pciExtendedConfigSpaceSize;
|
||||
} else {
|
||||
return pciConfigSpaceSize;
|
||||
}
|
||||
}
|
||||
|
||||
ssize_t preadMockInvalidPos(int fd, void *buf, size_t count, off_t offset) {
|
||||
uint8_t *mockBuf = static_cast<uint8_t *>(buf);
|
||||
// Sample config values
|
||||
if (fd == fakeFileDescriptor) {
|
||||
mockBuf[0x006] = 0x10;
|
||||
mockBuf[0x034] = 0x40;
|
||||
mockBuf[0x040] = 0x0d;
|
||||
mockBuf[0x041] = 0x50;
|
||||
mockBuf[0x050] = 0x10;
|
||||
mockBuf[0x051] = 0x70;
|
||||
mockBuf[0x052] = 0x90;
|
||||
mockBuf[0x070] = 0x10;
|
||||
mockBuf[0x071] = 0xac;
|
||||
mockBuf[0x072] = 0xa0;
|
||||
mockBuf[0x0ac] = 0x11;
|
||||
mockBuf[0x0ad] = 0x00;
|
||||
mockBuf[0x100] = 0x0e;
|
||||
mockBuf[0x102] = 0x01;
|
||||
mockBuf[0x420] = 0x15;
|
||||
mockBuf[0x422] = 0x01;
|
||||
mockBuf[0x423] = 0x22;
|
||||
mockBuf[0x220] = 0x24;
|
||||
mockBuf[0x222] = 0x01;
|
||||
mockBuf[0x223] = 0x32;
|
||||
mockBuf[0x320] = 0x10;
|
||||
mockBuf[0x322] = 0x01;
|
||||
mockBuf[0x323] = 0x40;
|
||||
mockBuf[0x400] = 0x18;
|
||||
mockBuf[0x402] = 0x01;
|
||||
return pciExtendedConfigSpaceSize;
|
||||
} else {
|
||||
mockBuf[0x006] = 0x10;
|
||||
mockBuf[0x034] = 0x40;
|
||||
mockBuf[0x040] = 0x0d;
|
||||
mockBuf[0x041] = 0x50;
|
||||
mockBuf[0x050] = 0x10;
|
||||
mockBuf[0x051] = 0x70;
|
||||
mockBuf[0x052] = 0x90;
|
||||
mockBuf[0x070] = 0x10;
|
||||
mockBuf[0x071] = 0xac;
|
||||
mockBuf[0x072] = 0xa0;
|
||||
mockBuf[0x0ac] = 0x11;
|
||||
mockBuf[0x0ad] = 0x00;
|
||||
return pciConfigSpaceSize;
|
||||
}
|
||||
}
|
||||
|
||||
ssize_t preadMockLoop(int fd, void *buf, size_t count, off_t offset) {
|
||||
uint8_t *mockBuf = static_cast<uint8_t *>(buf);
|
||||
// Sample config values
|
||||
if (fd == fakeFileDescriptor) {
|
||||
mockBuf[0x006] = 0x10;
|
||||
mockBuf[0x034] = 0x40;
|
||||
mockBuf[0x040] = 0x0d;
|
||||
mockBuf[0x041] = 0x50;
|
||||
mockBuf[0x050] = 0x10;
|
||||
mockBuf[0x051] = 0x70;
|
||||
mockBuf[0x052] = 0x90;
|
||||
mockBuf[0x070] = 0x10;
|
||||
mockBuf[0x071] = 0xac;
|
||||
mockBuf[0x072] = 0xa0;
|
||||
mockBuf[0x0ac] = 0x0d;
|
||||
mockBuf[0x0ad] = 0x40;
|
||||
mockBuf[0x0b8] = 0x11;
|
||||
mockBuf[0x100] = 0x0e;
|
||||
mockBuf[0x102] = 0x01;
|
||||
mockBuf[0x103] = 0x42;
|
||||
mockBuf[0x420] = 0x16;
|
||||
mockBuf[0x422] = 0x01;
|
||||
mockBuf[0x423] = 0x42;
|
||||
mockBuf[0x220] = 0x24;
|
||||
mockBuf[0x222] = 0x01;
|
||||
mockBuf[0x223] = 0x32;
|
||||
mockBuf[0x320] = 0x10;
|
||||
mockBuf[0x322] = 0x01;
|
||||
mockBuf[0x323] = 0x40;
|
||||
mockBuf[0x400] = 0x18;
|
||||
mockBuf[0x402] = 0x01;
|
||||
return pciExtendedConfigSpaceSize;
|
||||
} else {
|
||||
mockBuf[0x006] = 0x10;
|
||||
mockBuf[0x034] = 0x40;
|
||||
mockBuf[0x040] = 0x0d;
|
||||
mockBuf[0x041] = 0x50;
|
||||
mockBuf[0x050] = 0x10;
|
||||
mockBuf[0x051] = 0x70;
|
||||
mockBuf[0x052] = 0x90;
|
||||
mockBuf[0x070] = 0x0d;
|
||||
mockBuf[0x071] = 0xac;
|
||||
mockBuf[0x072] = 0xa0;
|
||||
mockBuf[0x0ac] = 0x0d;
|
||||
mockBuf[0x0ad] = 0x40;
|
||||
mockBuf[0x0b8] = 0x11;
|
||||
return pciConfigSpaceSize;
|
||||
}
|
||||
}
|
||||
|
||||
ssize_t preadMockFailure(int fd, void *buf, size_t count, off_t offset) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
class ZesPciFixture : public SysmanDeviceFixture {
|
||||
|
||||
protected:
|
||||
std::unique_ptr<MockPciSysfsAccess> pSysfsAccess;
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
L0::Sysman::SysfsAccess *pOriginalSysfsAccess = nullptr;
|
||||
L0::Sysman::FsAccess *pOriginalFsAccess = nullptr;
|
||||
L0::Sysman::PciImp *pPciImp;
|
||||
L0::Sysman::OsPci *pOsPciPrev;
|
||||
std::unique_ptr<Mock<L0::DriverHandleImp>> driverHandle;
|
||||
|
||||
void SetUp() override {
|
||||
SysmanDeviceFixture::SetUp();
|
||||
device = pSysmanDevice;
|
||||
pSysfsAccess = std::make_unique<MockPciSysfsAccess>();
|
||||
pOriginalSysfsAccess = pLinuxSysmanImp->pSysfsAccess;
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
|
||||
|
||||
pPciImp = static_cast<L0::Sysman::PciImp *>(pSysmanDeviceImp->pPci);
|
||||
pOsPciPrev = pPciImp->pOsPci;
|
||||
pPciImp->pOsPci = nullptr;
|
||||
PublicLinuxPciImp *pLinuxPciImp = new PublicLinuxPciImp(pOsSysman);
|
||||
pLinuxPciImp->openFunction = openMock;
|
||||
pLinuxPciImp->closeFunction = closeMock;
|
||||
pLinuxPciImp->preadFunction = preadMock;
|
||||
|
||||
pLinuxPciImp->pciExtendedConfigRead();
|
||||
pLinuxPciImp->pciCardBusConfigRead();
|
||||
pPciImp->pOsPci = static_cast<L0::Sysman::OsPci *>(pLinuxPciImp);
|
||||
pPciImp->pciGetStaticFields();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (nullptr != pPciImp->pOsPci) {
|
||||
delete pPciImp->pOsPci;
|
||||
}
|
||||
pPciImp->pOsPci = pOsPciPrev;
|
||||
pPciImp = nullptr;
|
||||
pLinuxSysmanImp->pSysfsAccess = pOriginalSysfsAccess;
|
||||
SysmanDeviceFixture::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(ZesPciFixture, GivenValidSysmanHandleWhenCallingzetSysmanPciGetPropertiesThenVerifyzetSysmanPciGetPropertiesCallSucceeds) {
|
||||
zes_pci_properties_t properties, propertiesBefore;
|
||||
|
||||
memset(&properties.address.bus, std::numeric_limits<int>::max(), sizeof(properties.address.bus));
|
||||
memset(&properties.address.device, std::numeric_limits<int>::max(), sizeof(properties.address.device));
|
||||
memset(&properties.address.function, std::numeric_limits<int>::max(), sizeof(properties.address.function));
|
||||
memset(&properties.maxSpeed.gen, std::numeric_limits<int>::max(), sizeof(properties.maxSpeed.gen));
|
||||
memset(&properties.maxSpeed.width, std::numeric_limits<int>::max(), sizeof(properties.maxSpeed.width));
|
||||
memset(&properties.maxSpeed.maxBandwidth, std::numeric_limits<int>::max(), sizeof(properties.maxSpeed.maxBandwidth));
|
||||
propertiesBefore = properties;
|
||||
|
||||
ze_result_t result = zesDevicePciGetProperties(device, &properties);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(properties.address.bus, expectedBus);
|
||||
EXPECT_EQ(properties.address.device, expectedDevice);
|
||||
EXPECT_EQ(properties.address.function, expectedFunction);
|
||||
EXPECT_EQ(properties.maxSpeed.gen, expectedGen);
|
||||
EXPECT_EQ(properties.maxSpeed.width, expectedWidth);
|
||||
EXPECT_EQ(properties.maxSpeed.maxBandwidth, expectedBandwidth);
|
||||
|
||||
EXPECT_NE(properties.address.bus, propertiesBefore.address.bus);
|
||||
EXPECT_NE(properties.address.device, propertiesBefore.address.device);
|
||||
EXPECT_NE(properties.address.function, propertiesBefore.address.function);
|
||||
EXPECT_NE(properties.maxSpeed.gen, propertiesBefore.maxSpeed.gen);
|
||||
EXPECT_NE(properties.maxSpeed.width, propertiesBefore.maxSpeed.width);
|
||||
EXPECT_NE(properties.maxSpeed.maxBandwidth, propertiesBefore.maxSpeed.maxBandwidth);
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, GivenValidSysmanHandleWhenSettingLmemSupportAndCallingzetSysmanPciGetPropertiesThenVerifyApiCallSucceeds) {
|
||||
zes_pci_properties_t properties, propertiesBefore;
|
||||
L0::Sysman::OsPci *pOsPciOriginal = pPciImp->pOsPci;
|
||||
PublicLinuxPciImp *pLinuxPciImpTemp = new PublicLinuxPciImp(pOsSysman);
|
||||
pLinuxPciImpTemp->openFunction = openMock;
|
||||
pLinuxPciImpTemp->closeFunction = closeMock;
|
||||
pLinuxPciImpTemp->preadFunction = preadMock;
|
||||
|
||||
pLinuxPciImpTemp->pciExtendedConfigRead();
|
||||
pLinuxPciImpTemp->pciCardBusConfigRead();
|
||||
pPciImp->pOsPci = static_cast<L0::Sysman::OsPci *>(pLinuxPciImpTemp);
|
||||
pPciImp->pciGetStaticFields();
|
||||
|
||||
memset(&properties.address.bus, std::numeric_limits<int>::max(), sizeof(properties.address.bus));
|
||||
memset(&properties.address.device, std::numeric_limits<int>::max(), sizeof(properties.address.device));
|
||||
memset(&properties.address.function, std::numeric_limits<int>::max(), sizeof(properties.address.function));
|
||||
memset(&properties.maxSpeed.gen, std::numeric_limits<int>::max(), sizeof(properties.maxSpeed.gen));
|
||||
memset(&properties.maxSpeed.width, std::numeric_limits<int>::max(), sizeof(properties.maxSpeed.width));
|
||||
memset(&properties.maxSpeed.maxBandwidth, std::numeric_limits<int>::max(), sizeof(properties.maxSpeed.maxBandwidth));
|
||||
propertiesBefore = properties;
|
||||
|
||||
ze_result_t result = zesDevicePciGetProperties(device, &properties);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(properties.address.bus, expectedBus);
|
||||
EXPECT_EQ(properties.address.device, expectedDevice);
|
||||
EXPECT_EQ(properties.address.function, expectedFunction);
|
||||
EXPECT_EQ(properties.maxSpeed.gen, expectedGen);
|
||||
EXPECT_EQ(properties.maxSpeed.width, expectedWidth);
|
||||
EXPECT_EQ(properties.maxSpeed.maxBandwidth, expectedBandwidth);
|
||||
|
||||
EXPECT_NE(properties.address.bus, propertiesBefore.address.bus);
|
||||
EXPECT_NE(properties.address.device, propertiesBefore.address.device);
|
||||
EXPECT_NE(properties.address.function, propertiesBefore.address.function);
|
||||
EXPECT_NE(properties.maxSpeed.gen, propertiesBefore.maxSpeed.gen);
|
||||
EXPECT_NE(properties.maxSpeed.width, propertiesBefore.maxSpeed.width);
|
||||
EXPECT_NE(properties.maxSpeed.maxBandwidth, propertiesBefore.maxSpeed.maxBandwidth);
|
||||
|
||||
delete pLinuxPciImpTemp;
|
||||
pPciImp->pOsPci = pOsPciOriginal;
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, GivenValidSysmanHandleWhenCallingzetSysmanPciGetPropertiesAndBdfStringIsEmptyThenVerifyApiCallSucceeds) {
|
||||
zes_pci_properties_t properties;
|
||||
|
||||
pSysfsAccess->isStringSymLinkEmpty = true;
|
||||
|
||||
ze_result_t result = zesDevicePciGetProperties(device, &properties);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(properties.address.bus, 0u);
|
||||
EXPECT_EQ(properties.address.device, 0u);
|
||||
EXPECT_EQ(properties.address.function, 0u);
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, GivenSysmanHandleWhenGettingPCIWidthAndSpeedAndCapabilityLinkListIsBrokenThenInvalidValuesAreReturned) {
|
||||
int32_t width = 0;
|
||||
double speed = 0;
|
||||
L0::Sysman::OsPci *pOsPciOriginal = pPciImp->pOsPci;
|
||||
PublicLinuxPciImp *pLinuxPciImpTemp = new PublicLinuxPciImp(pOsSysman);
|
||||
pLinuxPciImpTemp->openFunction = openMock;
|
||||
pLinuxPciImpTemp->closeFunction = closeMock;
|
||||
pLinuxPciImpTemp->preadFunction = preadMockInvalidPos;
|
||||
|
||||
pLinuxPciImpTemp->pciExtendedConfigRead();
|
||||
pLinuxPciImpTemp->pciCardBusConfigRead();
|
||||
pPciImp->pOsPci = static_cast<L0::Sysman::OsPci *>(pLinuxPciImpTemp);
|
||||
pPciImp->pciGetStaticFields();
|
||||
pPciImp->pOsPci->getMaxLinkCaps(speed, width);
|
||||
EXPECT_EQ(width, -1);
|
||||
EXPECT_EQ(speed, 0);
|
||||
|
||||
delete pLinuxPciImpTemp;
|
||||
pPciImp->pOsPci = pOsPciOriginal;
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, GivenSysmanHandleWhenGettingPCIWidthAndSpeedAndPCIExpressCapabilityIsNotPresentThenInvalidValuesAreReturned) {
|
||||
int32_t width = 0;
|
||||
double speed = 0;
|
||||
L0::Sysman::OsPci *pOsPciOriginal = pPciImp->pOsPci;
|
||||
PublicLinuxPciImp *pLinuxPciImpTemp = new PublicLinuxPciImp(pOsSysman);
|
||||
pLinuxPciImpTemp->openFunction = openMock;
|
||||
pLinuxPciImpTemp->closeFunction = closeMock;
|
||||
pLinuxPciImpTemp->preadFunction = preadMockLoop;
|
||||
|
||||
pLinuxPciImpTemp->pciExtendedConfigRead();
|
||||
pLinuxPciImpTemp->pciCardBusConfigRead();
|
||||
pPciImp->pOsPci = static_cast<L0::Sysman::OsPci *>(pLinuxPciImpTemp);
|
||||
pPciImp->pciGetStaticFields();
|
||||
pPciImp->pOsPci->getMaxLinkCaps(speed, width);
|
||||
EXPECT_EQ(width, -1);
|
||||
EXPECT_EQ(speed, 0);
|
||||
|
||||
delete pLinuxPciImpTemp;
|
||||
pPciImp->pOsPci = pOsPciOriginal;
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, GivenSysmanHandleWhenInitializingPciAndPciConfigOpenFailsThenInvalidSpeedAndWidthAreReturned) {
|
||||
int32_t width = 0;
|
||||
double speed = 0;
|
||||
L0::Sysman::OsPci *pOsPciOriginal = pPciImp->pOsPci;
|
||||
PublicLinuxPciImp *pLinuxPciImpTemp = new PublicLinuxPciImp(pOsSysman);
|
||||
pLinuxPciImpTemp->openFunction = openMockReturnFailure;
|
||||
pLinuxPciImpTemp->closeFunction = closeMock;
|
||||
pLinuxPciImpTemp->preadFunction = preadMock;
|
||||
|
||||
pLinuxPciImpTemp->pciExtendedConfigRead();
|
||||
pLinuxPciImpTemp->pciCardBusConfigRead();
|
||||
pPciImp->pOsPci = static_cast<L0::Sysman::OsPci *>(pLinuxPciImpTemp);
|
||||
pPciImp->pciGetStaticFields();
|
||||
pPciImp->pOsPci->getMaxLinkCaps(speed, width);
|
||||
EXPECT_EQ(width, -1);
|
||||
EXPECT_EQ(speed, 0);
|
||||
|
||||
delete pLinuxPciImpTemp;
|
||||
pPciImp->pOsPci = pOsPciOriginal;
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, GivenSysmanHandleWhenGettingPCIWidthAndSpeedAndPCIHeaderIsAbsentThenInvalidValuesAreReturned) {
|
||||
int32_t width = 0;
|
||||
double speed = 0;
|
||||
L0::Sysman::OsPci *pOsPciOriginal = pPciImp->pOsPci;
|
||||
PublicLinuxPciImp *pLinuxPciImpTemp = new PublicLinuxPciImp(pOsSysman);
|
||||
pLinuxPciImpTemp->openFunction = openMock;
|
||||
pLinuxPciImpTemp->closeFunction = closeMock;
|
||||
pLinuxPciImpTemp->preadFunction = preadMockHeaderFailure;
|
||||
|
||||
pLinuxPciImpTemp->pciExtendedConfigRead();
|
||||
pLinuxPciImpTemp->pciCardBusConfigRead();
|
||||
pPciImp->pOsPci = static_cast<L0::Sysman::OsPci *>(pLinuxPciImpTemp);
|
||||
pPciImp->pciGetStaticFields();
|
||||
pPciImp->pOsPci->getMaxLinkCaps(speed, width);
|
||||
EXPECT_EQ(width, -1);
|
||||
EXPECT_EQ(speed, 0);
|
||||
|
||||
delete pLinuxPciImpTemp;
|
||||
pPciImp->pOsPci = pOsPciOriginal;
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, GivenValidSysmanHandleWhenCallingzetSysmanPciGetBarsThenVerifyzetSysmanPciGetBarsCallSucceeds) {
|
||||
uint32_t count = 0;
|
||||
ze_result_t result = zesDevicePciGetBars(device, &count, nullptr);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_GT(count, 0u);
|
||||
|
||||
uint32_t testCount = count + 1;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDevicePciGetBars(device, &testCount, nullptr));
|
||||
EXPECT_EQ(count, testCount);
|
||||
|
||||
std::vector<zes_pci_bar_properties_t> pciBarProps(count);
|
||||
result = zesDevicePciGetBars(device, &count, pciBarProps.data());
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
EXPECT_LE(pciBarProps[i].type, ZES_PCI_BAR_TYPE_MEM);
|
||||
EXPECT_NE(pciBarProps[i].base, 0u);
|
||||
EXPECT_NE(pciBarProps[i].size, 0u);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, GivenValidSysmanHandleWhenInitializingPciAndPciConfigOpenFailsThenResizableBarSupportWillBeFalse) {
|
||||
L0::Sysman::OsPci *pOsPciOriginal = pPciImp->pOsPci;
|
||||
PublicLinuxPciImp *pLinuxPciImpTemp = new PublicLinuxPciImp(pOsSysman);
|
||||
pLinuxPciImpTemp->openFunction = openMockReturnFailure;
|
||||
pLinuxPciImpTemp->closeFunction = closeMock;
|
||||
pLinuxPciImpTemp->preadFunction = preadMock;
|
||||
|
||||
pLinuxPciImpTemp->pciExtendedConfigRead();
|
||||
pPciImp->pOsPci = static_cast<L0::Sysman::OsPci *>(pLinuxPciImpTemp);
|
||||
pPciImp->pciGetStaticFields();
|
||||
EXPECT_FALSE(pPciImp->pOsPci->resizableBarSupported());
|
||||
uint32_t barIndex = 2u;
|
||||
EXPECT_FALSE(pPciImp->pOsPci->resizableBarEnabled(barIndex));
|
||||
delete pLinuxPciImpTemp;
|
||||
pPciImp->pOsPci = pOsPciOriginal;
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, GivenValidSysmanHandleWhenInitializingPciAndPciConfigReadFailsThenResizableBarSupportWillBeFalse) {
|
||||
L0::Sysman::OsPci *pOsPciOriginal = pPciImp->pOsPci;
|
||||
PublicLinuxPciImp *pLinuxPciImpTemp = new PublicLinuxPciImp(pOsSysman);
|
||||
pLinuxPciImpTemp->openFunction = openMock;
|
||||
pLinuxPciImpTemp->closeFunction = closeMock;
|
||||
pLinuxPciImpTemp->preadFunction = preadMockFailure;
|
||||
|
||||
pLinuxPciImpTemp->pciExtendedConfigRead();
|
||||
pPciImp->pOsPci = static_cast<L0::Sysman::OsPci *>(pLinuxPciImpTemp);
|
||||
pPciImp->pciGetStaticFields();
|
||||
EXPECT_FALSE(pPciImp->pOsPci->resizableBarSupported());
|
||||
uint32_t barIndex = 2u;
|
||||
EXPECT_FALSE(pPciImp->pOsPci->resizableBarEnabled(barIndex));
|
||||
delete pLinuxPciImpTemp;
|
||||
pPciImp->pOsPci = pOsPciOriginal;
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, GivenSysmanHandleWhenCheckForResizableBarSupportAndHeaderFieldNotPresentThenResizableBarSupportFalseReturned) {
|
||||
L0::Sysman::OsPci *pOsPciOriginal = pPciImp->pOsPci;
|
||||
PublicLinuxPciImp *pLinuxPciImpTemp = new PublicLinuxPciImp(pOsSysman);
|
||||
pLinuxPciImpTemp->openFunction = openMock;
|
||||
pLinuxPciImpTemp->closeFunction = closeMock;
|
||||
pLinuxPciImpTemp->preadFunction = preadMockHeaderFailure;
|
||||
|
||||
pLinuxPciImpTemp->pciExtendedConfigRead();
|
||||
pPciImp->pOsPci = static_cast<L0::Sysman::OsPci *>(pLinuxPciImpTemp);
|
||||
pPciImp->pciGetStaticFields();
|
||||
EXPECT_FALSE(pPciImp->pOsPci->resizableBarSupported());
|
||||
uint32_t barIndex = 2u;
|
||||
EXPECT_FALSE(pPciImp->pOsPci->resizableBarEnabled(barIndex));
|
||||
delete pLinuxPciImpTemp;
|
||||
pPciImp->pOsPci = pOsPciOriginal;
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, GivenSysmanHandleWhenCheckForResizableBarSupportAndCapabilityLinkListIsBrokenThenResizableBarSupportFalseReturned) {
|
||||
L0::Sysman::OsPci *pOsPciOriginal = pPciImp->pOsPci;
|
||||
PublicLinuxPciImp *pLinuxPciImpTemp = new PublicLinuxPciImp(pOsSysman);
|
||||
pLinuxPciImpTemp->openFunction = openMock;
|
||||
pLinuxPciImpTemp->closeFunction = closeMock;
|
||||
pLinuxPciImpTemp->preadFunction = preadMockInvalidPos;
|
||||
|
||||
pLinuxPciImpTemp->pciExtendedConfigRead();
|
||||
pPciImp->pOsPci = static_cast<L0::Sysman::OsPci *>(pLinuxPciImpTemp);
|
||||
pPciImp->pciGetStaticFields();
|
||||
EXPECT_FALSE(pPciImp->pOsPci->resizableBarSupported());
|
||||
uint32_t barIndex = 2u;
|
||||
EXPECT_FALSE(pPciImp->pOsPci->resizableBarEnabled(barIndex));
|
||||
delete pLinuxPciImpTemp;
|
||||
pPciImp->pOsPci = pOsPciOriginal;
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, GivenSysmanHandleWhenCheckForResizableBarSupportAndIfRebarCapabilityNotPresentThenResizableBarSupportFalseReturned) {
|
||||
L0::Sysman::OsPci *pOsPciOriginal = pPciImp->pOsPci;
|
||||
PublicLinuxPciImp *pLinuxPciImpTemp = new PublicLinuxPciImp(pOsSysman);
|
||||
pLinuxPciImpTemp->openFunction = openMock;
|
||||
pLinuxPciImpTemp->closeFunction = closeMock;
|
||||
pLinuxPciImpTemp->preadFunction = preadMockLoop;
|
||||
|
||||
pLinuxPciImpTemp->pciExtendedConfigRead();
|
||||
pPciImp->pOsPci = static_cast<L0::Sysman::OsPci *>(pLinuxPciImpTemp);
|
||||
pPciImp->pciGetStaticFields();
|
||||
EXPECT_FALSE(pPciImp->pOsPci->resizableBarSupported());
|
||||
uint32_t barIndex = 2u;
|
||||
EXPECT_FALSE(pPciImp->pOsPci->resizableBarEnabled(barIndex));
|
||||
delete pLinuxPciImpTemp;
|
||||
pPciImp->pOsPci = pOsPciOriginal;
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, GivenValidSysmanHandleWhenCallingzetSysmanPciGetBarsThenVerifyzetSysmanPciGetBarsCallSucceedsWith1_2Extension) {
|
||||
uint32_t count = 0;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDevicePciGetBars(device, &count, nullptr));
|
||||
EXPECT_NE(count, 0u);
|
||||
|
||||
std::vector<zes_pci_bar_properties_t> pBarProps(count);
|
||||
std::vector<zes_pci_bar_properties_1_2_t> props12(count);
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
props12[i].stype = ZES_STRUCTURE_TYPE_PCI_BAR_PROPERTIES_1_2;
|
||||
props12[i].pNext = nullptr;
|
||||
pBarProps[i].stype = ZES_STRUCTURE_TYPE_PCI_BAR_PROPERTIES;
|
||||
pBarProps[i].pNext = static_cast<void *>(&props12[i]);
|
||||
}
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDevicePciGetBars(device, &count, pBarProps.data()));
|
||||
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
EXPECT_EQ(pBarProps[i].stype, zes_structure_type_t::ZES_STRUCTURE_TYPE_PCI_BAR_PROPERTIES);
|
||||
EXPECT_LE(pBarProps[i].type, ZES_PCI_BAR_TYPE_MEM);
|
||||
EXPECT_NE(pBarProps[i].base, 0u);
|
||||
EXPECT_NE(pBarProps[i].size, 0u);
|
||||
EXPECT_EQ(props12[i].stype, zes_structure_type_t::ZES_STRUCTURE_TYPE_PCI_BAR_PROPERTIES_1_2);
|
||||
EXPECT_EQ(props12[i].resizableBarSupported, true);
|
||||
if (props12[i].index == 2) {
|
||||
EXPECT_EQ(props12[i].resizableBarEnabled, true);
|
||||
} else {
|
||||
EXPECT_EQ(props12[i].resizableBarEnabled, false);
|
||||
}
|
||||
EXPECT_LE(props12[i].type, ZES_PCI_BAR_TYPE_MEM);
|
||||
EXPECT_NE(props12[i].base, 0u);
|
||||
EXPECT_NE(props12[i].size, 0u);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, GivenValidSysmanHandleWhenCallingzetSysmanPciGetBarsThenVerifyzetSysmanPciGetBarsCallSucceedsWith1_2ExtensionWrongType) {
|
||||
uint32_t count = 0;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDevicePciGetBars(device, &count, nullptr));
|
||||
EXPECT_NE(count, 0u);
|
||||
|
||||
std::vector<zes_pci_bar_properties_t> pBarProps(count);
|
||||
std::vector<zes_pci_bar_properties_1_2_t> props12(count);
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
props12[i].stype = ZES_STRUCTURE_TYPE_PCI_STATE;
|
||||
props12[i].pNext = nullptr;
|
||||
pBarProps[i].stype = ZES_STRUCTURE_TYPE_PCI_BAR_PROPERTIES;
|
||||
pBarProps[i].pNext = static_cast<void *>(&props12[i]);
|
||||
}
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDevicePciGetBars(device, &count, pBarProps.data()));
|
||||
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
EXPECT_EQ(pBarProps[i].stype, zes_structure_type_t::ZES_STRUCTURE_TYPE_PCI_BAR_PROPERTIES);
|
||||
EXPECT_LE(pBarProps[i].type, ZES_PCI_BAR_TYPE_MEM);
|
||||
EXPECT_NE(pBarProps[i].base, 0u);
|
||||
EXPECT_NE(pBarProps[i].size, 0u);
|
||||
EXPECT_EQ(props12[i].stype, zes_structure_type_t::ZES_STRUCTURE_TYPE_PCI_STATE);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, GivenValidSysmanHandleWhenCallingzetSysmanPciGetBarsThenVerifyzetSysmanPciGetBarsCallSucceedsWith1_2ExtensionWithNullPtr) {
|
||||
uint32_t count = 0;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDevicePciGetBars(device, &count, nullptr));
|
||||
EXPECT_NE(count, 0u);
|
||||
|
||||
zes_pci_bar_properties_t *pBarProps = new zes_pci_bar_properties_t[count];
|
||||
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
pBarProps[i].pNext = nullptr;
|
||||
pBarProps[i].stype = zes_structure_type_t::ZES_STRUCTURE_TYPE_PCI_BAR_PROPERTIES;
|
||||
}
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDevicePciGetBars(device, &count, pBarProps));
|
||||
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
EXPECT_LE(pBarProps[i].type, ZES_PCI_BAR_TYPE_MEM);
|
||||
EXPECT_NE(pBarProps[i].base, 0u);
|
||||
EXPECT_NE(pBarProps[i].size, 0u);
|
||||
}
|
||||
|
||||
delete[] pBarProps;
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, GivenValidSysmanHandleWhenCallingzetSysmanPciGetStateThenVerifyzetSysmanPciGetStateCallReturnNotSupported) {
|
||||
zes_pci_state_t state;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesDevicePciGetState(device, &state));
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, GivenValidSysmanHandleWhenCallingzetSysmanPciGetStatsThenVerifyzetSysmanPciGetStatsCallReturnNotSupported) {
|
||||
zes_pci_stats_t stats;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesDevicePciGetStats(device, &stats));
|
||||
}
|
||||
|
||||
TEST_F(ZesPciFixture, WhenConvertingLinkSpeedThenResultIsCorrect) {
|
||||
for (int32_t i = PciGenerations::PciGen1; i <= PciGenerations::PciGen5; i++) {
|
||||
double speed = L0::Sysman::convertPciGenToLinkSpeed(i);
|
||||
int32_t gen = L0::Sysman::convertLinkSpeedToPciGen(speed);
|
||||
EXPECT_EQ(i, gen);
|
||||
}
|
||||
|
||||
EXPECT_EQ(-1, L0::Sysman::convertLinkSpeedToPciGen(0.0));
|
||||
EXPECT_EQ(0.0, L0::Sysman::convertPciGenToLinkSpeed(0));
|
||||
}
|
||||
|
||||
// This test validates convertPcieSpeedFromGTsToBs method.
|
||||
// convertPcieSpeedFromGTsToBs(double maxLinkSpeedInGt) method will
|
||||
// return real PCIe speed in bytes per second as per below formula:
|
||||
// maxLinkSpeedInGt * (Gigabit to Megabit) * Encoding * (Mb/s to bytes/second) =
|
||||
// maxLinkSpeedInGt * convertGigabitToMegabit * Encoding * convertMegabitsPerSecondToBytesPerSecond;
|
||||
|
||||
TEST_F(ZesPciFixture, WhenConvertingLinkSpeedFromGigatransfersPerSecondToBytesPerSecondThenResultIsCorrect) {
|
||||
int64_t speedPci320 = L0::Sysman::convertPcieSpeedFromGTsToBs(PciLinkSpeeds::Pci32_0GigatransfersPerSecond);
|
||||
EXPECT_EQ(speedPci320, static_cast<int64_t>(PciLinkSpeeds::Pci32_0GigatransfersPerSecond * convertMegabitsPerSecondToBytesPerSecond * convertGigabitToMegabit * encodingGen3andAbove));
|
||||
int64_t speedPci160 = L0::Sysman::convertPcieSpeedFromGTsToBs(PciLinkSpeeds::Pci16_0GigatransfersPerSecond);
|
||||
EXPECT_EQ(speedPci160, static_cast<int64_t>(PciLinkSpeeds::Pci16_0GigatransfersPerSecond * convertMegabitsPerSecondToBytesPerSecond * convertGigabitToMegabit * encodingGen3andAbove));
|
||||
int64_t speedPci80 = L0::Sysman::convertPcieSpeedFromGTsToBs(PciLinkSpeeds::Pci8_0GigatransfersPerSecond);
|
||||
EXPECT_EQ(speedPci80, static_cast<int64_t>(PciLinkSpeeds::Pci8_0GigatransfersPerSecond * convertMegabitsPerSecondToBytesPerSecond * convertGigabitToMegabit * encodingGen3andAbove));
|
||||
int64_t speedPci50 = L0::Sysman::convertPcieSpeedFromGTsToBs(PciLinkSpeeds::Pci5_0GigatransfersPerSecond);
|
||||
EXPECT_EQ(speedPci50, static_cast<int64_t>(PciLinkSpeeds::Pci5_0GigatransfersPerSecond * convertMegabitsPerSecondToBytesPerSecond * convertGigabitToMegabit * encodingGen1Gen2));
|
||||
int64_t speedPci25 = L0::Sysman::convertPcieSpeedFromGTsToBs(PciLinkSpeeds::Pci2_5GigatransfersPerSecond);
|
||||
EXPECT_EQ(speedPci25, static_cast<int64_t>(PciLinkSpeeds::Pci2_5GigatransfersPerSecond * convertMegabitsPerSecondToBytesPerSecond * convertGigabitToMegabit * encodingGen1Gen2));
|
||||
EXPECT_EQ(0, L0::Sysman::convertPcieSpeedFromGTsToBs(0.0));
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
Reference in New Issue
Block a user