mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
Refactor: change namespace pci to devices
Signed-off-by: Pascal Bauer <pascal.bauer@rwth-aachen.de>
This commit is contained in:
parent
c41f91f1ca
commit
83e95f88a5
14 changed files with 23 additions and 22 deletions
|
@ -17,7 +17,7 @@
|
|||
|
||||
namespace villas {
|
||||
namespace kernel {
|
||||
namespace pci {
|
||||
namespace devices {
|
||||
|
||||
#define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f)
|
||||
#define PCI_FUNC(devfn) ((devfn) & 0x07)
|
||||
|
@ -125,6 +125,6 @@ public:
|
|||
PciDeviceList::value_type lookupDevice(const PciDevice &f);
|
||||
};
|
||||
|
||||
} // namespace pci
|
||||
} // namespace devices
|
||||
} // namespace kernel
|
||||
} // namespace villas
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
std::shared_ptr<Group> getOrAttachGroup(int index);
|
||||
|
||||
std::shared_ptr<Device> attachDevice(const std::string &name, int groupIndex);
|
||||
std::shared_ptr<Device> attachDevice(pci::PciDevice &pdev);
|
||||
std::shared_ptr<Device> attachDevice(devices::PciDevice &pdev);
|
||||
|
||||
// Map VM to an IOVA, which is accessible by devices in the container
|
||||
//
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace vfio {
|
|||
class Device {
|
||||
public:
|
||||
Device(const std::string &name, int groupFileDescriptor,
|
||||
const kernel::pci::PciDevice *pci_device = nullptr);
|
||||
const kernel::devices::PciDevice *pci_device = nullptr);
|
||||
~Device();
|
||||
|
||||
// No copying allowed because we manage the vfio state in constructor and destructors
|
||||
|
@ -89,7 +89,7 @@ private:
|
|||
std::vector<void *> mappings;
|
||||
|
||||
// libpci handle of the device
|
||||
const kernel::pci::PciDevice *pci_device;
|
||||
const kernel::devices::PciDevice *pci_device;
|
||||
|
||||
Logger log;
|
||||
};
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
std::shared_ptr<Device> attachDevice(std::shared_ptr<Device> device);
|
||||
std::shared_ptr<Device>
|
||||
attachDevice(const std::string &name,
|
||||
const kernel::pci::PciDevice *pci_device = nullptr);
|
||||
const kernel::devices::PciDevice *pci_device = nullptr);
|
||||
|
||||
bool checkStatus();
|
||||
void dump();
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <villas/kernel/devices/pci_device.hpp>
|
||||
#include <villas/utils.hpp>
|
||||
|
||||
using namespace villas::kernel::pci;
|
||||
using namespace villas::kernel::devices;
|
||||
|
||||
#define PCI_BASE_ADDRESS_N(n) (PCI_BASE_ADDRESS_0 + sizeof(uint32_t) * (n))
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@ std::shared_ptr<Device> Container::attachDevice(const std::string &name,
|
|||
return device;
|
||||
}
|
||||
|
||||
std::shared_ptr<Device> Container::attachDevice(pci::PciDevice &pdev) {
|
||||
std::shared_ptr<Device> Container::attachDevice(devices::PciDevice &pdev) {
|
||||
int ret;
|
||||
char name[32], iommu_state[4];
|
||||
static constexpr const char *kernelDriver = "vfio-pci";
|
||||
|
|
|
@ -53,7 +53,7 @@ static const char *vfio_pci_irq_names[] = {
|
|||
};
|
||||
|
||||
Device::Device(const std::string &name, int groupFileDescriptor,
|
||||
const kernel::pci::PciDevice *pci_device)
|
||||
const kernel::devices::PciDevice *pci_device)
|
||||
: name(name), fd(-1), attachedToGroup(false), groupFd(groupFileDescriptor),
|
||||
info(), irqs(), regions(), mappings(), pci_device(pci_device),
|
||||
log(Log::get("kernel:vfio:device")) {
|
||||
|
|
|
@ -68,7 +68,7 @@ std::shared_ptr<Device> Group::attachDevice(std::shared_ptr<Device> device) {
|
|||
|
||||
std::shared_ptr<Device>
|
||||
Group::attachDevice(const std::string &name,
|
||||
const kernel::pci::PciDevice *pci_device) {
|
||||
const kernel::devices::PciDevice *pci_device) {
|
||||
auto device = std::make_shared<Device>(name, fd, pci_device);
|
||||
return attachDevice(device);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public: // TODO: make this private
|
|||
bool doReset; // Reset VILLASfpga during startup?
|
||||
int affinity; // Affinity for MSI interrupts
|
||||
|
||||
std::shared_ptr<kernel::pci::PciDevice> pdev; // PCI device handle
|
||||
std::shared_ptr<kernel::devices::PciDevice> pdev; // PCI device handle
|
||||
|
||||
protected:
|
||||
Logger getLogger() const { return villas::Log::get(name); }
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
using namespace villas;
|
||||
|
||||
static std::shared_ptr<kernel::pci::PciDeviceList> pciDevices;
|
||||
static std::shared_ptr<kernel::devices::PciDeviceList> pciDevices;
|
||||
static auto logger = villas::Log::get("villasfpga_dma");
|
||||
|
||||
struct villasfpga_handle_t {
|
||||
|
|
|
@ -24,8 +24,8 @@ using namespace villas::fpga;
|
|||
// Instantiate factory to register
|
||||
static PCIeCardFactory PCIeCardFactoryInstance;
|
||||
|
||||
static const kernel::pci::PciDevice
|
||||
defaultFilter((kernel::pci::Id(FPGA_PCI_VID_XILINX, FPGA_PCI_PID_VFPGA)));
|
||||
static const kernel::devices::PciDevice defaultFilter(
|
||||
(kernel::devices::Id(FPGA_PCI_VID_XILINX, FPGA_PCI_PID_VFPGA)));
|
||||
|
||||
std::shared_ptr<PCIeCard>
|
||||
PCIeCardFactory::make(json_t *json_card, std::string card_name,
|
||||
|
@ -63,15 +63,16 @@ PCIeCardFactory::make(json_t *json_card, std::string card_name,
|
|||
card->doReset = do_reset != 0;
|
||||
card->polling = (polling != 0);
|
||||
|
||||
kernel::pci::PciDevice filter = defaultFilter;
|
||||
kernel::devices::PciDevice filter = defaultFilter;
|
||||
|
||||
if (pci_id)
|
||||
filter.id = kernel::pci::Id(pci_id);
|
||||
filter.id = kernel::devices::Id(pci_id);
|
||||
if (pci_slot)
|
||||
filter.slot = kernel::pci::Slot(pci_slot);
|
||||
filter.slot = kernel::devices::Slot(pci_slot);
|
||||
|
||||
// Search for FPGA card
|
||||
card->pdev = kernel::pci::PciDeviceList::getInstance()->lookupDevice(filter);
|
||||
card->pdev =
|
||||
kernel::devices::PciDeviceList::getInstance()->lookupDevice(filter);
|
||||
if (!card->pdev) {
|
||||
logger->warn("Failed to find PCI device");
|
||||
return nullptr;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
using namespace villas;
|
||||
|
||||
static std::shared_ptr<kernel::pci::PciDeviceList> pciDevices;
|
||||
static std::shared_ptr<kernel::devices::PciDeviceList> pciDevices;
|
||||
static auto logger = villas::Log::get("ctrl");
|
||||
|
||||
void writeToDmaFromStdIn(std::shared_ptr<villas::fpga::ip::Dma> dma) {
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
using namespace villas;
|
||||
|
||||
static std::shared_ptr<kernel::pci::PciDeviceList> pciDevices;
|
||||
static std::shared_ptr<kernel::devices::PciDeviceList> pciDevices;
|
||||
static auto logger = villas::Log::get("streamer");
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
using namespace villas;
|
||||
|
||||
static kernel::pci::PciDeviceList *pciDevices;
|
||||
static kernel::devices::PciDeviceList *pciDevices;
|
||||
|
||||
FpgaState state;
|
||||
|
||||
|
@ -40,7 +40,7 @@ static void init() {
|
|||
|
||||
plugin::registry->dump();
|
||||
|
||||
pciDevices = kernel::pci::PciDeviceList::getInstance();
|
||||
pciDevices = kernel::devices::PciDeviceList::getInstance();
|
||||
|
||||
auto vfioContainer = std::make_shared<kernel::vfio::Container>();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue