Skip to content

Commit 42def4f

Browse files
committed
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 <[email protected]>
1 parent 08ddb2d commit 42def4f

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/main.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,30 @@ async fn nvme_mi(router: &Router<'_>) -> std::io::Result<()> {
220220
};
221221

222222
debug!("Handling NVMe-MI message: {msg:x?}");
223-
mep.handle_async(&mut subsys, msg, ic, resp, async |_| {
224-
Err(CommandEffectError::Unsupported)
223+
mep.handle_async(&mut subsys, msg, ic, resp, async |ce| match ce {
224+
nvme_mi_dev::CommandEffect::SetMtu { port_id, mtus } => {
225+
if port_id != twpid {
226+
warn!("NVMe-MI: Bad Port ID for Set MTU: {port_id:?}");
227+
return Err(CommandEffectError::InternalError);
228+
}
229+
230+
if mtus != 64 {
231+
warn!("NVMe-MI: Application lacks support for MTU ({mtus}) != BTU (64)");
232+
return Err(CommandEffectError::Unsupported);
233+
}
234+
235+
Ok(())
236+
}
237+
nvme_mi_dev::CommandEffect::SetSmbusFreq { port_id: _, freq } => {
238+
use nvme_mi_dev::nvme::mi::SmbusFrequency;
239+
240+
if freq != SmbusFrequency::Freq100Khz {
241+
warn!("NVMe-MI: Application lacks support for I2C bus frequency {:?}", freq);
242+
return Err(CommandEffectError::Unsupported);
243+
}
244+
245+
Ok(())
246+
}
225247
})
226248
.await;
227249
}

0 commit comments

Comments
 (0)