1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
enum StatusCode {
    Generic(GenericStatusCode),
    Specific(SpecificStatusCode),
    MediaAndDataIntegrityErrors(MADStatusCode),
    PathRelated(PathStatusCode),
}

#[repr(u8)]
enum MADStatusCode {
    WriteFault = 0x80,
    UnrecoveredReadError,
    EndToEndGuardCheckError,
    EndToEndAppTagCheckError,
    EndToEndRefTagCheckError,
    CompareFailure,
    AccessDenied,
    DeallocatedOrUnwrittenLogicalBlock,
    EndToEndStorageTagCheckError,
}

#[repr(u8)]
enum PathStatusCode {
    InternalPathError,
    AsymetricAccessPersistentLoss,
    AsymetricAccessInaccessible,
    AsymetricAccessTransition,
    ControllerPathingError = 0x60,
    HostPathingError = 0x70,
    CommandAbortedByHost,
    ConflictingAttributes = 0x80,
    InvalidProtectionInfo,
    WriteToReadOnlyRange,
    CommandSizeLimitExceeded,

    ZonedBoundaryError = 0xb8,
    ZoneFull,
    ZoneReadOnly,
    ZoneOffline,
    ZoneInvalidWrite,
    TooManyActiveZones,
    TooManyOpenZones,
    InvalidZoneStateTransition,
}

#[repr(u8)]
enum GenericStatusCode {
    Success,
    InvalidOpcode,
    InvalidField,
    CommandIdConflict,
    DataTransferError,
    PowerLoss,
    InternalError,
    CommandAbortRequested,
    CommandAbortSQDeleted,
    CommandAbortFuseFailed,
    CommandAbortMissingFuse,
    InvalidNamespaceOrFormat,
    CommandSequenceError,
    InvalidSGLSegmentDescriptor,
    InvalidNumberOfSGLDescriptors,
    DataSGLLengthInvalid,
    MetadataSGLLengthInvalid,
    SGLDescriptorTypeInvalid,
    InvalidUseOfControllerMemBuffer,
    PRPOffsetInvalid,
    AtomicWriteUnitExceeded,
    OperationDenied,
    SGLOffsetInvalid,
    Reserved0 = 0x17,
    HostIDInconsistentFormat,
    KeepAliveTimeout,
    KeepAliveTimeoutInvalid,
    PreemptAndAbort,
    SanitizeFailed,
    SanitizeInProgress,
    SGLDataBlockGranularityInvalid,
    CommandNotSupportedForQueueInCMB,
    NamespaceWriteProtected,
    CommandInterrupted,
    TransientTransportError,
    CommandProhibitedByLockdown,
    AdminCommandMediaNotReady,
    LBACutOfRange = 0x80,
    CapacityExceeded,
    NamespaceNotReady,
    ReservationConflict,
    FormatInProgress,
    InvalidValueSize,
    InvalidKeySize,
    KVKeyDoesNotExist,
    UnrecoveredError,
    KeyExists,
}

#[repr(u8)]
enum SpecificStatusCode {
    CompletionQueueInvalid,
    InvalidQueueID,
    InvalidQueueSize,
    AbortCommandLimitExceeded,
    Reserved0,
    AsyncEventRequestLimitExceeded,
    InvalidFirmwareSlot,
    InvalidLogPage,
    InvalidFormat,
    FirmwareActivationRequiresReset,
    InvalidQueueDeletion,
    FeatureIDNotSavable,
    FeatureNotChangeable,
    FeatureNotNamespaceSpecific,
    FirmwareActivationRequiresNVMSubsystemReset,
    FirmwareActivationRequiresControllerReset,
    FirmwareActivationRequiresMaximumTimeViolation,
    FirmwareActivationProhibited,
    OverlappingRange,
    NamespaceInsufficientCapacity,
    NamespaceIDUnavailable,
    Reserved1 = 0x17,
    NamespaceAlreadyAttached,
    NamespaceIsPrivate,
    NamespaceNotAttached,
    ThinProvisioningNotSupported,
    ControllerListInvalid,
    DeviceSelfTestInProgress,
    BootPartitionWriteProhibited,
    InvalidControllerID,
    InvalidSecondaryControllerState,
    InvalidNumberOfControllerResources,
    InvalidResourceIdentifier,
    SanitizeProhibitedWhileNVMEnabled,
    ANAGroupIDInvalid,
    ANAAttachFailed,
    InsufficientCapacity,
    NamespaceAttachmentLimitExceeded,
    ProhibitionOfCommandExecutionNotSupported,
    IOCommandSetNotSupported,
    IOCommandSetNotEnabled,
    IOCommandSetCombinationRejected,
    InvalidIOCommandSet,
    IdentifierUnavailable,
    //TODO: Directive Specific
    ConflictingAttributes = 0x80,
    InvalidProtectionInfo,
    WriteToReadOnlyRange,
    CommandSizeLimitExceeded,

    ZonedBoundaryError = 0xb8,
    ZoneFull,
    ZoneReadOnly,
    ZoneOffline,
    ZoneInvalidWrite,
    TooManyActiveZones,
    TooManyOpenZones,
    InvalidZoneStateTransition,
}