@@ -53,16 +53,6 @@ const DEVICE_DRIVER_OK: u8 = 0x04;
53
53
const DEVICE_FEATURES_OK : u8 = 0x08 ;
54
54
const DEVICE_FAILED : u8 = 0x80 ;
55
55
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
-
66
56
/// Vector value used to disable MSI for a queue.
67
57
pub const VIRTQ_MSI_NO_VECTOR : u16 = 0xffff ;
68
58
@@ -83,7 +73,6 @@ enum PciCapabilityType {
83
73
// fields cap_vndr (1 byte) and cap_next (1 byte) defined in the virtio spec.
84
74
const VIRTIO_PCI_CAP_OFFSET : usize = 2 ;
85
75
86
- #[ allow( dead_code) ]
87
76
#[ repr( C , packed) ]
88
77
#[ derive( Debug , Clone , Copy , Default ) ]
89
78
struct VirtioPciCap {
@@ -126,7 +115,6 @@ impl VirtioPciCap {
126
115
}
127
116
}
128
117
129
- #[ allow( dead_code) ]
130
118
#[ repr( C , packed) ]
131
119
#[ derive( Clone , Copy , Default ) ]
132
120
struct VirtioPciNotifyCap {
@@ -164,47 +152,6 @@ impl VirtioPciNotifyCap {
164
152
}
165
153
}
166
154
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) ]
208
155
#[ repr( C , packed) ]
209
156
#[ derive( Debug , Clone , Copy , Default ) ]
210
157
struct VirtioPciCfgCap {
@@ -239,7 +186,6 @@ struct VirtioPciCfgCapInfo {
239
186
cap : VirtioPciCfgCap ,
240
187
}
241
188
242
- #[ allow( dead_code) ]
243
189
#[ derive( Debug , Copy , Clone ) ]
244
190
pub enum PciVirtioSubclass {
245
191
NonTransitionalBase = 0xff ,
@@ -281,16 +227,6 @@ const NOTIFY_OFF_MULTIPLIER: u32 = 4; // A dword per notification address.
281
227
const VIRTIO_PCI_VENDOR_ID : u16 = 0x1af4 ;
282
228
const VIRTIO_PCI_DEVICE_ID_BASE : u16 = 0x1040 ; // Add to device type to get device ID.
283
229
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
-
294
230
#[ derive( Debug , Clone , Serialize , Deserialize ) ]
295
231
pub struct VirtioPciDeviceState {
296
232
pub pci_device_bdf : PciBdf ,
@@ -682,29 +618,6 @@ impl VirtioPciDevice {
682
618
Ok ( ( ) )
683
619
}
684
620
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
-
708
621
pub fn state ( & self ) -> VirtioPciDeviceState {
709
622
VirtioPciDeviceState {
710
623
pci_device_bdf : self . pci_device_bdf ,
0 commit comments