Skip to content

Commit

Permalink
add iommu group
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnoreWarnings committed Aug 2, 2024
1 parent 59776bf commit d8ddbb4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions fpga/include/villas/fpga/devices/ip_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ class IpDevice : public Device {
public:
std::string ip_name() const;
size_t addr() const;
int iommu_group() const;
};
17 changes: 15 additions & 2 deletions fpga/lib/devices/ip_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ IpDevice IpDevice::from(const std::filesystem::path unsafe_path) {

bool IpDevice::is_path_valid(const std::filesystem::path unsafe_path) {
// Split the string at last slash
size_t pos = unsafe_path.u8string().rfind('/');
int pos = unsafe_path.u8string().rfind('/');
std::string assumed_device_name = unsafe_path.u8string().substr(pos + 1);

// Match format of hexaddr.devicename
Expand All @@ -35,7 +35,7 @@ bool IpDevice::is_path_valid(const std::filesystem::path unsafe_path) {
}

std::string IpDevice::ip_name() const {
size_t pos = name().find('.');
int pos = name().find('.');
return name().substr(pos + 1);
}

Expand All @@ -51,3 +51,16 @@ size_t IpDevice::addr() const {

return addr;
}

int IpDevice::iommu_group() const {
std::filesystem::path symlink =
std::filesystem::path(this->path.u8string() + "/iommu_group");

std::filesystem::path link;
link = std::filesystem::read_symlink(symlink);

std::string delimiter = "iommu_groups/";
int pos = link.u8string().find(delimiter);
int iommu_group = std::stoi(link.u8string().substr(pos + delimiter.length()));
return iommu_group;
}

0 comments on commit d8ddbb4

Please sign in to comment.