Skip to content

Commit 22891bd

Browse files
gangdeng-intelrdementi
authored andcommitted
For issue#547: add support QAT in-tree driver
1 parent 1322f3d commit 22891bd

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

src/cpucounters.cpp

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ class QATTelemetryVirtualGeneralConfigRegister : public HWRegister
921921
operation = PCM::IDX_OPERATION(val);
922922
#ifdef __linux__
923923
std::ostringstream sysfs_path(std::ostringstream::out);
924+
std::string telemetry_filename;
924925
switch (operation)
925926
{
926927
case PCM::QAT_TLM_START: //enable
@@ -936,6 +937,18 @@ class QATTelemetryVirtualGeneralConfigRegister : public HWRegister
936937
std::hex << std::setw(2) << std::setfill('0') << d << "." <<
937938
std::hex << f << "/telemetry/control";
938939

940+
/*check telemetry for out-of tree driver*/
941+
telemetry_filename = readSysFS(sysfs_path.str().c_str(), true);
942+
if(!telemetry_filename.size()){
943+
/*is not oot driver, check telemetry for in tree driver (since kernel 6.8)*/
944+
sysfs_path.str("");
945+
sysfs_path << std::string("/sys/kernel/debug/qat_4xxx_") <<
946+
std::hex << std::setw(4) << std::setfill('0') << domain << ":" <<
947+
std::hex << std::setw(2) << std::setfill('0') << b << ":" <<
948+
std::hex << std::setw(2) << std::setfill('0') << d << "." <<
949+
std::hex << f << "/telemetry/control";
950+
}
951+
939952
if (writeSysFS(sysfs_path.str().c_str(), (operation == PCM::QAT_TLM_START ? "1" : "0")) == false)
940953
{
941954
std::cerr << "Linux sysfs: Error on control QAT telemetry operation = " << operation << ".\n";
@@ -951,7 +964,17 @@ class QATTelemetryVirtualGeneralConfigRegister : public HWRegister
951964
std::hex << std::setw(2) << std::setfill('0') << b << ":" <<
952965
std::hex << std::setw(2) << std::setfill('0') << d << "." <<
953966
std::hex << f << "/telemetry/device_data";
954-
967+
/*check telemetry for out-of tree driver*/
968+
telemetry_filename = readSysFS(sysfs_path.str().c_str(), true);
969+
if(!telemetry_filename.size()){
970+
/*is not oot driver, check telemetry for in tree driver (since kernel 6.8)*/
971+
sysfs_path.str("");
972+
sysfs_path << std::string("/sys/kernel/debug/qat_4xxx_") <<
973+
std::hex << std::setw(4) << std::setfill('0') << domain << ":" <<
974+
std::hex << std::setw(2) << std::setfill('0') << b << ":" <<
975+
std::hex << std::setw(2) << std::setfill('0') << d << "." <<
976+
std::hex << f << "/telemetry/device_data";
977+
}
955978
data_cache.clear();
956979
readMapFromSysFS(sysfs_path.str().c_str(), data_cache);
957980
}
@@ -2382,17 +2405,28 @@ void PCM::initUncorePMUsDirect()
23822405
for (auto & devInfo : devInfos)
23832406
{
23842407
std::ostringstream qat_TLMCTL_sysfs_path(std::ostringstream::out);
2408+
/*parse telemetry follow rule of out of tree driver*/
23852409
qat_TLMCTL_sysfs_path << std::string("/sys/bus/pci/devices/") <<
23862410
std::hex << std::setw(4) << std::setfill('0') << devInfo.domain << ":" <<
23872411
std::hex << std::setw(2) << std::setfill('0') << devInfo.bus << ":" <<
23882412
std::hex << std::setw(2) << std::setfill('0') << devInfo.dev << "." <<
23892413
std::hex << devInfo.func << "/telemetry/control";
2390-
const std::string qatTLMCTLStr = readSysFS(qat_TLMCTL_sysfs_path.str().c_str(), true);
2414+
std::string qatTLMCTLStr = readSysFS(qat_TLMCTL_sysfs_path.str().c_str(), true);
23912415
if (!qatTLMCTLStr.size()) //check TLM feature available or NOT.
23922416
{
2393-
std::cout << "Warning: IDX - QAT telemetry feature of B:0x" << std::hex << devInfo.bus << ",D:0x" << devInfo.dev << ",F:0x" << devInfo.func \
2394-
<< " is NOT available, skipped." << std::dec << std::endl;
2395-
continue;
2417+
qat_TLMCTL_sysfs_path.str("");
2418+
/*parse telemetry follow rule of in tree driver*/
2419+
qat_TLMCTL_sysfs_path << std::string("/sys/kernel/debug/qat_4xxx_") <<
2420+
std::hex << std::setw(4) << std::setfill('0') << devInfo.domain << ":" <<
2421+
std::hex << std::setw(2) << std::setfill('0') << devInfo.bus << ":" <<
2422+
std::hex << std::setw(2) << std::setfill('0') << devInfo.dev << "." <<
2423+
std::hex << devInfo.func << "/telemetry/control";
2424+
qatTLMCTLStr = readSysFS(qat_TLMCTL_sysfs_path.str().c_str(), true);
2425+
if(!qatTLMCTLStr.size()){
2426+
std::cout << "Warning: IDX - QAT telemetry feature of B:0x" << std::hex << devInfo.bus << ",D:0x" << devInfo.dev << ",F:0x" << devInfo.func \
2427+
<< " is NOT available, skipped." << std::dec << std::endl;
2428+
continue;
2429+
}
23962430
}
23972431
idxPMUs[IDX_QAT].push_back(createQATPMU(devInfo.numa_node, devInfo.socket_id, devInfo.domain , devInfo.bus, devInfo.dev , devInfo.func));
23982432
}

0 commit comments

Comments
 (0)