diff --git a/common/include/villas/kernel/devices/pci_device.hpp b/common/include/villas/kernel/devices/pci_device.hpp index 8d792d7cc..e71fa4ecc 100644 --- a/common/include/villas/kernel/devices/pci_device.hpp +++ b/common/include/villas/kernel/devices/pci_device.hpp @@ -58,15 +58,15 @@ struct Region { unsigned long long flags; }; -class Device { +class PciDevice { public: - Device(Id i, Slot s) : id(i), slot(s), log(Log::get("kernel:pci")) {} + PciDevice(Id i, Slot s) : id(i), slot(s), log(Log::get("kernel:pci")) {} - Device(Id i) : id(i), log(Log::get("kernel:pci")) {} + PciDevice(Id i) : id(i), log(Log::get("kernel:pci")) {} - Device(Slot s) : slot(s), log(Log::get("kernel:pci")) {} + PciDevice(Slot s) : slot(s), log(Log::get("kernel:pci")) {} - bool operator==(const Device &other); + bool operator==(const PciDevice &other); // Get currently loaded driver for device std::string getDriver() const; @@ -106,7 +106,7 @@ protected: std::ios_base::out) const; }; -class DeviceList : public std::list> { +class DeviceList : public std::list> { private: // Initialize Linux PCI handle. // @@ -122,7 +122,7 @@ public: DeviceList::value_type lookupDevice(const Id &i); - DeviceList::value_type lookupDevice(const Device &f); + DeviceList::value_type lookupDevice(const PciDevice &f); }; } // namespace pci diff --git a/common/include/villas/kernel/vfio_container.hpp b/common/include/villas/kernel/vfio_container.hpp index 2e0ffaf97..fedb36436 100644 --- a/common/include/villas/kernel/vfio_container.hpp +++ b/common/include/villas/kernel/vfio_container.hpp @@ -49,7 +49,7 @@ public: std::shared_ptr getOrAttachGroup(int index); std::shared_ptr attachDevice(const std::string &name, int groupIndex); - std::shared_ptr attachDevice(pci::Device &pdev); + std::shared_ptr attachDevice(pci::PciDevice &pdev); // Map VM to an IOVA, which is accessible by devices in the container // diff --git a/common/include/villas/kernel/vfio_device.hpp b/common/include/villas/kernel/vfio_device.hpp index ce291bc27..a7805f6ad 100644 --- a/common/include/villas/kernel/vfio_device.hpp +++ b/common/include/villas/kernel/vfio_device.hpp @@ -29,7 +29,7 @@ namespace vfio { class Device { public: Device(const std::string &name, int groupFileDescriptor, - const kernel::pci::Device *pci_device = nullptr); + const kernel::pci::PciDevice *pci_device = nullptr); ~Device(); // No copying allowed because we manage the vfio state in constructor and destructors @@ -89,7 +89,7 @@ private: std::vector mappings; // libpci handle of the device - const kernel::pci::Device *pci_device; + const kernel::pci::PciDevice *pci_device; Logger log; }; diff --git a/common/include/villas/kernel/vfio_group.hpp b/common/include/villas/kernel/vfio_group.hpp index 7c4fca580..87b82901f 100644 --- a/common/include/villas/kernel/vfio_group.hpp +++ b/common/include/villas/kernel/vfio_group.hpp @@ -48,7 +48,7 @@ public: std::shared_ptr attachDevice(std::shared_ptr device); std::shared_ptr attachDevice(const std::string &name, - const kernel::pci::Device *pci_device = nullptr); + const kernel::pci::PciDevice *pci_device = nullptr); bool checkStatus(); void dump(); diff --git a/common/lib/kernel/devices/pci_device.cpp b/common/lib/kernel/devices/pci_device.cpp index baf385072..86f062114 100644 --- a/common/lib/kernel/devices/pci_device.cpp +++ b/common/lib/kernel/devices/pci_device.cpp @@ -82,7 +82,7 @@ DeviceList::DeviceList() { if (ret != 4) throw RuntimeError("Failed to parse PCI slot number: {}", e->d_name); - emplace_back(std::make_shared(id, slot)); + emplace_back(std::make_shared(id, slot)); } closedir(dp); @@ -100,7 +100,7 @@ DeviceList::value_type DeviceList::lookupDevice(const Id &i) { }); } -DeviceList::value_type DeviceList::lookupDevice(const Device &d) { +DeviceList::value_type DeviceList::lookupDevice(const PciDevice &d) { auto dev = std::find_if( begin(), end(), [d](const DeviceList::value_type &e) { return *e == d; }); @@ -247,11 +247,11 @@ bool Slot::operator==(const Slot &s) { return true; } -bool Device::operator==(const Device &f) { +bool PciDevice::operator==(const PciDevice &f) { return id == f.id && slot == f.slot; } -std::list Device::getRegions() const { +std::list PciDevice::getRegions() const { FILE *f; char sysfs[1024]; @@ -311,7 +311,7 @@ std::list Device::getRegions() const { return regions; } -std::string Device::getDriver() const { +std::string PciDevice::getDriver() const { int ret; char sysfs[1024], syml[1024]; memset(syml, 0, sizeof(syml)); @@ -331,7 +331,7 @@ std::string Device::getDriver() const { return basename(syml); } -bool Device::attachDriver(const std::string &driver) const { +bool PciDevice::attachDriver(const std::string &driver) const { FILE *f; char fn[1024]; @@ -363,7 +363,7 @@ bool Device::attachDriver(const std::string &driver) const { return true; } -uint32_t Device::readHostBar(unsigned barNum) const { +uint32_t PciDevice::readHostBar(unsigned barNum) const { auto file = openSysFs("resource", std::ios_base::in); std::string line; @@ -389,7 +389,7 @@ uint32_t Device::readHostBar(unsigned barNum) const { return start; } -void Device::rewriteBar(unsigned barNum) { +void PciDevice::rewriteBar(unsigned barNum) { auto hostBar = readHostBar(barNum); auto configBar = readBar(barNum); @@ -405,7 +405,7 @@ void Device::rewriteBar(unsigned barNum) { writeBar(hostBar, barNum); } -uint32_t Device::readBar(unsigned barNum) const { +uint32_t PciDevice::readBar(unsigned barNum) const { uint32_t addr; auto file = openSysFs("config", std::ios_base::in); @@ -415,14 +415,14 @@ uint32_t Device::readBar(unsigned barNum) const { return addr; } -void Device::writeBar(uint32_t addr, unsigned barNum) { +void PciDevice::writeBar(uint32_t addr, unsigned barNum) { auto file = openSysFs("config", std::ios_base::out); file.seekp(PCI_BASE_ADDRESS_N(barNum)); file.write(reinterpret_cast(&addr), sizeof(addr)); } -int Device::getIommuGroup() const { +int PciDevice::getIommuGroup() const { int ret; char *group; @@ -443,7 +443,7 @@ int Device::getIommuGroup() const { return atoi(group); } -std::fstream Device::openSysFs(const std::string &subPath, +std::fstream PciDevice::openSysFs(const std::string &subPath, std::ios_base::openmode mode) const { std::fstream file; diff --git a/common/lib/kernel/vfio_container.cpp b/common/lib/kernel/vfio_container.cpp index 7b67035f1..49d499a26 100644 --- a/common/lib/kernel/vfio_container.cpp +++ b/common/lib/kernel/vfio_container.cpp @@ -187,7 +187,7 @@ std::shared_ptr Container::attachDevice(const std::string &name, return device; } -std::shared_ptr Container::attachDevice(pci::Device &pdev) { +std::shared_ptr Container::attachDevice(pci::PciDevice &pdev) { int ret; char name[32], iommu_state[4]; static constexpr const char *kernelDriver = "vfio-pci"; diff --git a/common/lib/kernel/vfio_device.cpp b/common/lib/kernel/vfio_device.cpp index 160cff71d..601b4d47f 100644 --- a/common/lib/kernel/vfio_device.cpp +++ b/common/lib/kernel/vfio_device.cpp @@ -53,7 +53,7 @@ static const char *vfio_pci_irq_names[] = { }; Device::Device(const std::string &name, int groupFileDescriptor, - const kernel::pci::Device *pci_device) + const kernel::pci::PciDevice *pci_device) : name(name), fd(-1), attachedToGroup(false), groupFd(groupFileDescriptor), info(), irqs(), regions(), mappings(), pci_device(pci_device), log(Log::get("kernel:vfio:device")) { diff --git a/common/lib/kernel/vfio_group.cpp b/common/lib/kernel/vfio_group.cpp index 56591bb9f..7b01dea08 100644 --- a/common/lib/kernel/vfio_group.cpp +++ b/common/lib/kernel/vfio_group.cpp @@ -68,7 +68,7 @@ std::shared_ptr Group::attachDevice(std::shared_ptr device) { std::shared_ptr Group::attachDevice(const std::string &name, - const kernel::pci::Device *pci_device) { + const kernel::pci::PciDevice *pci_device) { auto device = std::make_shared(name, fd, pci_device); return attachDevice(device); } diff --git a/fpga/include/villas/fpga/pcie_card.hpp b/fpga/include/villas/fpga/pcie_card.hpp index d3ba2f54a..3aaaaf100 100644 --- a/fpga/include/villas/fpga/pcie_card.hpp +++ b/fpga/include/villas/fpga/pcie_card.hpp @@ -55,7 +55,7 @@ public: // TODO: make this private bool doReset; // Reset VILLASfpga during startup? int affinity; // Affinity for MSI interrupts - std::shared_ptr pdev; // PCI device handle + std::shared_ptr pdev; // PCI device handle protected: Logger getLogger() const { return villas::Log::get(name); } diff --git a/fpga/lib/pcie_card.cpp b/fpga/lib/pcie_card.cpp index f44026fd6..6a7f7b008 100644 --- a/fpga/lib/pcie_card.cpp +++ b/fpga/lib/pcie_card.cpp @@ -24,7 +24,7 @@ using namespace villas::fpga; // Instantiate factory to register static PCIeCardFactory PCIeCardFactoryInstance; -static const kernel::pci::Device +static const kernel::pci::PciDevice defaultFilter((kernel::pci::Id(FPGA_PCI_VID_XILINX, FPGA_PCI_PID_VFPGA))); std::shared_ptr @@ -63,7 +63,7 @@ PCIeCardFactory::make(json_t *json_card, std::string card_name, card->doReset = do_reset != 0; card->polling = (polling != 0); - kernel::pci::Device filter = defaultFilter; + kernel::pci::PciDevice filter = defaultFilter; if (pci_id) filter.id = kernel::pci::Id(pci_id);