1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

general code-style fixes

Signed-off-by: Steffen Vogel <post@steffenvogel.de>
This commit is contained in:
Steffen Vogel 2022-12-02 16:42:36 +01:00
parent 013e07b9ba
commit fbfbf578bf
6 changed files with 40 additions and 54 deletions

View file

@ -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<Group> getOrAttachGroup(int index);

View file

@ -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

View file

@ -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<Device> attachDevice(std::shared_ptr<Device> device);
std::shared_ptr<Device> attachDevice(const std::string& name, const kernel::pci::Device *pci_device = nullptr);

View file

@ -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<Group> 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<Device>
Container::attachDevice(const std::string& name, int index)
std::shared_ptr<Device> 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<Device>
Container::attachDevice(const pci::Device &pdev)
std::shared_ptr<Device> 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;

View file

@ -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 = &regions[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 = &regions[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;
}

View file

@ -78,7 +78,6 @@ std::shared_ptr<Device> Group::attachDevice(const std::string& name, const kerne
return attachDevice(device);
}
bool Group::checkStatus()
{
int ret;