diff --git a/common/include/villas/kernel/vfio_container.hpp b/common/include/villas/kernel/vfio_container.hpp index 14d383fe8..692aaddb8 100644 --- a/common/include/villas/kernel/vfio_container.hpp +++ b/common/include/villas/kernel/vfio_container.hpp @@ -35,7 +35,7 @@ public: { static Container instance; return &instance; - }; + } // No copying allowed Container(Container const&) = delete; @@ -63,7 +63,10 @@ public: bool memoryUnmap(uintptr_t phys, size_t length); bool isIommuEnabled() const - { return this->hasIommu; } + { + return this->hasIommu; + } + private: std::shared_ptr getOrAttachGroup(int index); diff --git a/common/include/villas/kernel/vfio_device.hpp b/common/include/villas/kernel/vfio_device.hpp index dc1a87eac..c6a527c3d 100644 --- a/common/include/villas/kernel/vfio_device.hpp +++ b/common/include/villas/kernel/vfio_device.hpp @@ -36,7 +36,6 @@ namespace vfio { class Device { public: Device(const std::string &name, int groupFileDescriptor, const kernel::pci::Device *pci_device = nullptr); - ~Device(); bool reset(); @@ -61,15 +60,21 @@ public: bool pciHotReset(); int getFileDescriptor() const - { return fd; } + { + return fd; + } void dump(); bool isAttachedToGroup() const - { return attachedToGroup; } + { + return attachedToGroup; + } void setAttachedToGroup() - { this->attachedToGroup = true; } + { + this->attachedToGroup = true; + } private: // Name of the device as listed under diff --git a/common/include/villas/kernel/vfio_group.hpp b/common/include/villas/kernel/vfio_group.hpp index 0c991a890..db0e82312 100644 --- a/common/include/villas/kernel/vfio_group.hpp +++ b/common/include/villas/kernel/vfio_group.hpp @@ -28,20 +28,27 @@ namespace vfio { class Group { public: Group(int index, bool iommuEnabled); - ~Group(); void setAttachedToContainer() - { attachedToContainer = true; }; + { + attachedToContainer = true; + } bool isAttachedToContainer() - { return attachedToContainer; }; + { + return attachedToContainer; + } int getFileDescriptor() - { return fd; }; + { + return fd; + } int getIndex() - { return index; }; + { + return index; + } std::shared_ptr attachDevice(std::shared_ptr device); std::shared_ptr attachDevice(const std::string& name, const kernel::pci::Device *pci_device = nullptr); diff --git a/common/lib/kernel/vfio_container.cpp b/common/lib/kernel/vfio_container.cpp index 9320dbec6..80251bbe5 100644 --- a/common/lib/kernel/vfio_container.cpp +++ b/common/lib/kernel/vfio_container.cpp @@ -90,7 +90,6 @@ Container::Container() : log->debug("IOMMU: {}", hasIommu ? "yes" : "no"); } - Container::~Container() { // Release memory and close fds @@ -154,10 +153,7 @@ std::shared_ptr Container::getOrAttachGroup(int index) return group; } - - -void -Container::dump() +void Container::dump() { log->info("File descriptor: {}", fd); log->info("Version: {}", version); @@ -168,9 +164,7 @@ Container::dump() } } - -std::shared_ptr -Container::attachDevice(const std::string& name, int index) +std::shared_ptr Container::attachDevice(const std::string& name, int index) { auto group = getOrAttachGroup(index); auto device = group->attachDevice(name); @@ -178,9 +172,7 @@ Container::attachDevice(const std::string& name, int index) return device; } - -std::shared_ptr -Container::attachDevice(const pci::Device &pdev) +std::shared_ptr Container::attachDevice(const pci::Device &pdev) { int ret; char name[32], iommu_state[4]; @@ -226,8 +218,7 @@ Container::attachDevice(const pci::Device &pdev) } -uintptr_t -Container::memoryMap(uintptr_t virt, uintptr_t phys, size_t length) +uintptr_t Container::memoryMap(uintptr_t virt, uintptr_t phys, size_t length) { int ret; @@ -274,9 +265,7 @@ Container::memoryMap(uintptr_t virt, uintptr_t phys, size_t length) return dmaMap.iova; } - -bool -Container::memoryUnmap(uintptr_t phys, size_t length) +bool Container::memoryUnmap(uintptr_t phys, size_t length) { int ret; diff --git a/common/lib/kernel/vfio_device.cpp b/common/lib/kernel/vfio_device.cpp index 4f251c86e..d971a2826 100644 --- a/common/lib/kernel/vfio_device.cpp +++ b/common/lib/kernel/vfio_device.cpp @@ -138,9 +138,7 @@ Device::~Device() } } - -bool -Device::reset() +bool Device::reset() { log->debug("Resetting device."); if (this->info.flags & VFIO_DEVICE_FLAGS_RESET) @@ -149,9 +147,7 @@ Device::reset() return false; // not supported by this device } - -void* -Device::regionMap(size_t index) +void * Device::regionMap(size_t index) { struct vfio_region_info *r = ®ions[index]; @@ -171,9 +167,7 @@ Device::regionMap(size_t index) return mappings[index]; } - -bool -Device::regionUnmap(size_t index) +bool Device::regionUnmap(size_t index) { int ret; struct vfio_region_info *r = ®ions[index]; @@ -192,9 +186,7 @@ Device::regionUnmap(size_t index) return true; } - -size_t -Device::regionGetSize(size_t index) +size_t Device::regionGetSize(size_t index) { if (index >= regions.size()) { log->error("Index out of range: {} >= {}", index, regions.size()); @@ -243,8 +235,7 @@ void Device::dump() } } -bool -Device::pciEnable() +bool Device::pciEnable() { int ret; uint32_t reg; @@ -269,9 +260,7 @@ Device::pciEnable() return true; } - -int -Device::pciMsiInit(int efds[]) +int Device::pciMsiInit(int efds[]) { // Check if this is really a vfio-pci device if (not isVfioPciDevice()) @@ -316,9 +305,7 @@ Device::pciMsiInit(int efds[]) return irqCount; } - -int -Device::pciMsiDeinit(int efds[]) +int Device::pciMsiDeinit(int efds[]) { // Check if this is really a vfio-pci device if (not isVfioPciDevice()) @@ -357,9 +344,7 @@ Device::pciMsiDeinit(int efds[]) return irqCount; } - -bool -Device::pciMsiFind(int nos[]) +bool Device::pciMsiFind(int nos[]) { int ret, idx, irq; char *end, *col, *last, line[1024], name[13]; @@ -399,9 +384,7 @@ Device::pciMsiFind(int nos[]) return true; } - -bool -Device::isVfioPciDevice() const +bool Device::isVfioPciDevice() const { return info.flags & VFIO_DEVICE_FLAGS_PCI; } diff --git a/common/lib/kernel/vfio_group.cpp b/common/lib/kernel/vfio_group.cpp index b51cd2ab8..a73cbd0e6 100644 --- a/common/lib/kernel/vfio_group.cpp +++ b/common/lib/kernel/vfio_group.cpp @@ -78,7 +78,6 @@ std::shared_ptr Group::attachDevice(const std::string& name, const kerne return attachDevice(device); } - bool Group::checkStatus() { int ret;