-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scan multiple instances of same device type in the system #6
base: main
Are you sure you want to change the base?
Scan multiple instances of same device type in the system #6
Conversation
4efcbd8
to
5676898
Compare
src/lib.rs
Outdated
ops: &PciEcamCfgOps, | ||
vendor_id: u16, | ||
device_id: u16, | ||
) -> Vec<Device> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we return a DeviceIterator by applying filter operation on lines 1501-1503 instead of pushing to a Vec? This library does not have any dependency on alloc crate and was wondering if we could keep it that way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/lib.rs
Outdated
@@ -1484,6 +1487,25 @@ pub fn shallow_scan_for_device( | |||
.find(|&device| device.vendor_id == vendor_id && device.device_id == device_id) | |||
} | |||
|
|||
// same as shallow_scan_for_device but scans all instances, some devices like | |||
// RoT have multiple instances within each chiplet, we should find and return all. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a generic library, so let's avoid any specific examples for any design here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
To be used by caller to go over all the instances of pci devices.
5676898
to
5cd77d1
Compare
@@ -1484,6 +1484,17 @@ pub fn shallow_scan_for_device( | |||
.find(|&device| device.vendor_id == vendor_id && device.device_id == device_id) | |||
} | |||
|
|||
pub fn get_pci_device_iter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vendor_id and device_id are unused here, what is the purpose? It seems like you're wanting maybe something like
all_local_devices(Bdf::from_bus(Bus(bus)), ops, Bus(bus + 1)).filter(|dev| dev.vendor_id == vendor_id && dev.device_id == device_id)
which is just adding a filter() call to all_local_devices(). does that need to be in this library? We have users of this library already that use it like:
for dev in pci::all_local_devices(0, &ops)
.filter(|dev| dev.vendor_id == RIVOS_VENDOR_ID && dev.device_id == IOMMU_DEVICE_ID)
No description provided.