mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
Fix formatting for VFIO changes
Signed-off-by: Steffen Vogel <steffen.vogel@opal-rt.com>
This commit is contained in:
parent
a5ab5ebc65
commit
b359c2715d
5 changed files with 46 additions and 57 deletions
|
@ -10,16 +10,16 @@
|
|||
#define FPGA_PCI
|
||||
|
||||
#if defined(FPGA_PLATFORM)
|
||||
#define KERNEL_MODULE_VFIO
|
||||
#define KERNEL_MODULE_VFIO
|
||||
#endif
|
||||
|
||||
#if defined(FPGA_PCI)
|
||||
#define KERNEL_MODULE_VFIO
|
||||
#define KERNEL_MODULE_VFIO_PCI
|
||||
#define KERNEL_MODULE_VFIO_IOMMU_TYPE1
|
||||
#define KERNEL_MODULE_VFIO
|
||||
#define KERNEL_MODULE_VFIO_PCI
|
||||
#define KERNEL_MODULE_VFIO_IOMMU_TYPE1
|
||||
#endif
|
||||
|
||||
static constexpr const char* const requiredKernelModules[] = {
|
||||
static constexpr const char *const requiredKernelModules[] = {
|
||||
#if defined(KERNEL_MODULE_VFIO)
|
||||
"vfio",
|
||||
#endif // KERNEL_MODULE_VFIO_PCI
|
||||
|
@ -27,7 +27,7 @@ static constexpr const char* const requiredKernelModules[] = {
|
|||
#if defined(KERNEL_MODULE_VFIO_PCI)
|
||||
"vfio_pci",
|
||||
#endif // KERNEL_MODULE_VFIO_PCI
|
||||
|
||||
|
||||
#if defined(KERNEL_MODULE_VFIO_IOMMU_TYPE1)
|
||||
"vfio_iommu_type1"
|
||||
#endif // KERNEL_MODULE_VFIO_IOMMU_TYPE1
|
||||
|
|
|
@ -38,10 +38,10 @@ public:
|
|||
|
||||
bool reset();
|
||||
|
||||
std::string getName() { return name; };
|
||||
std::string getName() { return name; };
|
||||
|
||||
// Map a device memory region to the application address space (e.g. PCI BARs)
|
||||
void* regionMap(size_t index);
|
||||
// Map a device memory region to the application address space (e.g. PCI BARs)
|
||||
void *regionMap(size_t index);
|
||||
|
||||
// munmap() a region which has been mapped by vfio_map_region()
|
||||
bool regionUnmap(size_t index);
|
||||
|
|
|
@ -96,25 +96,20 @@ private:
|
|||
uintptr_t dest; // Base address in "to" address space
|
||||
size_t size; // Size of the mapping
|
||||
|
||||
friend std::ostream&
|
||||
operator<< (std::ostream &stream, const Mapping &mapping)
|
||||
{
|
||||
return stream << static_cast<const Edge&>(mapping) << " = "
|
||||
<< mapping.name
|
||||
<< std::hex
|
||||
<< " (src=0x" << mapping.src
|
||||
<< ", dest=0x" << mapping.dest
|
||||
<< ", size=0x" << mapping.size
|
||||
<< ")";
|
||||
}
|
||||
friend std::ostream &operator<<(std::ostream &stream,
|
||||
const Mapping &mapping) {
|
||||
return stream << static_cast<const Edge &>(mapping) << " = "
|
||||
<< mapping.name << std::hex << " (src=0x" << mapping.src
|
||||
<< ", dest=0x" << mapping.dest << ", size=0x"
|
||||
<< mapping.size << ")";
|
||||
}
|
||||
|
||||
std::string toString()
|
||||
{
|
||||
std::stringstream s;
|
||||
s << *this;
|
||||
return s.str();
|
||||
}
|
||||
};
|
||||
std::string toString() {
|
||||
std::stringstream s;
|
||||
s << *this;
|
||||
return s.str();
|
||||
}
|
||||
};
|
||||
|
||||
// Custom vertex in memory graph representing an address space
|
||||
//
|
||||
|
|
|
@ -31,10 +31,8 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include <villas/exceptions.hpp>
|
||||
#include <villas/log.hpp>
|
||||
#include <villas/kernel/vfio.hpp>
|
||||
#include <villas/kernel/vfio_container.hpp>
|
||||
#include <villas/kernel/kernel.hpp>
|
||||
#include <villas/kernel/vfio.hpp>
|
||||
#include <villas/kernel/vfio_container.hpp>
|
||||
#include <villas/log.hpp>
|
||||
|
||||
|
@ -67,21 +65,16 @@ static std::array<std::string, EXTENSION_SIZE> construct_vfio_extension_str() {
|
|||
static std::array<std::string, EXTENSION_SIZE> VFIO_EXTENSION_STR =
|
||||
construct_vfio_extension_str();
|
||||
|
||||
Container::Container() :
|
||||
fd(-1),
|
||||
version(0),
|
||||
extensions(),
|
||||
iova_next(0),
|
||||
hasIommu(false),
|
||||
groups(),
|
||||
log(logging.get("kernel:vfio:container"))
|
||||
{
|
||||
for (const char* module : requiredKernelModules) {
|
||||
if (kernel::loadModule(module) != 0) {
|
||||
throw RuntimeError("Kernel module '{}' required but could not be loaded. "
|
||||
"Please load manually!", module);
|
||||
}
|
||||
}
|
||||
Container::Container()
|
||||
: fd(-1), version(0), extensions(), iova_next(0), hasIommu(false), groups(),
|
||||
log(logging.get("kernel:vfio:container")) {
|
||||
for (const char *module : requiredKernelModules) {
|
||||
if (kernel::loadModule(module) != 0) {
|
||||
throw RuntimeError("Kernel module '{}' required but could not be loaded. "
|
||||
"Please load manually!",
|
||||
module);
|
||||
}
|
||||
}
|
||||
|
||||
// Create a VFIO Container
|
||||
fd = open(VFIO_DEV, O_RDWR);
|
||||
|
|
|
@ -75,22 +75,21 @@ Device::Device(const std::string &name, int groupFileDescriptor,
|
|||
log->debug("device info: flags: 0x{:x}, num_regions: {}, num_irqs: {}",
|
||||
info.flags, info.num_regions, info.num_irqs);
|
||||
|
||||
if (pci_device != 0) {
|
||||
// device_info.num_region reports always 9 and includes a VGA region, which is only supported on
|
||||
// certain device IDs. So for non-VGA devices VFIO_PCI_CONFIG_REGION_INDEX will be the highest
|
||||
// region index. This is the config space.
|
||||
info.num_regions = VFIO_PCI_CONFIG_REGION_INDEX + 1;
|
||||
} else { info.num_regions = 1; }
|
||||
// device_info.num_region reports always 9 and includes a VGA region, which is only supported on
|
||||
// certain device IDs. So for non-VGA devices VFIO_PCI_CONFIG_REGION_INDEX will be the highest
|
||||
// region index. This is the config space.
|
||||
info.num_regions =
|
||||
pci_device != 0 ? VFIO_PCI_CONFIG_REGION_INDEX + 1 : 1;
|
||||
|
||||
// Reserve slots already so that we can use the []-operator for access
|
||||
irqs.resize(info.num_irqs);
|
||||
regions.resize(info.num_regions);
|
||||
mappings.resize(info.num_regions);
|
||||
|
||||
// Get device regions
|
||||
for (size_t i = 0; i < info.num_regions; i++) {
|
||||
struct vfio_region_info region;
|
||||
memset(®ion, 0, sizeof (region));
|
||||
// Get device regions
|
||||
for (size_t i = 0; i < info.num_regions; i++) {
|
||||
struct vfio_region_info region;
|
||||
memset(®ion, 0, sizeof(region));
|
||||
|
||||
region.argsz = sizeof(region);
|
||||
region.index = i;
|
||||
|
@ -99,8 +98,10 @@ Device::Device(const std::string &name, int groupFileDescriptor,
|
|||
if (ret < 0)
|
||||
throw RuntimeError("Failed to get region {} of VFIO device: {}", i, name);
|
||||
|
||||
log->debug("region {} info: flags: 0x{:x}, cap_offset: 0x{:x}, size: 0x{:x}, offset: 0x{:x}",
|
||||
region.index, region.flags, region.cap_offset, region.size, region.offset);
|
||||
log->debug("region {} info: flags: 0x{:x}, cap_offset: 0x{:x}, size: "
|
||||
"0x{:x}, offset: 0x{:x}",
|
||||
region.index, region.flags, region.cap_offset, region.size,
|
||||
region.offset);
|
||||
|
||||
regions[i] = region;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue