Skip to content

Commit 242edf1

Browse files
Refactor: rename pci class to pci_device
Signed-off-by: Pascal Bauer <pascal.bauer@rwth-aachen.de>
1 parent b6c9271 commit 242edf1

10 files changed

Lines changed: 29 additions & 29 deletions

File tree

common/include/villas/kernel/devices/pci_device.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ struct Region {
5858
unsigned long long flags;
5959
};
6060

61-
class Device {
61+
class PciDevice {
6262
public:
63-
Device(Id i, Slot s) : id(i), slot(s), log(Log::get("kernel:pci")) {}
63+
PciDevice(Id i, Slot s) : id(i), slot(s), log(Log::get("kernel:pci")) {}
6464

65-
Device(Id i) : id(i), log(Log::get("kernel:pci")) {}
65+
PciDevice(Id i) : id(i), log(Log::get("kernel:pci")) {}
6666

67-
Device(Slot s) : slot(s), log(Log::get("kernel:pci")) {}
67+
PciDevice(Slot s) : slot(s), log(Log::get("kernel:pci")) {}
6868

69-
bool operator==(const Device &other);
69+
bool operator==(const PciDevice &other);
7070

7171
// Get currently loaded driver for device
7272
std::string getDriver() const;
@@ -106,7 +106,7 @@ class Device {
106106
std::ios_base::out) const;
107107
};
108108

109-
class DeviceList : public std::list<std::shared_ptr<Device>> {
109+
class DeviceList : public std::list<std::shared_ptr<PciDevice>> {
110110
private:
111111
// Initialize Linux PCI handle.
112112
//
@@ -122,7 +122,7 @@ class DeviceList : public std::list<std::shared_ptr<Device>> {
122122

123123
DeviceList::value_type lookupDevice(const Id &i);
124124

125-
DeviceList::value_type lookupDevice(const Device &f);
125+
DeviceList::value_type lookupDevice(const PciDevice &f);
126126
};
127127

128128
} // namespace pci

common/include/villas/kernel/vfio_container.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Container {
4949
std::shared_ptr<Group> getOrAttachGroup(int index);
5050

5151
std::shared_ptr<Device> attachDevice(const std::string &name, int groupIndex);
52-
std::shared_ptr<Device> attachDevice(pci::Device &pdev);
52+
std::shared_ptr<Device> attachDevice(pci::PciDevice &pdev);
5353

5454
// Map VM to an IOVA, which is accessible by devices in the container
5555
//

common/include/villas/kernel/vfio_device.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace vfio {
2929
class Device {
3030
public:
3131
Device(const std::string &name, int groupFileDescriptor,
32-
const kernel::pci::Device *pci_device = nullptr);
32+
const kernel::pci::PciDevice *pci_device = nullptr);
3333
~Device();
3434

3535
// No copying allowed because we manage the vfio state in constructor and destructors
@@ -89,7 +89,7 @@ class Device {
8989
std::vector<void *> mappings;
9090

9191
// libpci handle of the device
92-
const kernel::pci::Device *pci_device;
92+
const kernel::pci::PciDevice *pci_device;
9393

9494
Logger log;
9595
};

common/include/villas/kernel/vfio_group.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Group {
4848
std::shared_ptr<Device> attachDevice(std::shared_ptr<Device> device);
4949
std::shared_ptr<Device>
5050
attachDevice(const std::string &name,
51-
const kernel::pci::Device *pci_device = nullptr);
51+
const kernel::pci::PciDevice *pci_device = nullptr);
5252

5353
bool checkStatus();
5454
void dump();

common/lib/kernel/devices/pci_device.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ DeviceList::DeviceList() {
8282
if (ret != 4)
8383
throw RuntimeError("Failed to parse PCI slot number: {}", e->d_name);
8484

85-
emplace_back(std::make_shared<Device>(id, slot));
85+
emplace_back(std::make_shared<PciDevice>(id, slot));
8686
}
8787

8888
closedir(dp);
@@ -100,7 +100,7 @@ DeviceList::value_type DeviceList::lookupDevice(const Id &i) {
100100
});
101101
}
102102

103-
DeviceList::value_type DeviceList::lookupDevice(const Device &d) {
103+
DeviceList::value_type DeviceList::lookupDevice(const PciDevice &d) {
104104
auto dev = std::find_if(
105105
begin(), end(), [d](const DeviceList::value_type &e) { return *e == d; });
106106

@@ -247,11 +247,11 @@ bool Slot::operator==(const Slot &s) {
247247
return true;
248248
}
249249

250-
bool Device::operator==(const Device &f) {
250+
bool PciDevice::operator==(const PciDevice &f) {
251251
return id == f.id && slot == f.slot;
252252
}
253253

254-
std::list<Region> Device::getRegions() const {
254+
std::list<Region> PciDevice::getRegions() const {
255255
FILE *f;
256256
char sysfs[1024];
257257

@@ -311,7 +311,7 @@ std::list<Region> Device::getRegions() const {
311311
return regions;
312312
}
313313

314-
std::string Device::getDriver() const {
314+
std::string PciDevice::getDriver() const {
315315
int ret;
316316
char sysfs[1024], syml[1024];
317317
memset(syml, 0, sizeof(syml));
@@ -331,7 +331,7 @@ std::string Device::getDriver() const {
331331
return basename(syml);
332332
}
333333

334-
bool Device::attachDriver(const std::string &driver) const {
334+
bool PciDevice::attachDriver(const std::string &driver) const {
335335
FILE *f;
336336
char fn[1024];
337337

@@ -363,7 +363,7 @@ bool Device::attachDriver(const std::string &driver) const {
363363
return true;
364364
}
365365

366-
uint32_t Device::readHostBar(unsigned barNum) const {
366+
uint32_t PciDevice::readHostBar(unsigned barNum) const {
367367
auto file = openSysFs("resource", std::ios_base::in);
368368

369369
std::string line;
@@ -389,7 +389,7 @@ uint32_t Device::readHostBar(unsigned barNum) const {
389389
return start;
390390
}
391391

392-
void Device::rewriteBar(unsigned barNum) {
392+
void PciDevice::rewriteBar(unsigned barNum) {
393393
auto hostBar = readHostBar(barNum);
394394
auto configBar = readBar(barNum);
395395

@@ -405,7 +405,7 @@ void Device::rewriteBar(unsigned barNum) {
405405
writeBar(hostBar, barNum);
406406
}
407407

408-
uint32_t Device::readBar(unsigned barNum) const {
408+
uint32_t PciDevice::readBar(unsigned barNum) const {
409409
uint32_t addr;
410410
auto file = openSysFs("config", std::ios_base::in);
411411

@@ -415,14 +415,14 @@ uint32_t Device::readBar(unsigned barNum) const {
415415
return addr;
416416
}
417417

418-
void Device::writeBar(uint32_t addr, unsigned barNum) {
418+
void PciDevice::writeBar(uint32_t addr, unsigned barNum) {
419419
auto file = openSysFs("config", std::ios_base::out);
420420

421421
file.seekp(PCI_BASE_ADDRESS_N(barNum));
422422
file.write(reinterpret_cast<char *>(&addr), sizeof(addr));
423423
}
424424

425-
int Device::getIommuGroup() const {
425+
int PciDevice::getIommuGroup() const {
426426
int ret;
427427
char *group;
428428

@@ -443,7 +443,7 @@ int Device::getIommuGroup() const {
443443
return atoi(group);
444444
}
445445

446-
std::fstream Device::openSysFs(const std::string &subPath,
446+
std::fstream PciDevice::openSysFs(const std::string &subPath,
447447
std::ios_base::openmode mode) const {
448448
std::fstream file;
449449

common/lib/kernel/vfio_container.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ std::shared_ptr<Device> Container::attachDevice(const std::string &name,
187187
return device;
188188
}
189189

190-
std::shared_ptr<Device> Container::attachDevice(pci::Device &pdev) {
190+
std::shared_ptr<Device> Container::attachDevice(pci::PciDevice &pdev) {
191191
int ret;
192192
char name[32], iommu_state[4];
193193
static constexpr const char *kernelDriver = "vfio-pci";

common/lib/kernel/vfio_device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static const char *vfio_pci_irq_names[] = {
5353
};
5454

5555
Device::Device(const std::string &name, int groupFileDescriptor,
56-
const kernel::pci::Device *pci_device)
56+
const kernel::pci::PciDevice *pci_device)
5757
: name(name), fd(-1), attachedToGroup(false), groupFd(groupFileDescriptor),
5858
info(), irqs(), regions(), mappings(), pci_device(pci_device),
5959
log(Log::get("kernel:vfio:device")) {

common/lib/kernel/vfio_group.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ std::shared_ptr<Device> Group::attachDevice(std::shared_ptr<Device> device) {
6868

6969
std::shared_ptr<Device>
7070
Group::attachDevice(const std::string &name,
71-
const kernel::pci::Device *pci_device) {
71+
const kernel::pci::PciDevice *pci_device) {
7272
auto device = std::make_shared<Device>(name, fd, pci_device);
7373
return attachDevice(device);
7474
}

fpga/include/villas/fpga/pcie_card.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class PCIeCard : public Card {
5555
bool doReset; // Reset VILLASfpga during startup?
5656
int affinity; // Affinity for MSI interrupts
5757

58-
std::shared_ptr<kernel::pci::Device> pdev; // PCI device handle
58+
std::shared_ptr<kernel::pci::PciDevice> pdev; // PCI device handle
5959

6060
protected:
6161
Logger getLogger() const { return villas::Log::get(name); }

fpga/lib/pcie_card.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ using namespace villas::fpga;
2424
// Instantiate factory to register
2525
static PCIeCardFactory PCIeCardFactoryInstance;
2626

27-
static const kernel::pci::Device
27+
static const kernel::pci::PciDevice
2828
defaultFilter((kernel::pci::Id(FPGA_PCI_VID_XILINX, FPGA_PCI_PID_VFPGA)));
2929

3030
std::shared_ptr<PCIeCard>
@@ -63,7 +63,7 @@ PCIeCardFactory::make(json_t *json_card, std::string card_name,
6363
card->doReset = do_reset != 0;
6464
card->polling = (polling != 0);
6565

66-
kernel::pci::Device filter = defaultFilter;
66+
kernel::pci::PciDevice filter = defaultFilter;
6767

6868
if (pci_id)
6969
filter.id = kernel::pci::Id(pci_id);

0 commit comments

Comments
 (0)