Skip to content

Commit 8e91523

Browse files
committed
nvme: mi: dev: Broadcast NSID behaviour for Admin / Identify / NVM Identify Namespace
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
1 parent fdfd8a9 commit 8e91523

2 files changed

Lines changed: 62 additions & 2 deletions

File tree

src/nvme/mi/dev.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,8 +1174,17 @@ impl RequestHandler for AdminIdentifyRequest {
11741174
assert!(subsys.nss.len() <= u32::MAX.try_into().unwrap());
11751175

11761176
if self.nsid == u32::MAX {
1177-
debug!("Support with broadcast NSID");
1178-
return Err(ResponseStatus::InternalError);
1177+
let ainvminr = AdminIdentifyNvmIdentifyNamespaceResponse {
1178+
lbaf0_lbads: 9, // TODO: Tie to controller model
1179+
..Default::default()
1180+
}
1181+
.encode()?;
1182+
1183+
return admin_send_response_body(
1184+
resp,
1185+
admin_constrain_body(self.dofst, self.dlen, &ainvminr.0)?,
1186+
)
1187+
.await;
11791188
}
11801189

11811190
if self.nsid == 0 || self.nsid > subsys.nss.capacity() as u32 {

tests/admin.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,57 @@ mod identify {
700700
});
701701
}
702702

703+
#[test]
704+
fn namespace_broadcast() {
705+
setup();
706+
707+
let (mut mep, mut subsys) = new_device(DeviceType::P1p1tC1aN0a0a);
708+
709+
#[rustfmt::skip]
710+
const REQ: [u8; 71] = [
711+
0x10, 0x00, 0x00,
712+
0x06, 0x00, 0x00, 0x00,
713+
714+
// SQE DWORD 1
715+
0xff, 0xff, 0xff, 0xff,
716+
0x00, 0x00, 0x00, 0x00,
717+
0x00, 0x00, 0x00, 0x00,
718+
0x00, 0x00, 0x00, 0x00,
719+
0x00, 0x00, 0x00, 0x00,
720+
721+
// DOFST
722+
0x00, 0x00, 0x00, 0x00,
723+
0x00, 0x10, 0x00, 0x00,
724+
725+
// Reserved
726+
0x00, 0x00, 0x00, 0x00,
727+
0x00, 0x00, 0x00, 0x00,
728+
729+
// SQE DWORD 10
730+
0x00, 0x00, 0x00, 0x00,
731+
0x00, 0x00, 0x00, 0x00,
732+
0x00, 0x00, 0x00, 0x00,
733+
0x00, 0x00, 0x00, 0x00,
734+
0x00, 0x00, 0x00, 0x00,
735+
0x00, 0x00, 0x00, 0x00,
736+
737+
// MIC
738+
0xdc, 0xee, 0xe8, 0xf2
739+
];
740+
741+
#[rustfmt::skip]
742+
let resp_fields: Vec<ExpectedField> = vec![
743+
(0, &[0x90]),
744+
(19 + 130, &[0x09]), // LBADS
745+
];
746+
747+
let resp = RelaxedRespChannel::new(resp_fields);
748+
smol::block_on(async {
749+
mep.handle_async(&mut subsys, &REQ, MsgIC(true), resp, async |_| Ok(()))
750+
.await
751+
});
752+
}
753+
703754
#[test]
704755
fn namespace_inactive() {
705756
setup();

0 commit comments

Comments
 (0)