Skip to content

Commit aaf9bc0

Browse files
committed
refactor(pci): drop programming interface argument
We don't really use the programming interface field of the PCI header. It's always zero for the devices we support. Don't expose it as an argument for constructing PciConfiguration objects. Signed-off-by: Babis Chalios <[email protected]>
1 parent 9fa26c3 commit aaf9bc0

File tree

4 files changed

+3
-39
lines changed

4 files changed

+3
-39
lines changed

src/pci/src/bus.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ impl PciRoot {
5858
0,
5959
PciClassCode::BridgeDevice,
6060
&PciBridgeSubclass::HostBridge,
61-
None,
6261
PciHeaderType::Device,
6362
0,
6463
0,
@@ -482,7 +481,6 @@ mod tests {
482481
0x0,
483482
PciClassCode::MassStorage,
484483
&PciMassStorageSubclass::SerialScsiController,
485-
None,
486484
PciHeaderType::Device,
487485
0x13,
488486
0x12,

src/pci/src/configuration.rs

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,6 @@ impl PciSubclass for PciNetworkControllerSubclass {
176176
}
177177
}
178178

179-
/// Trait to define a PCI class programming interface
180-
///
181-
/// Each combination of `PciClassCode` and `PciSubclass` can specify a
182-
/// set of register-level programming interfaces.
183-
/// This trait is implemented by each programming interface.
184-
/// It allows use of a trait object to generate configurations.
185-
pub trait PciProgrammingInterface {
186-
/// Convert this programming interface to the value used in the PCI specification.
187-
fn get_register_value(&self) -> u8;
188-
}
189-
190179
/// Types of PCI capabilities.
191180
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
192181
#[allow(dead_code)]
@@ -451,7 +440,6 @@ impl PciConfiguration {
451440
revision_id: u8,
452441
class_code: PciClassCode,
453442
subclass: &dyn PciSubclass,
454-
programming_interface: Option<&dyn PciProgrammingInterface>,
455443
header_type: PciHeaderType,
456444
subsystem_vendor_id: u16,
457445
subsystem_id: u16,
@@ -473,14 +461,8 @@ impl PciConfiguration {
473461
registers[0] = (u32::from(device_id) << 16) | u32::from(vendor_id);
474462
// TODO(dverkamp): Status should be write-1-to-clear
475463
writable_bits[1] = 0x0000_ffff; // Status (r/o), command (r/w)
476-
let pi = if let Some(pi) = programming_interface {
477-
pi.get_register_value()
478-
} else {
479-
0
480-
};
481464
registers[2] = (u32::from(class_code.get_register_value()) << 24)
482465
| (u32::from(subclass.get_register_value()) << 16)
483-
| (u32::from(pi) << 8)
484466
| u32::from(revision_id);
485467
writable_bits[3] = 0x0000_00ff; // Cacheline size (r/w)
486468

@@ -1016,17 +998,6 @@ mod tests {
1016998
assert_eq!(cfg.read_reg(cap_reg + 2), pba_offset);
1017999
}
10181000

1019-
#[derive(Copy, Clone)]
1020-
enum TestPi {
1021-
Test = 0x5a,
1022-
}
1023-
1024-
impl PciProgrammingInterface for TestPi {
1025-
fn get_register_value(&self) -> u8 {
1026-
*self as u8
1027-
}
1028-
}
1029-
10301001
#[test]
10311002
fn class_code() {
10321003
let cfg = PciConfiguration::new(
@@ -1035,7 +1006,6 @@ mod tests {
10351006
0x1,
10361007
PciClassCode::MultimediaController,
10371008
&PciMultimediaSubclass::AudioController,
1038-
Some(&TestPi::Test),
10391009
PciHeaderType::Device,
10401010
0xABCD,
10411011
0x2468,
@@ -1049,7 +1019,7 @@ mod tests {
10491019
let prog_if = (class_reg >> 8) & 0xFF;
10501020
assert_eq!(class_code, 0x04);
10511021
assert_eq!(subclass, 0x01);
1052-
assert_eq!(prog_if, 0x5a);
1022+
assert_eq!(prog_if, 0x0);
10531023
}
10541024

10551025
#[test]
@@ -1092,7 +1062,6 @@ mod tests {
10921062
0x0,
10931063
PciClassCode::MassStorage,
10941064
&PciMassStorageSubclass::SerialScsiController,
1095-
None,
10961065
PciHeaderType::Device,
10971066
0x13,
10981067
0x12,
@@ -1174,7 +1143,6 @@ mod tests {
11741143
0x0,
11751144
PciClassCode::MassStorage,
11761145
&PciMassStorageSubclass::SerialScsiController,
1177-
None,
11781146
PciHeaderType::Device,
11791147
0x13,
11801148
0x12,
@@ -1220,7 +1188,6 @@ mod tests {
12201188
0x0,
12211189
PciClassCode::MassStorage,
12221190
&PciMassStorageSubclass::SerialScsiController,
1223-
None,
12241191
PciHeaderType::Device,
12251192
0x13,
12261193
0x12,

src/pci/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ pub use self::bus::{PciBus, PciConfigIo, PciConfigMmio, PciRoot, PciRootError};
2424
pub use self::configuration::{
2525
PciBarConfiguration, PciBarPrefetchable, PciBarRegionType, PciCapability, PciCapabilityId,
2626
PciClassCode, PciConfiguration, PciConfigurationState, PciExpressCapabilityId, PciHeaderType,
27-
PciMassStorageSubclass, PciNetworkControllerSubclass, PciProgrammingInterface,
28-
PciSerialBusSubClass, PciSubclass, PCI_CONFIGURATION_ID,
27+
PciMassStorageSubclass, PciNetworkControllerSubclass, PciSerialBusSubClass, PciSubclass,
28+
PCI_CONFIGURATION_ID,
2929
};
3030
pub use self::device::{
3131
BarReprogrammingParams, DeviceRelocation, Error as PciDeviceError, PciDevice,

src/vmm/src/devices/virtio/transport/pci/device.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ impl VirtioPciDevice {
335335
0x1, // For modern virtio-PCI devices
336336
class,
337337
subclass,
338-
None,
339338
PciHeaderType::Device,
340339
VIRTIO_PCI_VENDOR_ID,
341340
pci_device_id,

0 commit comments

Comments
 (0)