56 lines
1.9 KiB
C++
56 lines
1.9 KiB
C++
#include <iostream>
|
|
#include <memory>
|
|
#include <sstream>
|
|
#include <iomanip>
|
|
#include "device/PCIEDevice.h"
|
|
#include "fm10k/FM10K.h"
|
|
#include "fm10k/registers/Register.h"
|
|
|
|
template <typename T> std::string tohex(T v){
|
|
std::stringstream o;
|
|
o << std::hex << std::setw(sizeof(v) * 2) << std::setfill('0') << v;
|
|
|
|
return o.str();
|
|
}
|
|
|
|
int main() {
|
|
auto entries = PCIEDevice::DeviceEntry::find();
|
|
|
|
std::cout << "Found " << entries.size() << " FM10K management device(s)." << std::endl;
|
|
|
|
for(auto& entry : entries){
|
|
auto dev = std::make_unique<PCIEDevice>(entry);
|
|
|
|
std::cout << "dev.path: " << dev->getDeviceEntry().getPath() << std::endl;
|
|
std::cout << "dev.vendor: " << tohex(dev->getDeviceEntry().getVendor()) << std::endl;
|
|
std::cout << "dev.class: " << tohex(dev->getDeviceEntry().getClass()) << std::endl;
|
|
|
|
FM10K::FM10K fm10k(std::move(dev));
|
|
|
|
std::cout << "Device Model_Stepping: " << fm10k.getHardwareInformationString() << std::endl;
|
|
|
|
auto fuseData_0 = fm10k.mapRegister<FM10K::registers::MGMT::FUSE_DATA_0>();
|
|
std::cout << "FUSE_DATA_0: " << tohex(fuseData_0->value) << std::endl;
|
|
std::cout << "FUSE_DATA_0.VDDF_VRM: " << FM10K::VR12_VID_to_Millivolts(fuseData_0->fields.VDDS_VRM) << std::endl;
|
|
std::cout << "FUSE_DATA_0.VDDF_VRM: " << FM10K::VR12_VID_to_Millivolts(fuseData_0->fields.VDDF_VRM) << std::endl;
|
|
|
|
auto deviceCfg = fm10k.mapRegister<FM10K::registers::MGMT::DEVICE_CFG>();
|
|
std::cout << "DEVICE_CFG: " << tohex(deviceCfg->value) << std::endl;
|
|
|
|
std::cout << "trying to initialize: ";
|
|
|
|
auto& port = fm10k.addPort(1, 1);
|
|
port.m_portType = Port::PortType::EPL;
|
|
port.m_interfaceType = Port::InterfaceType::QSFP_LANE0;
|
|
|
|
if(fm10k.initializationSequence()){
|
|
std::cout << "success" << std::endl;
|
|
}else{
|
|
std::cout << "fail" << std::endl;
|
|
}
|
|
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|