diff --git a/Cargo.lock b/Cargo.lock index 088382e..f10751a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -859,7 +859,7 @@ dependencies = [ [[package]] name = "nvme-mi-dev" version = "0.1.0" -source = "git+https://github.com/CodeConstruct/nvme-mi-dev?branch=main#421cd454dc53763d991df0fe748965ea07002527" +source = "git+https://github.com/CodeConstruct/nvme-mi-dev?branch=main#8b38ed3ab4e7189e7ed667a662fbd191d0a80e4b" dependencies = [ "crc", "deku 0.19.1 (git+https://github.com/sharksforarms/deku.git?rev=e5363bc11e123bfcfd3467a2a90aeef8b588f432)", diff --git a/src/main.rs b/src/main.rs index 339ff50..5871dca 100644 --- a/src/main.rs +++ b/src/main.rs @@ -220,8 +220,30 @@ async fn nvme_mi(router: &Router<'_>) -> std::io::Result<()> { }; debug!("Handling NVMe-MI message: {msg:x?}"); - mep.handle_async(&mut subsys, msg, ic, resp, async |_| { - Err(CommandEffectError::Unsupported) + mep.handle_async(&mut subsys, msg, ic, resp, async |ce| match ce { + nvme_mi_dev::CommandEffect::SetMtu { port_id, mtus } => { + if port_id != twpid { + warn!("NVMe-MI: Bad Port ID for Set MTU: {port_id:?}"); + return Err(CommandEffectError::InternalError); + } + + if mtus != 64 { + warn!("NVMe-MI: Application lacks support for MTU ({mtus}) != BTU (64)"); + return Err(CommandEffectError::Unsupported); + } + + Ok(()) + } + nvme_mi_dev::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); + } + + Ok(()) + } }) .await; }