2 * Copyright (c) 2016 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 format_number(uint64_t value
)
42 humanize_number(buf
, sizeof(buf
), value
, "",
43 HN_AUTOSCALE
, HN_DIVISOR_1000
| HN_NOSPACE
);
49 status_to_str(uint16_t status
)
52 int code
= NVME_COMQ_STATUS_CODE_GET(status
);
53 const char *msg
= NULL
;
55 switch(NVME_COMQ_STATUS_TYPE_GET(status
)) {
56 case NVME_STATUS_TYPE_GENERIC
:
58 case NVME_CODE_SUCCESS
:
64 case NVME_CODE_BADFIELD
:
67 case NVME_CODE_IDCONFLICT
:
70 case NVME_CODE_BADXFER
:
73 case NVME_CODE_ABORTED_PWRLOSS
:
74 msg
= "Abort on Power Loss";
76 case NVME_CODE_INTERNAL
:
77 msg
= "Internal Error";
79 case NVME_CODE_ABORTED_ONREQ
:
80 msg
= "Abort on Request";
82 case NVME_CODE_ABORTED_SQDEL
:
83 msg
= "Abort on SubQ Deletion";
85 case NVME_CODE_ABORTED_FUSEFAIL
:
86 msg
= "Abort on Fuse Failed";
88 case NVME_CODE_ABORTED_FUSEMISSING
:
89 msg
= "Abort on Fuse Missing";
91 case NVME_CODE_BADNAMESPACE
:
92 msg
= "Bad Namespace";
94 case NVME_CODE_SEQERROR
:
97 case NVME_CODE_BADSGLSEG
:
98 msg
= "Bad SGL Segment";
100 case NVME_CODE_BADSGLCNT
:
101 msg
= "Bad SGL Count";
103 case NVME_CODE_BADSGLLEN
:
104 msg
= "Bad SGL Length";
106 case NVME_CODE_BADSGLMLEN
:
107 msg
= "Bad SGL MLength";
109 case NVME_CODE_BADSGLTYPE
:
110 msg
= "Bad SGL Type";
112 case NVME_CODE_BADMEMBUFUSE
:
113 msg
= "Bad Memory Buffer Usage";
115 case NVME_CODE_BADPRPOFF
:
116 msg
= "Bad PRP Offset";
118 case NVME_CODE_ATOMICWUOVFL
:
119 msg
= "Atomic Write Overflow";
121 case NVME_CODE_LBA_RANGE
:
122 msg
= "LBA Out of Range";
124 case NVME_CODE_CAP_EXCEEDED
:
125 msg
= "Capacity Exceeded";
127 case NVME_CODE_NAM_NOT_READY
:
128 msg
= "Namespace not Ready";
130 case NVME_CODE_RSV_CONFLICT
:
131 msg
= "Reservation Conflict";
133 case NVME_CODE_FMT_IN_PROG
:
134 msg
= "Format in Progress";
137 snprintf(buf
, sizeof(buf
), "generic(0x%02x)", code
);
141 case NVME_STATUS_TYPE_SPECIFIC
:
143 case NVME_CSSCODE_BADCOMQ
:
144 msg
= "Bad Completion Queue";
146 case NVME_CSSCODE_BADQID
:
147 msg
= "Bad Queue ID";
149 case NVME_CSSCODE_BADQSIZE
:
150 msg
= "Bad Queue Size";
152 case NVME_CSSCODE_ABORTLIM
:
153 msg
= "Too many Aborts";
155 case NVME_CSSCODE_RESERVED04
:
158 case NVME_CSSCODE_ASYNCEVENTLIM
:
159 msg
= "Too many Async Events";
161 case NVME_CSSCODE_BADFWSLOT
:
162 msg
= "Bad Firmware Slot";
164 case NVME_CSSCODE_BADFWIMAGE
:
165 msg
= "Bad Firmware Image";
167 case NVME_CSSCODE_BADINTRVECT
:
168 msg
= "Bad Interrupt Vector";
170 case NVME_CSSCODE_BADLOGPAGE
:
171 msg
= "Unsupported Log Page";
173 case NVME_CSSCODE_BADFORMAT
:
174 msg
= "Bad Format Command";
176 case NVME_CSSCODE_FW_NEEDSCONVRESET
:
177 msg
= "Firmware Activation Needs Conventional Reset";
179 case NVME_CSSCODE_BADQDELETE
:
180 msg
= "Bad Queue Delete";
182 case NVME_CSSCODE_FEAT_NOT_SAVEABLE
:
183 msg
= "Feature not Saveable";
185 case NVME_CSSCODE_FEAT_NOT_CHGABLE
:
186 msg
= "Feature not Changeable";
188 case NVME_CSSCODE_FEAT_NOT_NSSPEC
:
189 msg
= "Feature not Namespace-Specific";
191 case NVME_CSSCODE_FW_NEEDSSUBRESET
:
192 msg
= "Firmware Activation Needs Subsystem Reset";
194 case NVME_CSSCODE_FW_NEEDSRESET
:
195 msg
= "Firmware Activation Needs Reset";
197 case NVME_CSSCODE_FW_NEEDSMAXTVIOLATE
:
198 msg
= "Firmware Activation Requires "
199 "Maximum Time Violation";
201 case NVME_CSSCODE_FW_PROHIBITED
:
202 msg
= "Firmware Activation Prohibited";
204 case NVME_CSSCODE_RANGE_OVERLAP
:
205 msg
= "Overlapping Range";
207 case NVME_CSSCODE_NAM_INSUFF_CAP
:
208 msg
= "Insufficient Capacity";
210 case NVME_CSSCODE_NAM_ID_UNAVAIL
:
211 msg
= "NSID is not Available";
213 case NVME_CSSCODE_RESERVED17
:
216 case NVME_CSSCODE_NAM_ALREADY_ATT
:
217 msg
= "NSID Already Attached";
219 case NVME_CSSCODE_NAM_IS_PRIVATE
:
220 msg
= "NSID is Private";
222 case NVME_CSSCODE_NAM_NOT_ATT
:
223 msg
= "NSID Not Attached";
225 case NVME_CSSCODE_NO_THIN_PROVISION
:
226 msg
= "This Provisioning not Supported";
228 case NVME_CSSCODE_CTLR_LIST_INVALID
:
229 msg
= "Controller List Invalid";
231 case NVME_CSSCODE_ATTR_CONFLICT
:
232 msg
= "Conflicting Attributes";
234 case NVME_CSSCODE_BADPROTINFO
:
235 msg
= "Invalid Prortection Information";
237 case NVME_CSSCODE_WRITE_TO_RDONLY
:
238 msg
= "Attempted Write to Read Only Range";
241 snprintf(buf
, sizeof(buf
), "specific(0x%02x)", code
);
245 case NVME_STATUS_TYPE_MEDIA
:
247 case NVME_MEDCODE_WRITE_FAULT
:
250 case NVME_MEDCODE_UNRECOV_READ_ERROR
:
251 msg
= "Unrecoverable Read Error";
253 case NVME_MEDCODE_ETOE_GUARD_CHK
:
254 msg
= "End-to-End Guard Check Fail";
256 case NVME_MEDCODE_ETOE_APPTAG_CHK
:
257 msg
= "End-to-End Application Tag Check Error";
259 case NVME_MEDCODE_ETOE_REFTAG_CHK
:
260 msg
= "End-to-End Reference Tag Check Error";
262 case NVME_MEDCODE_COMPARE_FAILURE
:
263 msg
= "Compare Failure";
265 case NVME_MEDCODE_ACCESS_DENIED
:
266 msg
= "Access Denied";
268 case NVME_MEDCODE_UNALLOCATED
:
269 msg
= "Deallocated or Unwritten Logical Block";
272 snprintf(buf
, sizeof(buf
), "media(0x%02x)", code
);
276 case NVME_STATUS_TYPE_3
:
277 case NVME_STATUS_TYPE_4
:
278 case NVME_STATUS_TYPE_5
:
279 case NVME_STATUS_TYPE_6
:
282 case NVME_STATUS_TYPE_VENDOR
:
283 snprintf(buf
, sizeof(buf
), "vendor(0x%02x)", code
);
287 snprintf(buf
, sizeof(buf
), "%s", msg
);