From e0717f6e3e78a95d5a0ffd976e21a14fd1af2c17 Mon Sep 17 00:00:00 2001 From: Andrew Jeffery Date: Tue, 23 Sep 2025 10:42:02 +0930 Subject: [PATCH 1/3] nvme-mi: Accept command effects that maintain current state Further, warn if the values deviate, as this indicates that the model's supported values have changed. Signed-off-by: Andrew Jeffery --- src/main.rs | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index a68eaf9..da0ee04 100644 --- a/src/main.rs +++ b/src/main.rs @@ -428,19 +428,29 @@ async fn nvme_mi_task(router: &'static Router<'static>) -> ! { debug!("Handling NVMe-MI message: {msg:x?}"); mep.handle_async(&mut subsys, msg, ic, resp, async |cmd| match cmd { CommandEffect::SetMtu { port_id, mtus } => { - if port_id == ppid { + if port_id != twpid { + warn!("NVMe-MI: Set MTU bad Port ID {port_id:?}"); + return Err(CommandEffectError::InternalError); + } + if mtus != 64 { // TODO: implement once PortLookup::by_eid trait takes a // non-mut reference. - warn!("NVMe-MI: Set MTU Port ID {port_id:?} MTU {mtus}, not currently handled"); - Err(CommandEffectError::Unsupported) - } else { - warn!("NVMe-MI: Set MTU bad Port ID {port_id:?}"); - Err(CommandEffectError::InternalError) + warn!("NVMe-MI: Application lacks support for MTU ({mtus}) != BTU (64)"); + return Err(CommandEffectError::Unsupported); } + + Ok(()) } - CommandEffect::SetSmbusFreq { .. } => { - info!("NVMe-MI: Ignoring Set SMBUS Frequency"); - Err(CommandEffectError::Unsupported) + CommandEffect::SetSmbusFreq { port_id: _, freq } => { + use nvme_mi_dev::nvme::mi::SmbusFrequency; + + if freq != SmbusFrequency::Freq100Khz { + warn!("NVMe-MI: Application lacks support for I2C bus frequency {:?}", freq); + return Err(CommandEffectError::Unsupported) + } + + // Not an error to ignore SMBus frequency when we're using USB + Ok(()) } }) .await; From 1e07eae46674a65a02d3388b1e1a9590abd121b3 Mon Sep 17 00:00:00 2001 From: Andrew Jeffery Date: Tue, 23 Sep 2025 10:42:47 +0930 Subject: [PATCH 2/3] nvme-mi: Constrain to one controller For now, ensure that multiple controllers aren't advertised so that an empty secondary controller list doesn't appear incoherent. Signed-off-by: Andrew Jeffery --- src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index da0ee04..96133fc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -402,7 +402,6 @@ async fn nvme_mi_task(router: &'static Router<'static>) -> ! { let mut subsys = Subsystem::new(SubsystemInfo::environment()); let ppid = subsys.add_port(PortType::Pcie(PciePort::new())).unwrap(); let ctrlid0 = subsys.add_controller(ppid).unwrap(); - let _ctrlid1 = subsys.add_controller(ppid).unwrap(); let size_blocks = 10_000_000_000_000_u64.div_ceil(512); let nsid = subsys.add_namespace(size_blocks).unwrap(); From 2edcdd6790eda4190d6b17824393456cbe44179b Mon Sep 17 00:00:00 2001 From: Andrew Jeffery Date: Tue, 23 Sep 2025 10:41:44 +0930 Subject: [PATCH 3/3] Update nvme-mi-dev Pick up implementations of Admin Identify CNS 11h (Identify Namespace for Allocated Namespace ID) and 12h (Namespace Attached Controller List). Signed-off-by: Andrew Jeffery --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 7add741..c9f5f56 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -759,7 +759,7 @@ dependencies = [ [[package]] name = "nvme-mi-dev" version = "0.1.0" -source = "git+https://github.com/CodeConstruct/nvme-mi-dev#b6614f2651dc46df5e7798c133a43669cebfee70" +source = "git+https://github.com/CodeConstruct/nvme-mi-dev#4deccf75405cb91e6bd2f020d3a0e0afa126ea6c" dependencies = [ "crc", "deku 0.19.1 (git+https://github.com/sharksforarms/deku.git?rev=e5363bc11e123bfcfd3467a2a90aeef8b588f432)",