Skip to content

Commit

Permalink
Refactor: change namespace pci to devices
Browse files Browse the repository at this point in the history
Signed-off-by: Pascal Bauer <[email protected]>
  • Loading branch information
IgnoreWarnings authored and n-eiling committed Aug 29, 2024
1 parent df8c26c commit 38e1199
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 22 deletions.
4 changes: 2 additions & 2 deletions common/include/villas/kernel/devices/pci_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -125,6 +125,6 @@ class PciDeviceList : public std::list<std::shared_ptr<PciDevice>> {
PciDeviceList::value_type lookupDevice(const PciDevice &f);
};

} // namespace pci
} // namespace devices
} // namespace kernel
} // namespace villas
2 changes: 1 addition & 1 deletion common/include/villas/kernel/vfio_container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Container {
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
//
Expand Down
4 changes: 2 additions & 2 deletions common/include/villas/kernel/vfio_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -89,7 +89,7 @@ class Device {
std::vector<void *> mappings;

// libpci handle of the device
const kernel::pci::PciDevice *pci_device;
const kernel::devices::PciDevice *pci_device;

Logger log;
};
Expand Down
2 changes: 1 addition & 1 deletion common/include/villas/kernel/vfio_group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Group {
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();
Expand Down
2 changes: 1 addition & 1 deletion common/lib/kernel/devices/pci_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion common/lib/kernel/vfio_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion common/lib/kernel/vfio_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
2 changes: 1 addition & 1 deletion common/lib/kernel/vfio_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion fpga/include/villas/fpga/pcie_card.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PCIeCard : public Card {
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); }
Expand Down
2 changes: 1 addition & 1 deletion fpga/lib/dma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 7 additions & 6 deletions fpga/lib/pcie_card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion fpga/src/villas-fpga-ctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion fpga/src/villas-fpga-pipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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[]) {
Expand Down
4 changes: 2 additions & 2 deletions fpga/tests/unit/fpga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

using namespace villas;

static kernel::pci::PciDeviceList *pciDevices;
static kernel::devices::PciDeviceList *pciDevices;

FpgaState state;

Expand All @@ -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>();

Expand Down

0 comments on commit 38e1199

Please sign in to comment.