1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-23 00:00:01 +01:00
VILLASnode/common/include/villas/kernel/vfio_group.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

80 lines
1.5 KiB
C++
Raw Normal View History

/** Virtual Function IO wrapper around kernel API
*
* @file
* @author Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
* @author Steffen Vogel <svogel2@eonerc.rwth-aachen.de>
* @author Daniel Krebs <github@daniel-krebs.net>
* @copyright 2022, Niklas Eiling
* @copyright 2014-2021, Steffen Vogel
* @copyright 2018, Daniel Krebs
*********************************************************************************/
#pragma once
#include <list>
#include <vector>
#include <memory>
#include <linux/vfio.h>
#include <sys/mman.h>
#include <villas/kernel/vfio_device.hpp>
#include <villas/log.hpp>
namespace villas {
namespace kernel {
namespace vfio {
class Group {
public:
Group(int index, bool iommuEnabled);
~Group();
void setAttachedToContainer()
{
attachedToContainer = true;
}
bool isAttachedToContainer()
{
return attachedToContainer;
}
int getFileDescriptor()
{
return fd;
}
int getIndex()
{
return index;
}
std::shared_ptr<Device> attachDevice(std::shared_ptr<Device> device);
std::shared_ptr<Device> attachDevice(const std::string& name, const kernel::pci::Device *pci_device = nullptr);
bool checkStatus();
void dump();
private:
// VFIO group file descriptor
int fd;
// Index of the IOMMU group as listed under /sys/kernel/iommu_groups/
int index;
bool attachedToContainer;
// Status of group
struct vfio_group_status status;
// All devices owned by this group
std::list<std::shared_ptr<Device>> devices;
Logger log;
};
} // namespace vfio
} // namespace kernel
} // namespace villas