diff --git a/common/include/villas/kernel/pci.hpp b/common/include/villas/kernel/pci.hpp index 0e9f7a35c..3f8eba971 100644 --- a/common/include/villas/kernel/pci.hpp +++ b/common/include/villas/kernel/pci.hpp @@ -107,11 +107,16 @@ protected: }; class DeviceList : public std::list> { -public: +private: // Initialize Linux PCI handle. // // This search for all available PCI devices under /sys/bus/pci DeviceList(); + DeviceList &operator=(const DeviceList &); + static DeviceList *instance; + +public: + static DeviceList *getInstance(); DeviceList::value_type lookupDevice(const Slot &s); diff --git a/common/include/villas/kernel/vfio_device.hpp b/common/include/villas/kernel/vfio_device.hpp index b94b26caf..9f8c51a7c 100644 --- a/common/include/villas/kernel/vfio_device.hpp +++ b/common/include/villas/kernel/vfio_device.hpp @@ -60,6 +60,7 @@ public: bool pciHotReset(); int getFileDescriptor() const { return fd; } + std::vector &getEventfdList() { return eventfdList; } void dump(); @@ -78,6 +79,9 @@ private: bool attachedToGroup; int groupFd; + // Interrupt eventfds + std::vector eventfdList; + struct vfio_device_info info; std::vector irqs; diff --git a/common/lib/kernel/pci.cpp b/common/lib/kernel/pci.cpp index b0fd260fe..05ee61fba 100644 --- a/common/lib/kernel/pci.cpp +++ b/common/lib/kernel/pci.cpp @@ -25,6 +25,15 @@ using namespace villas::kernel::pci; #define PCI_BASE_ADDRESS_N(n) (PCI_BASE_ADDRESS_0 + sizeof(uint32_t) * (n)) +DeviceList *DeviceList::instance = nullptr; + +DeviceList *DeviceList::getInstance() { + if (instance == nullptr) { + instance = new DeviceList(); + } + return instance; +}; + DeviceList::DeviceList() { struct dirent *e; DIR *dp; diff --git a/common/lib/kernel/vfio_device.cpp b/common/lib/kernel/vfio_device.cpp index 8b574b55b..2344098a7 100644 --- a/common/lib/kernel/vfio_device.cpp +++ b/common/lib/kernel/vfio_device.cpp @@ -277,6 +277,7 @@ int Device::pciMsiInit(int efds[]) { delete[] irqSetBuf; return -1; } + eventfdList.push_back(efds[i]); } memcpy(irqSet->data, efds, sizeof(int) * irqCount);