Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dhaval-rivos
Copy link

No description provided.

@dhaval-rivos dhaval-rivos force-pushed the dev/dhaval/pcie-all-instance-enum branch 2 times, most recently from 4efcbd8 to 5676898 Compare December 29, 2024 09:14
src/lib.rs Outdated
ops: &PciEcamCfgOps,
vendor_id: u16,
device_id: u16,
) -> Vec<Device> {

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?

Copy link
Author

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.

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.

Copy link
Author

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.
@dhaval-rivos dhaval-rivos force-pushed the dev/dhaval/pcie-all-instance-enum branch from 5676898 to 5cd77d1 Compare January 2, 2025 09:01
@@ -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(
Copy link
Owner

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants