Skip to content

Commit 4a115b9

Browse files
committed
nvme: Order structs and enums by section and figure
Try to maintain some sanity. Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
1 parent b18c8d0 commit 4a115b9

File tree

1 file changed

+54
-54
lines changed

1 file changed

+54
-54
lines changed

src/nvme.rs

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@ flags! {
4141
}
4242
}
4343

44-
// Base v2.1, 4.2.3, Figure 100, CRD
45-
#[expect(dead_code)]
46-
#[repr(u8)]
47-
enum CommandRetryDelay {
48-
None = 0x00,
49-
Time1 = 0x01,
50-
Time2 = 0x02,
51-
Time3 = 0x03,
52-
}
53-
unsafe impl Discriminant<u8> for CommandRetryDelay {}
54-
5544
// Base v2.1, 4.2.1, Figure 98
5645
struct AdminIoCqeStatus {
5746
cid: u16,
@@ -85,6 +74,17 @@ impl From<AdminIoCqeStatus> for u32 {
8574
}
8675
}
8776

77+
// Base v2.1, 4.2.3, Figure 100, CRD
78+
#[expect(dead_code)]
79+
#[repr(u8)]
80+
enum CommandRetryDelay {
81+
None = 0x00,
82+
Time1 = 0x01,
83+
Time2 = 0x02,
84+
Time3 = 0x03,
85+
}
86+
unsafe impl Discriminant<u8> for CommandRetryDelay {}
87+
8888
// Base v2.1, 4.3.2, Figure 101
8989
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
9090
#[repr(u8)]
@@ -110,49 +110,6 @@ enum AdminIoCqeGenericCommandStatus {
110110
}
111111
unsafe impl Discriminant<u8> for AdminIoCqeGenericCommandStatus {}
112112

113-
// Base v2.1, 5.1.13.1, Figure 310
114-
#[derive(Clone, Copy, Debug, DekuRead, DekuWrite, Eq, PartialEq)]
115-
#[deku(ctx = "endian: Endian, cns: u8", id = "cns", endian = "endian")]
116-
#[repr(u8)]
117-
enum AdminIdentifyCnsRequestType {
118-
NvmIdentifyNamespace = 0x00,
119-
IdentifyController = 0x01,
120-
ActiveNamespaceIDList = 0x02,
121-
NamespaceIdentificationDescriptorList = 0x03,
122-
IoIdentifyNamespace = 0x05,
123-
IoIdentifyController = 0x06,
124-
IoActiveNamespaceIdList = 0x07,
125-
IdentifyNamespace = 0x08,
126-
AllocatedNamespaceIdList = 0x10,
127-
NvmSubsystemControllerList = 0x13,
128-
SecondaryControllerList = 0x15,
129-
}
130-
unsafe impl Discriminant<u8> for AdminIdentifyCnsRequestType {}
131-
132-
// Base v2.1, 5.1.13.1, Figure 310
133-
// NVM Command Set v1.0c, 4.1.5.1, Figure 97
134-
#[derive(Debug, Default, DekuRead, DekuWrite)]
135-
#[deku(endian = "little")]
136-
pub struct AdminIdentifyNvmIdentifyNamespaceResponse {
137-
nsze: u64,
138-
ncap: u64,
139-
nuse: u64,
140-
nsfeat: u8,
141-
nlbaf: u8,
142-
flbas: u8,
143-
mc: u8,
144-
dpc: u8,
145-
dps: u8,
146-
#[deku(seek_from_start = "48")]
147-
nvmcap: u128,
148-
#[deku(seek_from_start = "128")]
149-
// FIXME: use another struct
150-
lbaf0: u16,
151-
lbaf0_lbads: u8,
152-
lbaf0_rp: u8,
153-
}
154-
impl Encode<4096> for AdminIdentifyNvmIdentifyNamespaceResponse {}
155-
156113
// Base v2.1, 5.1.12, Figure 202
157114
// MI v2.0, 6.3, Figure 141
158115
#[derive(Debug, DekuRead, DekuWrite, Eq, PartialEq)]
@@ -242,6 +199,49 @@ pub struct SmartHealthInformationLogPageResponse {
242199
}
243200
impl Encode<512> for SmartHealthInformationLogPageResponse {}
244201

202+
// Base v2.1, 5.1.13.1, Figure 310
203+
#[derive(Clone, Copy, Debug, DekuRead, DekuWrite, Eq, PartialEq)]
204+
#[deku(ctx = "endian: Endian, cns: u8", id = "cns", endian = "endian")]
205+
#[repr(u8)]
206+
enum AdminIdentifyCnsRequestType {
207+
NvmIdentifyNamespace = 0x00,
208+
IdentifyController = 0x01,
209+
ActiveNamespaceIDList = 0x02,
210+
NamespaceIdentificationDescriptorList = 0x03,
211+
IoIdentifyNamespace = 0x05,
212+
IoIdentifyController = 0x06,
213+
IoActiveNamespaceIdList = 0x07,
214+
IdentifyNamespace = 0x08,
215+
AllocatedNamespaceIdList = 0x10,
216+
NvmSubsystemControllerList = 0x13,
217+
SecondaryControllerList = 0x15,
218+
}
219+
unsafe impl Discriminant<u8> for AdminIdentifyCnsRequestType {}
220+
221+
// Base v2.1, 5.1.13.1, Figure 310
222+
// NVM Command Set v1.0c, 4.1.5.1, Figure 97
223+
#[derive(Debug, Default, DekuRead, DekuWrite)]
224+
#[deku(endian = "little")]
225+
pub struct AdminIdentifyNvmIdentifyNamespaceResponse {
226+
nsze: u64,
227+
ncap: u64,
228+
nuse: u64,
229+
nsfeat: u8,
230+
nlbaf: u8,
231+
flbas: u8,
232+
mc: u8,
233+
dpc: u8,
234+
dps: u8,
235+
#[deku(seek_from_start = "48")]
236+
nvmcap: u128,
237+
#[deku(seek_from_start = "128")]
238+
// FIXME: use another struct
239+
lbaf0: u16,
240+
lbaf0_lbads: u8,
241+
lbaf0_rp: u8,
242+
}
243+
impl Encode<4096> for AdminIdentifyNvmIdentifyNamespaceResponse {}
244+
245245
// Base v2.1, 5.1.13.1, Figure 311
246246
#[derive(Clone, Copy, Debug, DekuRead, DekuWrite)]
247247
#[deku(id_type = "u8", endian = "endian", ctx = "endian: Endian")]

0 commit comments

Comments
 (0)