Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 19 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -428,19 +427,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;
Expand Down