Skip to content

Commit 060ab3b

Browse files
committed
wip: pci transport
Signed-off-by: Babis Chalios <[email protected]>
1 parent 20c7068 commit 060ab3b

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

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

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use vm_memory::GuestAddress;
1616

1717
use crate::devices::virtio::device::VirtioDevice;
1818
use crate::devices::virtio::queue::Queue;
19-
use crate::logger::{debug, error, info, trace, warn};
19+
use crate::logger::warn;
2020
pub const VIRTIO_PCI_COMMON_CONFIG_ID: &str = "virtio_pci_common_config";
2121

2222
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -176,7 +176,10 @@ impl VirtioPciCommonConfig {
176176
let v = self.read_common_config_qword(offset);
177177
LittleEndian::write_u64(data, v);
178178
}
179-
_ => error!("invalid data length for virtio read: len {}", data.len()),
179+
_ => warn!(
180+
"pci: invalid data length for virtio read: len {}",
181+
data.len()
182+
),
180183
}
181184
}
182185

@@ -196,35 +199,35 @@ impl VirtioPciCommonConfig {
196199
LittleEndian::read_u64(data),
197200
device.lock().unwrap().queues_mut(),
198201
),
199-
_ => error!("invalid data length for virtio write: len {}", data.len()),
202+
_ => warn!(
203+
"pci: invalid data length for virtio write: len {}",
204+
data.len()
205+
),
200206
}
201207
}
202208

203209
fn read_common_config_byte(&self, offset: u64) -> u8 {
204-
debug!("read_common_config_byte: offset 0x{:x}", offset);
205210
// The driver is only allowed to do aligned, properly sized access.
206211
match offset {
207212
0x14 => self.driver_status,
208213
0x15 => self.config_generation,
209214
_ => {
210-
warn!("invalid virtio config byte read: 0x{:x}", offset);
215+
warn!("pci: invalid virtio config byte read: 0x{:x}", offset);
211216
0
212217
}
213218
}
214219
}
215220

216221
fn write_common_config_byte(&mut self, offset: u64, value: u8) {
217-
debug!("write_common_config_byte: offset 0x{offset:x}: {value:x}");
218222
match offset {
219223
0x14 => self.driver_status = value,
220224
_ => {
221-
warn!("invalid virtio config byte write: 0x{:x}", offset);
225+
warn!("pci: invalid virtio config byte write: 0x{:x}", offset);
222226
}
223227
}
224228
}
225229

226230
fn read_common_config_word(&self, offset: u64, queues: &[Queue]) -> u16 {
227-
debug!("read_common_config_word: offset 0x{:x}", offset);
228231
match offset {
229232
0x10 => self.msix_config.load(Ordering::Acquire),
230233
0x12 => queues.len().try_into().unwrap(), // num_queues
@@ -246,14 +249,13 @@ impl VirtioPciCommonConfig {
246249
0x1c => u16::from(self.with_queue(queues, |q| q.ready).unwrap_or(false)),
247250
0x1e => self.queue_select, // notify_off
248251
_ => {
249-
warn!("invalid virtio register word read: 0x{:x}", offset);
252+
warn!("pci: invalid virtio register word read: 0x{:x}", offset);
250253
0
251254
}
252255
}
253256
}
254257

255258
fn write_common_config_word(&mut self, offset: u64, value: u16, queues: &mut [Queue]) {
256-
debug!("write_common_config_word: offset 0x{:x}", offset);
257259
match offset {
258260
0x10 => self.msix_config.store(value, Ordering::Release),
259261
0x16 => self.queue_select = value,
@@ -274,13 +276,12 @@ impl VirtioPciCommonConfig {
274276
q.ready = value == 1;
275277
}),
276278
_ => {
277-
warn!("invalid virtio register word write: 0x{:x}", offset);
279+
warn!("pci: invalid virtio register word write: 0x{:x}", offset);
278280
}
279281
}
280282
}
281283

282284
fn read_common_config_dword(&self, offset: u64, device: Arc<Mutex<dyn VirtioDevice>>) -> u32 {
283-
debug!("read_common_config_dword: offset 0x{:x}", offset);
284285
match offset {
285286
0x00 => self.device_feature_select,
286287
0x04 => {
@@ -296,7 +297,7 @@ impl VirtioPciCommonConfig {
296297
}
297298
0x08 => self.driver_feature_select,
298299
_ => {
299-
warn!("invalid virtio register dword read: 0x{:x}", offset);
300+
warn!("pci: invalid virtio register dword read: 0x{:x}", offset);
300301
0
301302
}
302303
}
@@ -308,7 +309,6 @@ impl VirtioPciCommonConfig {
308309
value: u32,
309310
device: Arc<Mutex<dyn VirtioDevice>>,
310311
) {
311-
debug!("write_common_config_dword: offset 0x{:x}", offset);
312312
fn hi(v: &mut GuestAddress, x: u32) {
313313
*v = (*v & 0xffff_ffff) | (u64::from(x) << 32)
314314
}
@@ -342,19 +342,16 @@ impl VirtioPciCommonConfig {
342342
hi(&mut q.used_ring_address, value)
343343
}),
344344
_ => {
345-
warn!("invalid virtio register dword write: 0x{:x}", offset);
345+
warn!("pci: invalid virtio register dword write: 0x{:x}", offset);
346346
}
347347
}
348348
}
349349

350350
fn read_common_config_qword(&self, _offset: u64) -> u64 {
351-
debug!("read_common_config_qword: offset 0x{:x}", _offset);
352351
0 // Assume the guest has no reason to read write-only registers.
353352
}
354353

355354
fn write_common_config_qword(&mut self, offset: u64, value: u64, queues: &mut [Queue]) {
356-
debug!("write_common_config_qword: offset 0x{:x}", offset);
357-
358355
let low = Some((value & 0xffff_ffff) as u32);
359356
let high = Some((value >> 32) as u32);
360357

@@ -363,7 +360,7 @@ impl VirtioPciCommonConfig {
363360
0x28 => self.with_queue_mut(queues, |q| q.avail_ring_address.0 = value),
364361
0x30 => self.with_queue_mut(queues, |q| q.used_ring_address.0 = value),
365362
_ => {
366-
warn!("invalid virtio register qword write: 0x{:x}", offset);
363+
warn!("pci: invalid virtio register qword write: 0x{:x}", offset);
367364
}
368365
}
369366
}

0 commit comments

Comments
 (0)