Browse Source

chore: Update virtio-drivers to commit 61ece509c4 and modify max_queue_size implementation (#748)

LoGin 10 months ago
parent
commit
b502fbf0b9
2 changed files with 12 additions and 5 deletions
  1. 1 1
      kernel/Cargo.toml
  2. 11 4
      kernel/src/driver/virtio/transport_pci.rs

+ 1 - 1
kernel/Cargo.toml

@@ -47,7 +47,7 @@ num-traits = { git = "https://git.mirrors.dragonos.org.cn/DragonOS-Community/num
 smoltcp = { version = "=0.11.0", default-features = false, features = ["log", "alloc",  "socket-raw", "socket-udp", "socket-tcp", "socket-icmp", "socket-dhcpv4", "socket-dns", "proto-ipv4", "proto-ipv6"]}
 system_error = { path = "crates/system_error" }
 unified-init = { path = "crates/unified-init" }
-virtio-drivers = { git = "https://git.mirrors.dragonos.org.cn/DragonOS-Community/virtio-drivers.git", rev = "f1d1cbb" }
+virtio-drivers = { git = "https://git.mirrors.dragonos.org.cn/DragonOS-Community/virtio-drivers.git", rev = "61ece509c4" }
 fdt = "=0.1.5"
 uefi = { version = "=0.26.0", features = ["alloc"] }
 uefi-raw = "=0.5.0"

+ 11 - 4
kernel/src/driver/virtio/transport_pci.rs

@@ -276,10 +276,11 @@ impl Transport for PciTransport {
         }
     }
 
-    fn max_queue_size(&self) -> u32 {
-        // Safe because the common config pointer is valid and we checked in get_bar_region that it
-        // was aligned.
-        unsafe { volread!(self.common_cfg, queue_size) }.into()
+    fn max_queue_size(&mut self, queue: u16) -> u32 {
+        unsafe {
+            volwrite!(self.common_cfg, queue_select, queue);
+            volread!(self.common_cfg, queue_size).into()
+        }
     }
 
     fn notify(&mut self, queue: u16) {
@@ -304,6 +305,12 @@ impl Transport for PciTransport {
         }
     }
 
+    fn get_status(&self) -> DeviceStatus {
+        // Safe because the common config pointer is valid and we checked in get_bar_region that it
+        // was aligned.
+        unsafe { DeviceStatus::from_bits_truncate(volread!(self.common_cfg, device_status).into()) }
+    }
+
     fn set_guest_page_size(&mut self, _guest_page_size: u32) {
         // No-op, the PCI transport doesn't care.
     }