pcid: Replace get_capabilities with get_vendor_capabilities
While this stops returning raw MSI/MSI-X capabilities from get_capabilities, the same info can be obtained using fetch_all_features and feature_info.
This commit is contained in:
@@ -101,10 +101,13 @@ impl DriverHandler {
|
||||
use driver_interface::*;
|
||||
|
||||
match request {
|
||||
PcidClientRequest::RequestCapabilities => PcidClientResponse::Capabilities(
|
||||
PcidClientRequest::RequestVendorCapabilities => PcidClientResponse::VendorCapabilities(
|
||||
self.capabilities
|
||||
.iter()
|
||||
.map(|capability| capability.clone())
|
||||
.filter_map(|capability| match capability {
|
||||
PciCapability::Vendor(capability) => Some(capability.clone()),
|
||||
_ => None,
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
),
|
||||
PcidClientRequest::RequestConfig => PcidClientResponse::Config(args.clone()),
|
||||
|
||||
@@ -8,7 +8,7 @@ use std::os::unix::io::{FromRawFd, RawFd};
|
||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||
use thiserror::Error;
|
||||
|
||||
pub use crate::pci::cap::Capability;
|
||||
pub use crate::pci::cap::VendorSpecificCapability;
|
||||
pub use crate::pci::msi;
|
||||
pub use crate::pci::{FullDeviceId, PciAddress, PciBar};
|
||||
|
||||
@@ -192,7 +192,7 @@ pub enum SetFeatureInfo {
|
||||
pub enum PcidClientRequest {
|
||||
RequestConfig,
|
||||
RequestFeatures,
|
||||
RequestCapabilities,
|
||||
RequestVendorCapabilities,
|
||||
EnableFeature(PciFeature),
|
||||
FeatureInfo(PciFeature),
|
||||
SetFeatureInfo(SetFeatureInfo),
|
||||
@@ -210,9 +210,9 @@ pub enum PcidServerResponseError {
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[non_exhaustive]
|
||||
pub enum PcidClientResponse {
|
||||
Capabilities(Vec<Capability>),
|
||||
Config(SubdriverArguments),
|
||||
AllFeatures(Vec<PciFeature>),
|
||||
VendorCapabilities(Vec<VendorSpecificCapability>),
|
||||
FeatureEnabled(PciFeature),
|
||||
FeatureStatus(PciFeature, FeatureStatus),
|
||||
Error(PcidServerResponseError),
|
||||
@@ -247,7 +247,7 @@ pub(crate) fn recv<R: Read, T: DeserializeOwned>(r: &mut R) -> Result<T> {
|
||||
if length > 0x100_000 {
|
||||
panic!("pcid_interface: buffer too large");
|
||||
}
|
||||
let mut data = vec! [0u8; length as usize];
|
||||
let mut data = vec![0u8; length as usize];
|
||||
r.read_exact(&mut data)?;
|
||||
|
||||
Ok(bincode::deserialize_from(&data[..])?)
|
||||
@@ -277,11 +277,11 @@ impl PcidServerHandle {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_capabilities(&mut self) -> Result<Vec<Capability>> {
|
||||
self.send(&PcidClientRequest::RequestCapabilities)?;
|
||||
pub fn get_vendor_capabilities(&mut self) -> Result<Vec<VendorSpecificCapability>> {
|
||||
self.send(&PcidClientRequest::RequestVendorCapabilities)?;
|
||||
|
||||
match self.recv()? {
|
||||
PcidClientResponse::Capabilities(a) => Ok(a),
|
||||
PcidClientResponse::VendorCapabilities(a) => Ok(a),
|
||||
other => Err(PcidClientHandleError::InvalidResponse(other)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,17 +71,7 @@ pub fn probe_device(pcid_handle: &mut PcidServerHandle) -> Result<Device, Error>
|
||||
let mut notify_addr = None;
|
||||
let mut device_addr = None;
|
||||
|
||||
for raw_capability in pcid_handle
|
||||
.get_capabilities()?
|
||||
.iter()
|
||||
.filter_map(|capability| {
|
||||
if let Capability::Vendor(vendor) = capability {
|
||||
Some(vendor)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
{
|
||||
for raw_capability in pcid_handle.get_vendor_capabilities()? {
|
||||
// SAFETY: We have verified that the length of the data is correct.
|
||||
let capability = unsafe { &*(raw_capability.data.as_ptr() as *const PciCapability) };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user