Skip to content

Commit 6323d07

Browse files
committed
pci: remove dead code
Remove dead code from the logic that handles setting up a PCI VirtIO device transport. This was either code that we pulled from Cloud Hypervisor and we don't need here or code that we are not currently using. Signed-off-by: Babis Chalios <[email protected]>
1 parent c91b8a4 commit 6323d07

File tree

1 file changed

+0
-87
lines changed
  • src/vmm/src/devices/virtio/transport/pci

1 file changed

+0
-87
lines changed

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

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,6 @@ const DEVICE_DRIVER_OK: u8 = 0x04;
5353
const DEVICE_FEATURES_OK: u8 = 0x08;
5454
const DEVICE_FAILED: u8 = 0x80;
5555

56-
const VIRTIO_F_RING_INDIRECT_DESC: u32 = 28;
57-
const VIRTIO_F_RING_EVENT_IDX: u32 = 29;
58-
const VIRTIO_F_VERSION_1: u32 = 32;
59-
const VIRTIO_F_IOMMU_PLATFORM: u32 = 33;
60-
const VIRTIO_F_IN_ORDER: u32 = 35;
61-
const VIRTIO_F_ORDER_PLATFORM: u32 = 36;
62-
#[allow(dead_code)]
63-
const VIRTIO_F_SR_IOV: u32 = 37;
64-
const VIRTIO_F_NOTIFICATION_DATA: u32 = 38;
65-
6656
/// Vector value used to disable MSI for a queue.
6757
pub const VIRTQ_MSI_NO_VECTOR: u16 = 0xffff;
6858

@@ -83,7 +73,6 @@ enum PciCapabilityType {
8373
// fields cap_vndr (1 byte) and cap_next (1 byte) defined in the virtio spec.
8474
const VIRTIO_PCI_CAP_OFFSET: usize = 2;
8575

86-
#[allow(dead_code)]
8776
#[repr(C, packed)]
8877
#[derive(Debug, Clone, Copy, Default)]
8978
struct VirtioPciCap {
@@ -126,7 +115,6 @@ impl VirtioPciCap {
126115
}
127116
}
128117

129-
#[allow(dead_code)]
130118
#[repr(C, packed)]
131119
#[derive(Clone, Copy, Default)]
132120
struct VirtioPciNotifyCap {
@@ -164,47 +152,6 @@ impl VirtioPciNotifyCap {
164152
}
165153
}
166154

167-
#[allow(dead_code)]
168-
#[repr(C, packed)]
169-
#[derive(Clone, Copy, Default)]
170-
struct VirtioPciCap64 {
171-
cap: VirtioPciCap,
172-
offset_hi: Le32,
173-
length_hi: Le32,
174-
}
175-
// SAFETY: All members are simple numbers and any value is valid.
176-
unsafe impl ByteValued for VirtioPciCap64 {}
177-
178-
impl PciCapability for VirtioPciCap64 {
179-
fn bytes(&self) -> &[u8] {
180-
self.as_slice()
181-
}
182-
183-
fn id(&self) -> PciCapabilityId {
184-
PciCapabilityId::VendorSpecific
185-
}
186-
}
187-
188-
impl VirtioPciCap64 {
189-
pub fn new(cfg_type: PciCapabilityType, pci_bar: u8, id: u8, offset: u64, length: u64) -> Self {
190-
VirtioPciCap64 {
191-
cap: VirtioPciCap {
192-
cap_len: u8::try_from(std::mem::size_of::<VirtioPciCap64>()).unwrap()
193-
+ VIRTIO_PCI_CAP_LEN_OFFSET,
194-
cfg_type: cfg_type as u8,
195-
pci_bar,
196-
id,
197-
padding: [0; 2],
198-
offset: Le32::from((offset & 0xffff_ffff) as u32),
199-
length: Le32::from((length & 0xffff_ffff) as u32),
200-
},
201-
offset_hi: Le32::from((offset >> 32) as u32),
202-
length_hi: Le32::from((length >> 32) as u32),
203-
}
204-
}
205-
}
206-
207-
#[allow(dead_code)]
208155
#[repr(C, packed)]
209156
#[derive(Debug, Clone, Copy, Default)]
210157
struct VirtioPciCfgCap {
@@ -239,7 +186,6 @@ struct VirtioPciCfgCapInfo {
239186
cap: VirtioPciCfgCap,
240187
}
241188

242-
#[allow(dead_code)]
243189
#[derive(Debug, Copy, Clone)]
244190
pub enum PciVirtioSubclass {
245191
NonTransitionalBase = 0xff,
@@ -281,16 +227,6 @@ const NOTIFY_OFF_MULTIPLIER: u32 = 4; // A dword per notification address.
281227
const VIRTIO_PCI_VENDOR_ID: u16 = 0x1af4;
282228
const VIRTIO_PCI_DEVICE_ID_BASE: u16 = 0x1040; // Add to device type to get device ID.
283229

284-
#[derive(Debug, Clone, Serialize, Deserialize)]
285-
pub struct QueueState {
286-
max_size: u16,
287-
size: u16,
288-
ready: bool,
289-
desc_table: u64,
290-
avail_ring: u64,
291-
used_ring: u64,
292-
}
293-
294230
#[derive(Debug, Clone, Serialize, Deserialize)]
295231
pub struct VirtioPciDeviceState {
296232
pub pci_device_bdf: PciBdf,
@@ -682,29 +618,6 @@ impl VirtioPciDevice {
682618
Ok(())
683619
}
684620

685-
/// Unregister the IoEvent notification for a VirtIO device
686-
pub fn unregister_notification_ioevent(
687-
&self,
688-
vm: &Vm,
689-
) -> std::result::Result<(), errno::Error> {
690-
let bar_addr = self.config_bar_addr();
691-
for (i, queue_evt) in self
692-
.device
693-
.lock()
694-
.expect("Poisoned lock")
695-
.queue_events()
696-
.iter()
697-
.enumerate()
698-
{
699-
let notify_base = bar_addr + NOTIFICATION_BAR_OFFSET;
700-
let io_addr =
701-
IoEventAddress::Mmio(notify_base + i as u64 * NOTIFY_OFF_MULTIPLIER as u64);
702-
vm.fd()
703-
.unregister_ioevent(queue_evt, &io_addr, NoDatamatch)?;
704-
}
705-
Ok(())
706-
}
707-
708621
pub fn state(&self) -> VirtioPciDeviceState {
709622
VirtioPciDeviceState {
710623
pci_device_bdf: self.pci_device_bdf,

0 commit comments

Comments
 (0)