smartmontools SVN Rev 5611
Utility to control and monitor storage systems with "S.M.A.R.T."
nvmeprint.cpp
Go to the documentation of this file.
1/*
2 * nvmeprint.cpp
3 *
4 * Home page of code is: https://www.smartmontools.org
5 *
6 * Copyright (C) 2016-24 Christian Franke
7 *
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
10
11#include "config.h"
12#define __STDC_FORMAT_MACROS 1 // enable PRI* for C++
13
14#include "nvmeprint.h"
15
16const char * nvmeprint_cvsid = "$Id: nvmeprint.cpp 5604 2024-03-29 16:14:52Z chrfranke $"
18
19#include "utility.h"
20#include "dev_interface.h"
21#include "nvmecmds.h"
22#include "atacmds.h" // dont_print_serial_number
23#include "scsicmds.h" // dStrHex()
24#include "smartctl.h"
25#include "sg_unaligned.h"
26
27#include <inttypes.h>
28
29using namespace smartmontools;
30
31// Return true if 128 bit LE integer is != 0.
32static bool le128_is_non_zero(const unsigned char (& val)[16])
33{
34 for (int i = 0; i < 16; i++) {
35 if (val[i])
36 return true;
37 }
38 return false;
39}
40
41// Format 128 bit integer for printing.
42// Add value with SI prefixes if BYTES_PER_UNIT is specified.
43static const char * le128_to_str(char (& str)[64], uint64_t hi, uint64_t lo, unsigned bytes_per_unit)
44{
45 if (!hi) {
46 // Up to 64-bit, print exact value
47 format_with_thousands_sep(str, sizeof(str)-16, lo);
48
49 if (lo && bytes_per_unit && lo < 0xffffffffffffffffULL / bytes_per_unit) {
50 int i = strlen(str);
51 str[i++] = ' '; str[i++] = '[';
52 format_capacity(str+i, (int)sizeof(str)-i-1, lo * bytes_per_unit);
53 i = strlen(str);
54 str[i++] = ']'; str[i] = 0;
55 }
56 }
57 else {
58 // More than 64-bit, prepend '~' flag on low precision
59 int i = 0;
60 // cppcheck-suppress knownConditionTrueFalse
62 str[i++] = '~';
63 uint128_hilo_to_str(str + i, (int)sizeof(str) - i, hi, lo);
64 }
65
66 return str;
67}
68
69// Format 128 bit LE integer for printing.
70// Add value with SI prefixes if BYTES_PER_UNIT is specified.
71static const char * le128_to_str(char (& str)[64], const unsigned char (& val)[16],
72 unsigned bytes_per_unit = 0)
73{
74 uint64_t hi = val[15];
75 for (int i = 15-1; i >= 8; i--) {
76 hi <<= 8; hi += val[i];
77 }
78 uint64_t lo = val[7];
79 for (int i = 7-1; i >= 0; i--) {
80 lo <<= 8; lo += val[i];
81 }
82 return le128_to_str(str, hi, lo, bytes_per_unit);
83}
84
85// Format capacity specified as 64bit LBA count for printing.
86static const char * lbacap_to_str(char (& str)[64], uint64_t lba_cnt, int lba_bits)
87{
88 return le128_to_str(str, (lba_cnt >> (64 - lba_bits)), (lba_cnt << lba_bits), 1);
89}
90
91// Output capacity specified as 64bit LBA count to JSON
92static void lbacap_to_js(const json::ref & jref, uint64_t lba_cnt, int lba_bits)
93{
94 jref["blocks"].set_unsafe_uint64(lba_cnt);
95 jref["bytes"].set_unsafe_uint128((lba_cnt >> (64 - lba_bits)), (lba_cnt << lba_bits));
96}
97
98// Format a Kelvin temperature value in Celsius.
99static const char * kelvin_to_str(char (& str)[64], int k)
100{
101 if (!k) // unsupported?
102 str[0] = '-', str[1] = 0;
103 else
104 snprintf(str, sizeof(str), "%d Celsius", k - 273);
105 return str;
106}
107
108static void print_drive_info(const nvme_id_ctrl & id_ctrl, const nvme_id_ns & id_ns,
109 unsigned nsid, bool show_all)
110{
111 char buf[64];
112 jout("Model Number: %s\n", format_char_array(buf, id_ctrl.mn));
113 jglb["model_name"] = buf;
115 jout("Serial Number: %s\n", format_char_array(buf, id_ctrl.sn));
116 jglb["serial_number"] = buf;
117 }
118
119 jout("Firmware Version: %s\n", format_char_array(buf, id_ctrl.fr));
120 jglb["firmware_version"] = buf;
121
122 // Vendor and Subsystem IDs are usually equal
123 if (show_all || id_ctrl.vid != id_ctrl.ssvid) {
124 jout("PCI Vendor ID: 0x%04x\n", id_ctrl.vid);
125 jout("PCI Vendor Subsystem ID: 0x%04x\n", id_ctrl.ssvid);
126 }
127 else {
128 jout("PCI Vendor/Subsystem ID: 0x%04x\n", id_ctrl.vid);
129 }
130 jglb["nvme_pci_vendor"]["id"] = id_ctrl.vid;
131 jglb["nvme_pci_vendor"]["subsystem_id"] = id_ctrl.ssvid;
132
133 jout("IEEE OUI Identifier: 0x%02x%02x%02x\n",
134 id_ctrl.ieee[2], id_ctrl.ieee[1], id_ctrl.ieee[0]);
135 jglb["nvme_ieee_oui_identifier"] = sg_get_unaligned_le(3, id_ctrl.ieee);
136
137 // Capacity info is optional for devices without namespace management
138 if (show_all || le128_is_non_zero(id_ctrl.tnvmcap) || le128_is_non_zero(id_ctrl.unvmcap)) {
139 jout("Total NVM Capacity: %s\n", le128_to_str(buf, id_ctrl.tnvmcap, 1));
140 jglb["nvme_total_capacity"].set_unsafe_le128(id_ctrl.tnvmcap);
141 jout("Unallocated NVM Capacity: %s\n", le128_to_str(buf, id_ctrl.unvmcap, 1));
142 jglb["nvme_unallocated_capacity"].set_unsafe_le128(id_ctrl.unvmcap);
143 }
144
145 jout("Controller ID: %d\n", id_ctrl.cntlid);
146 jglb["nvme_controller_id"] = id_ctrl.cntlid;
147
148 if (id_ctrl.ver) { // NVMe 1.2
149 int i = snprintf(buf, sizeof(buf), "%u.%u", id_ctrl.ver >> 16, (id_ctrl.ver >> 8) & 0xff);
150 if (i > 0 && (id_ctrl.ver & 0xff))
151 snprintf(buf+i, sizeof(buf)-i, ".%u", id_ctrl.ver & 0xff);
152 }
153 else
154 snprintf(buf, sizeof(buf), "<1.2");
155 jout("NVMe Version: %s\n", buf);
156 jglb["nvme_version"]["string"] = buf;
157 jglb["nvme_version"]["value"] = id_ctrl.ver;
158
159 // Print namespace info if available
160 jout("Number of Namespaces: %u\n", id_ctrl.nn);
161 jglb["nvme_number_of_namespaces"] = id_ctrl.nn;
162
163 if (nsid && id_ns.nsze) {
164 const char * align = &(" "[nsid < 10 ? 0 : (nsid < 100 ? 1 : 2)]);
165 int fmt_lba_bits = id_ns.lbaf[id_ns.flbas & 0xf].ds;
166
167 json::ref jrns = jglb["nvme_namespaces"][0];
168 jrns["id"] = nsid;
169
170 // Size and Capacity are equal if thin provisioning is not supported
171 if (show_all || id_ns.ncap != id_ns.nsze || (id_ns.nsfeat & 0x01)) {
172 jout("Namespace %u Size: %s%s\n", nsid, align,
173 lbacap_to_str(buf, id_ns.nsze, fmt_lba_bits));
174 jout("Namespace %u Capacity: %s%s\n", nsid, align,
175 lbacap_to_str(buf, id_ns.ncap, fmt_lba_bits));
176 }
177 else {
178 jout("Namespace %u Size/Capacity: %s%s\n", nsid, align,
179 lbacap_to_str(buf, id_ns.nsze, fmt_lba_bits));
180 }
181 lbacap_to_js(jrns["size"], id_ns.nsze, fmt_lba_bits);
182 lbacap_to_js(jrns["capacity"], id_ns.ncap, fmt_lba_bits);
183 lbacap_to_js(jglb["user_capacity"], id_ns.ncap, fmt_lba_bits); // TODO: use nsze?
184
185 // Utilization may be always equal to Capacity if thin provisioning is not supported
186 if (show_all || id_ns.nuse != id_ns.ncap || (id_ns.nsfeat & 0x01))
187 jout("Namespace %u Utilization: %s%s\n", nsid, align,
188 lbacap_to_str(buf, id_ns.nuse, fmt_lba_bits));
189 lbacap_to_js(jrns["utilization"], id_ns.nuse, fmt_lba_bits);
190
191 jout("Namespace %u Formatted LBA Size: %s%u\n", nsid, align, (1U << fmt_lba_bits));
192 jrns["formatted_lba_size"] = (1U << fmt_lba_bits);
193 jglb["logical_block_size"] = (1U << fmt_lba_bits);
194
195 if (!dont_print_serial_number && (show_all || nonempty(id_ns.eui64, sizeof(id_ns.eui64)))) {
196 jout("Namespace %u IEEE EUI-64: %s%02x%02x%02x %02x%02x%02x%02x%02x\n",
197 nsid, align, id_ns.eui64[0], id_ns.eui64[1], id_ns.eui64[2], id_ns.eui64[3],
198 id_ns.eui64[4], id_ns.eui64[5], id_ns.eui64[6], id_ns.eui64[7]);
199 jrns["eui64"]["oui"] = sg_get_unaligned_be(3, id_ns.eui64);
200 jrns["eui64"]["ext_id"] = sg_get_unaligned_be(5, id_ns.eui64 + 3);
201 }
202 }
203
204 // SMART/Health Information is mandatory
205 jglb["smart_support"] += { {"available", true}, {"enabled", true} };
206
207 jout_startup_datetime("Local Time is: ");
208}
209
210// Format scaled power value.
211static const char * format_power(char (& str)[16], unsigned power, unsigned scale)
212{
213 switch (scale & 0x3) {
214 case 0: // not reported
215 str[0] = '-'; str[1] = ' '; str[2] = 0; break;
216 case 1: // 0.0001W
217 snprintf(str, sizeof(str), "%u.%04uW", power / 10000, power % 10000); break;
218 case 2: // 0.01W
219 snprintf(str, sizeof(str), "%u.%02uW", power / 100, power % 100); break;
220 default: // reserved
221 str[0] = '?'; str[1] = 0; break;
222 }
223 return str;
224}
225
226static void print_drive_capabilities(const nvme_id_ctrl & id_ctrl, const nvme_id_ns & id_ns,
227 unsigned nsid, bool show_all)
228{
229 // Figure 112 of NVM Express Base Specification Revision 1.3d, March 20, 2019
230 // Figure 251 of NVM Express Base Specification Revision 1.4c, March 9, 2021
231 // Figure 275 of NVM Express Base Specification Revision 2.0c, October 4, 2022
232 pout("Firmware Updates (0x%02x): %d Slot%s%s%s%s%s\n", id_ctrl.frmw,
233 ((id_ctrl.frmw >> 1) & 0x7), (((id_ctrl.frmw >> 1) & 0x7) != 1 ? "s" : ""),
234 ((id_ctrl.frmw & 0x01) ? ", Slot 1 R/O" : ""),
235 ((id_ctrl.frmw & 0x10) ? ", no Reset required" : ""),
236 ((id_ctrl.frmw & 0x20) ? ", multiple detected" : ""), // NVMe 2.0
237 ((id_ctrl.frmw & ~0x3f) ? ", *Other*" : ""));
238
239 if (show_all || id_ctrl.oacs)
240 pout("Optional Admin Commands (0x%04x): %s%s%s%s%s%s%s%s%s%s%s%s%s\n", id_ctrl.oacs,
241 (!id_ctrl.oacs ? " -" : ""),
242 ((id_ctrl.oacs & 0x0001) ? " Security" : ""),
243 ((id_ctrl.oacs & 0x0002) ? " Format" : ""),
244 ((id_ctrl.oacs & 0x0004) ? " Frmw_DL" : ""),
245 ((id_ctrl.oacs & 0x0008) ? " NS_Mngmt" : ""), // NVMe 1.2
246 ((id_ctrl.oacs & 0x0010) ? " Self_Test" : ""), // NVMe 1.3 ...
247 ((id_ctrl.oacs & 0x0020) ? " Directvs" : ""),
248 ((id_ctrl.oacs & 0x0040) ? " MI_Snd/Rec" : ""),
249 ((id_ctrl.oacs & 0x0080) ? " Vrt_Mngmt" : ""),
250 ((id_ctrl.oacs & 0x0100) ? " Drbl_Bf_Cfg" : ""),
251 ((id_ctrl.oacs & 0x0200) ? " Get_LBA_Sts" : ""), // NVMe 1.4
252 ((id_ctrl.oacs & 0x0400) ? " Lockdown" : ""), // NVMe 2.0
253 ((id_ctrl.oacs & ~0x07ff) ? " *Other*" : ""));
254
255 if (show_all || id_ctrl.oncs)
256 pout("Optional NVM Commands (0x%04x): %s%s%s%s%s%s%s%s%s%s%s\n", id_ctrl.oncs,
257 (!id_ctrl.oncs ? " -" : ""),
258 ((id_ctrl.oncs & 0x0001) ? " Comp" : ""),
259 ((id_ctrl.oncs & 0x0002) ? " Wr_Unc" : ""),
260 ((id_ctrl.oncs & 0x0004) ? " DS_Mngmt" : ""),
261 ((id_ctrl.oncs & 0x0008) ? " Wr_Zero" : ""), // NVMe 1.1 ...
262 ((id_ctrl.oncs & 0x0010) ? " Sav/Sel_Feat" : ""),
263 ((id_ctrl.oncs & 0x0020) ? " Resv" : ""),
264 ((id_ctrl.oncs & 0x0040) ? " Timestmp" : ""), // NVMe 1.3
265 ((id_ctrl.oncs & 0x0080) ? " Verify" : ""), // NVMe 1.4
266 ((id_ctrl.oncs & 0x0100) ? " Copy" : ""), // NVMe 2.0
267 ((id_ctrl.oncs & ~0x01ff) ? " *Other*" : ""));
268
269 if (show_all || id_ctrl.lpa)
270 pout("Log Page Attributes (0x%02x): %s%s%s%s%s%s%s%s%s\n", id_ctrl.lpa,
271 (!id_ctrl.lpa ? " -" : ""),
272 ((id_ctrl.lpa & 0x01) ? " S/H_per_NS" : ""),
273 ((id_ctrl.lpa & 0x02) ? " Cmd_Eff_Lg" : ""), // NVMe 1.2
274 ((id_ctrl.lpa & 0x04) ? " Ext_Get_Lg" : ""), // NVMe 1.2.1
275 ((id_ctrl.lpa & 0x08) ? " Telmtry_Lg" : ""), // NVMe 1.3
276 ((id_ctrl.lpa & 0x10) ? " Pers_Ev_Lg" : ""), // NVMe 1.4
277 ((id_ctrl.lpa & 0x20) ? " Log0_FISE_MI" : ""), // NVMe 2.0 ...
278 ((id_ctrl.lpa & 0x40) ? " Telmtry_Ar_4" : ""),
279 ((id_ctrl.lpa & ~0x7f) ? " *Other*" : ""));
280
281 if (id_ctrl.mdts)
282 pout("Maximum Data Transfer Size: %u Pages\n", (1U << id_ctrl.mdts));
283 else if (show_all)
284 pout("Maximum Data Transfer Size: -\n");
285
286 // Temperature thresholds are optional
287 char buf[64];
288 if (show_all || id_ctrl.wctemp)
289 pout("Warning Comp. Temp. Threshold: %s\n", kelvin_to_str(buf, id_ctrl.wctemp));
290 if (show_all || id_ctrl.cctemp)
291 pout("Critical Comp. Temp. Threshold: %s\n", kelvin_to_str(buf, id_ctrl.cctemp));
292
293 // Figure 110 of NVM Express Base Specification Revision 1.3d, March 20, 2019
294 // Figure 249 of NVM Express Base Specification Revision 1.4c, March 9, 2021
295 // Figure 97 of NVM Express NVM Command Set Specification, Revision 1.0c, October 3, 2022
296 if (nsid && (show_all || id_ns.nsfeat)) {
297 const char * align = &(" "[nsid < 10 ? 0 : (nsid < 100 ? 1 : 2)]);
298 pout("Namespace %u Features (0x%02x): %s%s%s%s%s%s%s%s\n", nsid, id_ns.nsfeat, align,
299 (!id_ns.nsfeat ? " -" : ""),
300 ((id_ns.nsfeat & 0x01) ? " Thin_Prov" : ""),
301 ((id_ns.nsfeat & 0x02) ? " NA_Fields" : ""), // NVMe 1.2 ...
302 ((id_ns.nsfeat & 0x04) ? " Dea/Unw_Error" : ""),
303 ((id_ns.nsfeat & 0x08) ? " No_ID_Reuse" : ""), // NVMe 1.3
304 ((id_ns.nsfeat & 0x10) ? " NP_Fields" : ""), // NVMe 1.4
305 ((id_ns.nsfeat & ~0x1f) ? " *Other*" : ""));
306 }
307
308 // Print Power States
309 pout("\nSupported Power States\n");
310 pout("St Op Max Active Idle RL RT WL WT Ent_Lat Ex_Lat\n");
311 for (int i = 0; i <= id_ctrl.npss /* 1-based */ && i < 32; i++) {
312 char p1[16], p2[16], p3[16];
313 const nvme_id_power_state & ps = id_ctrl.psd[i];
314 pout("%2d %c %9s %8s %8s %3d %2d %2d %2d %8u %7u\n", i,
315 ((ps.flags & 0x02) ? '-' : '+'),
316 format_power(p1, ps.max_power, ((ps.flags & 0x01) ? 1 : 2)),
319 ps.read_lat & 0x1f, ps.read_tput & 0x1f,
320 ps.write_lat & 0x1f, ps.write_tput & 0x1f,
321 ps.entry_lat, ps.exit_lat);
322 }
323
324 // Print LBA sizes
325 if (nsid && id_ns.lbaf[0].ds) {
326 pout("\nSupported LBA Sizes (NSID 0x%x)\n", nsid);
327 pout("Id Fmt Data Metadt Rel_Perf\n");
328 for (int i = 0; i <= id_ns.nlbaf /* 1-based */ && i < 16; i++) {
329 const nvme_lbaf & lba = id_ns.lbaf[i];
330 pout("%2d %c %7u %7d %9d\n", i, (i == id_ns.flbas ? '+' : '-'),
331 (1U << lba.ds), lba.ms, lba.rp);
332 }
333 }
334}
335
336static void print_critical_warning(unsigned char w)
337{
338 jout("SMART overall-health self-assessment test result: %s\n",
339 (!w ? "PASSED" : "FAILED!"));
340 jglb["smart_status"]["passed"] = !w;
341
342 json::ref jref = jglb["smart_status"]["nvme"];
343 jref["value"] = w;
344
345 if (w) {
346 if (w & 0x01)
347 jout("- available spare has fallen below threshold\n");
348 jref["spare_below_threshold"] = !!(w & 0x01);
349 if (w & 0x02)
350 jout("- temperature is above or below threshold\n");
351 jref["temperature_above_or_below_threshold"] = !!(w & 0x02);
352 if (w & 0x04)
353 jout("- NVM subsystem reliability has been degraded\n");
354 jref["reliability_degraded"] = !!(w & 0x04);
355 if (w & 0x08)
356 jout("- media has been placed in read only mode\n");
357 jref["media_read_only"] = !!(w & 0x08);
358 if (w & 0x10)
359 jout("- volatile memory backup device has failed\n");
360 jref["volatile_memory_backup_failed"] = !!(w & 0x10);
361 if (w & 0x20)
362 jout("- persistent memory region has become read-only or unreliable\n");
363 jref["persistent_memory_region_unreliable"] = !!(w & 0x20);
364 if (w & ~0x3f)
365 jout("- unknown critical warning(s) (0x%02x)\n", w & ~0x3f);
366 jref["other"] = w & ~0x3f;
367 }
368
369 jout("\n");
370}
371
372static void print_smart_log(const nvme_smart_log & smart_log,
373 const nvme_id_ctrl & id_ctrl, bool show_all)
374{
375 json::ref jref = jglb["nvme_smart_health_information_log"];
376 char buf[64];
377 jout("SMART/Health Information (NVMe Log 0x02)\n");
378 jout("Critical Warning: 0x%02x\n", smart_log.critical_warning);
379 jref["critical_warning"] = smart_log.critical_warning;
380
381 int k = sg_get_unaligned_le16(smart_log.temperature);
382 jout("Temperature: %s\n", kelvin_to_str(buf, k));
383 if (k) {
384 jref["temperature"] = k - 273;
385 jglb["temperature"]["current"] = k - 273;
386 }
387
388 jout("Available Spare: %u%%\n", smart_log.avail_spare);
389 jref["available_spare"] = smart_log.avail_spare;
390 jout("Available Spare Threshold: %u%%\n", smart_log.spare_thresh);
391 jref["available_spare_threshold"] = smart_log.spare_thresh;
392 jout("Percentage Used: %u%%\n", smart_log.percent_used);
393 jref["percentage_used"] = smart_log.percent_used;
394 jout("Data Units Read: %s\n", le128_to_str(buf, smart_log.data_units_read, 1000*512));
395 jref["data_units_read"].set_unsafe_le128(smart_log.data_units_read);
396 jout("Data Units Written: %s\n", le128_to_str(buf, smart_log.data_units_written, 1000*512));
397 jref["data_units_written"].set_unsafe_le128(smart_log.data_units_written);
398 jout("Host Read Commands: %s\n", le128_to_str(buf, smart_log.host_reads));
399 jref["host_reads"].set_unsafe_le128(smart_log.host_reads);
400 jout("Host Write Commands: %s\n", le128_to_str(buf, smart_log.host_writes));
401 jref["host_writes"].set_unsafe_le128(smart_log.host_writes);
402 jout("Controller Busy Time: %s\n", le128_to_str(buf, smart_log.ctrl_busy_time));
403 jref["controller_busy_time"].set_unsafe_le128(smart_log.ctrl_busy_time);
404 jout("Power Cycles: %s\n", le128_to_str(buf, smart_log.power_cycles));
405 jref["power_cycles"].set_unsafe_le128(smart_log.power_cycles);
406 jglb["power_cycle_count"].set_if_safe_le128(smart_log.power_cycles);
407 jout("Power On Hours: %s\n", le128_to_str(buf, smart_log.power_on_hours));
408 jref["power_on_hours"].set_unsafe_le128(smart_log.power_on_hours);
409 jglb["power_on_time"]["hours"].set_if_safe_le128(smart_log.power_on_hours);
410 jout("Unsafe Shutdowns: %s\n", le128_to_str(buf, smart_log.unsafe_shutdowns));
411 jref["unsafe_shutdowns"].set_unsafe_le128(smart_log.unsafe_shutdowns);
412 jout("Media and Data Integrity Errors: %s\n", le128_to_str(buf, smart_log.media_errors));
413 jref["media_errors"].set_unsafe_le128(smart_log.media_errors);
414 jout("Error Information Log Entries: %s\n", le128_to_str(buf, smart_log.num_err_log_entries));
415 jref["num_err_log_entries"].set_unsafe_le128(smart_log.num_err_log_entries);
416
417 // Temperature thresholds are optional
418 if (show_all || id_ctrl.wctemp || smart_log.warning_temp_time) {
419 jout("Warning Comp. Temperature Time: %d\n", smart_log.warning_temp_time);
420 jref["warning_temp_time"] = smart_log.warning_temp_time;
421 }
422 if (show_all || id_ctrl.cctemp || smart_log.critical_comp_time) {
423 jout("Critical Comp. Temperature Time: %d\n", smart_log.critical_comp_time);
424 jref["critical_comp_time"] = smart_log.critical_comp_time;
425 }
426
427 // Temperature sensors are optional
428 for (int i = 0; i < 8; i++) {
429 k = smart_log.temp_sensor[i];
430 if (show_all || k) {
431 jout("Temperature Sensor %d: %s\n", i + 1,
432 kelvin_to_str(buf, k));
433 if (k)
434 jref["temperature_sensors"][i] = k - 273;
435 }
436 }
437 if (show_all || smart_log.thm_temp1_trans_count)
438 pout("Thermal Temp. 1 Transition Count: %d\n", smart_log.thm_temp1_trans_count);
439 if (show_all || smart_log.thm_temp2_trans_count)
440 pout("Thermal Temp. 2 Transition Count: %d\n", smart_log.thm_temp2_trans_count);
441 if (show_all || smart_log.thm_temp1_total_time)
442 pout("Thermal Temp. 1 Total Time: %d\n", smart_log.thm_temp1_total_time);
443 if (show_all || smart_log.thm_temp2_total_time)
444 pout("Thermal Temp. 2 Total Time: %d\n", smart_log.thm_temp2_total_time);
445 pout("\n");
446}
447
448static void print_error_log(const nvme_error_log_page * error_log,
449 unsigned read_entries, unsigned max_entries)
450{
451 // Figure 93 of NVM Express Base Specification Revision 1.3d, March 20, 2019
452 // Figure 197 of NVM Express Base Specification Revision 1.4c, March 9, 2021
453 json::ref jref = jglb["nvme_error_information_log"];
454 jout("Error Information (NVMe Log 0x01, %u of %u entries)\n",
455 read_entries, max_entries);
456
457 // Search last valid entry
458 unsigned valid_entries = read_entries;
459 while (valid_entries && !error_log[valid_entries-1].error_count)
460 valid_entries--;
461
462 unsigned unread_entries = 0;
463 if (valid_entries == read_entries && read_entries < max_entries)
464 unread_entries = max_entries - read_entries;
465 jref += {
466 { "size", max_entries },
467 { "read", read_entries },
468 { "unread", unread_entries },
469 };
470
471 if (!valid_entries) {
472 jout("No Errors Logged\n\n");
473 return;
474 }
475
476 jout("Num ErrCount SQId CmdId Status PELoc LBA NSID VS Message\n");
477 int unused = 0;
478 for (unsigned i = 0; i < valid_entries; i++) {
479 const nvme_error_log_page & e = error_log[i];
480 if (!e.error_count) {
481 // unused or invalid entry
482 unused++;
483 continue;
484 }
485 if (unused) {
486 jout(" - [%d unused entr%s]\n", unused, (unused == 1 ? "y" : "ies"));
487 unused = 0;
488 }
489
490 json::ref jrefi = jref["table"][i];
491 jrefi["error_count"] = e.error_count;
492 const char * msg = "-"; char msgbuf[64]{};
493 char sq[16] = "-", cm[16] = "-", st[16] = "-", pe[16] = "-";
494 char lb[32] = "-", ns[16] = "-", vs[8] = "-";
495 if (e.sqid != 0xffff) {
496 snprintf(sq, sizeof(sq), "%d", e.sqid);
497 jrefi["submission_queue_id"] = e.sqid;
498 }
499 if (e.cmdid != 0xffff) {
500 snprintf(cm, sizeof(cm), "0x%04x", e.cmdid);
501 jrefi["command_id"] = e.cmdid;
502 }
503 if (e.status_field != 0xffff) {
504 snprintf(st, sizeof(st), "0x%04x", e.status_field);
505 uint16_t s = e.status_field >> 1;
506 msg = nvme_status_to_info_str(msgbuf, s);
507 jrefi += {
508 { "status_field", {
509 { "value", s },
510 { "do_not_retry", !!(s & 0x4000) },
511 { "status_code_type", (s >> 8) & 0x7 },
512 { "status_code" , (uint8_t)s },
513 { "string", msg }
514 }},
515 { "phase_tag", !!(e.status_field & 0x0001) }
516 };
517 }
518 if (e.parm_error_location != 0xffff) {
519 snprintf(pe, sizeof(pe), "0x%03x", e.parm_error_location);
520 jrefi["parm_error_location"] = e.parm_error_location;
521 }
522 if (e.lba != 0xffffffffffffffffULL) {
523 snprintf(lb, sizeof(lb), "%" PRIu64, e.lba);
524 jrefi["lba"]["value"].set_unsafe_uint64(e.lba);
525 }
526 if (e.nsid != 0xffffffffU) {
527 snprintf(ns, sizeof(ns), "%u", e.nsid);
528 jrefi["nsid"] = e.nsid;
529 }
530 if (e.vs != 0x00) {
531 snprintf(vs, sizeof(vs), "0x%02x", e.vs);
532 jrefi["vendor_specific"] = e.vs;
533 }
534 // TODO: TRTYPE, command/transport specific information
535
536 jout("%3u %10" PRIu64 " %5s %7s %7s %6s %12s %5s %5s %s\n",
537 i, e.error_count, sq, cm, st, pe, lb, ns, vs, msg);
538 }
539
540 if (unread_entries)
541 jout("... (%u entries not read)\n", unread_entries);
542 jout("\n");
543}
544
545static void print_self_test_log(const nvme_self_test_log & self_test_log, unsigned nsid)
546{
547 // Figure 99 of NVM Express Base Specification Revision 1.3d, March 20, 2019
548 // Figure 203 of NVM Express Base Specification Revision 1.4c, March 9, 2021
549 json::ref jref = jglb["nvme_self_test_log"];
550 jout("Self-test Log (NVMe Log 0x06, NSID 0x%x)\n", nsid);
551 jref["nsid"] = (nsid != 0xffffffff ? (int64_t)nsid : -1);
552
553 const char * s; char buf[32];
554 switch (self_test_log.current_operation & 0xf) {
555 case 0x0: s = "No self-test in progress"; break;
556 case 0x1: s = "Short self-test in progress"; break;
557 case 0x2: s = "Extended self-test in progress"; break;
558 case 0xe: s = "Vendor specific self-test in progress"; break;
559 default: snprintf(buf, sizeof(buf), "Unknown status (0x%x)",
560 self_test_log.current_operation & 0xf);
561 s = buf; break;
562 }
563 jout("Self-test status: %s", s);
564 jref["current_self_test_operation"] += {
565 { "value", self_test_log.current_operation & 0xf },
566 { "string", s }
567 };
568 if (self_test_log.current_operation & 0xf) {
569 jout(" (%d%% completed)", self_test_log.current_completion & 0x7f);
570 jref["current_self_test_completion_percent"] = self_test_log.current_completion & 0x7f;
571 }
572 jout("\n");
573
574 int cnt = 0;
575 for (unsigned i = 0; i < 20; i++) {
576 const nvme_self_test_result & r = self_test_log.results[i];
577 uint8_t op = r.self_test_status >> 4;
578 uint8_t res = r.self_test_status & 0xf;
579 if (!op || res == 0xf)
580 continue; // unused entry
581
582 json::ref jrefi = jref["table"][i];
583 const char * t; char buf2[32];
584 switch (op) {
585 case 0x1: t = "Short"; break;
586 case 0x2: t = "Extended"; break;
587 case 0xe: t = "Vendor specific"; break;
588 default: snprintf(buf2, sizeof(buf2), "Unknown (0x%x)", op);
589 t = buf2; break;
590 }
591
592 switch (res) {
593 case 0x0: s = "Completed without error"; break;
594 case 0x1: s = "Aborted: Self-test command"; break;
595 case 0x2: s = "Aborted: Controller Reset"; break;
596 case 0x3: s = "Aborted: Namespace removed"; break;
597 case 0x4: s = "Aborted: Format NVM command"; break;
598 case 0x5: s = "Fatal or unknown test error"; break;
599 case 0x6: s = "Completed: unknown failed segment"; break;
600 case 0x7: s = "Completed: failed segments"; break;
601 case 0x8: s = "Aborted: unknown reason"; break;
602 case 0x9: s = "Aborted: sanitize operation"; break;
603 default: snprintf(buf, sizeof(buf), "Unknown result (0x%x)", res);
604 s = buf; break;
605 }
606
607 uint64_t poh = sg_get_unaligned_le64(r.power_on_hours);
608
609 jrefi += {
610 { "self_test_code", { { "value", op }, { "string", t } } },
611 { "self_test_result", { { "value", res }, { "string", s } } },
612 { "power_on_hours", poh }
613 };
614
615 char sg[8] = "-", ns[16] = "-", lb[32] = "-", st[8] = "-", sc[8] = "-";
616 if (res == 0x7) {
617 snprintf(sg, sizeof(sg), "%d", r.segment);
618 jrefi["segment"] = r.segment;
619 }
620 if (r.valid & 0x01) {
621 if (r.nsid == 0xffffffff)
622 ns[0] = '*', ns[1] = 0;
623 else
624 snprintf(ns, sizeof(ns), "%u", r.nsid);
625 // Broadcast = -1
626 jrefi["nsid"] = (r.nsid != 0xffffffff ? (int64_t)r.nsid : -1);
627 }
628 if (r.valid & 0x02) {
629 uint64_t lba = sg_get_unaligned_le64(r.lba);
630 snprintf(lb, sizeof(lb), "%" PRIu64, lba);
631 jrefi["lba"] = lba;
632 }
633 if (r.valid & 0x04) {
634 snprintf(st, sizeof(st), "0x%x", r.status_code_type);
635 jrefi["status_code_type"] = r.status_code_type;
636 }
637 if (r.valid & 0x08) {
638 snprintf(sc, sizeof(sc), "0x%02x", r.status_code);
639 jrefi["status_code"] = r.status_code;
640 }
641
642 if (++cnt == 1)
643 jout("Num Test_Description Status Power_on_Hours Failing_LBA NSID Seg SCT Code\n");
644 jout("%2u %-17s %-33s %9" PRIu64 " %12s %5s %3s %3s %4s\n", i, t, s, poh, lb, ns, sg, st, sc);
645 }
646
647 if (!cnt)
648 jout("No Self-tests Logged\n");
649 jout("\n");
650}
651
652int nvmePrintMain(nvme_device * device, const nvme_print_options & options)
653{
654 if (!( options.drive_info || options.drive_capabilities
655 || options.smart_check_status || options.smart_vendor_attrib
656 || options.smart_selftest_log || options.error_log_entries
657 || options.log_page_size || options.smart_selftest_type )) {
658 pout("NVMe device successfully opened\n\n"
659 "Use 'smartctl -a' (or '-x') to print SMART (and more) information\n\n");
660 return 0;
661 }
662
663 // Show unset optional values only if debugging is enabled
664 bool show_all = (nvme_debugmode > 0);
665
666 // Read Identify Controller always
667 nvme_id_ctrl id_ctrl;
668 if (!nvme_read_id_ctrl(device, id_ctrl)) {
669 jerr("Read NVMe Identify Controller failed: %s\n", device->get_errmsg());
670 return FAILID;
671 }
672
673 // Print Identify Controller/Namespace info
674 if (options.drive_info || options.drive_capabilities) {
675 pout("=== START OF INFORMATION SECTION ===\n");
676 nvme_id_ns id_ns; memset(&id_ns, 0, sizeof(id_ns));
677
678 unsigned nsid = device->get_nsid();
679 if (nsid == 0xffffffffU) {
680 // Broadcast namespace
681 if (id_ctrl.nn == 1) {
682 // No namespace management, get size from single namespace
683 nsid = 1;
684 if (!nvme_read_id_ns(device, nsid, id_ns))
685 nsid = 0;
686 }
687 }
688 else {
689 // Identify current namespace
690 if (!nvme_read_id_ns(device, nsid, id_ns)) {
691 jerr("Read NVMe Identify Namespace 0x%x failed: %s\n", nsid, device->get_errmsg());
692 return FAILID;
693 }
694 }
695
696 if (options.drive_info)
697 print_drive_info(id_ctrl, id_ns, nsid, show_all);
698 if (options.drive_capabilities)
699 print_drive_capabilities(id_ctrl, id_ns, nsid, show_all);
700 pout("\n");
701 }
702
703 if ( options.smart_check_status || options.smart_vendor_attrib
704 || options.error_log_entries || options.smart_selftest_log )
705 pout("=== START OF SMART DATA SECTION ===\n");
706
707 // Print SMART Status and SMART/Health Information
708 int retval = 0;
709 if (options.smart_check_status || options.smart_vendor_attrib) {
710 nvme_smart_log smart_log;
711 if (!nvme_read_smart_log(device, smart_log)) {
712 jerr("Read NVMe SMART/Health Information failed: %s\n\n", device->get_errmsg());
713 return FAILSMART;
714 }
715
716 if (options.smart_check_status) {
718 if (smart_log.critical_warning)
719 retval |= FAILSTATUS;
720 }
721
722 if (options.smart_vendor_attrib) {
723 print_smart_log(smart_log, id_ctrl, show_all);
724 }
725 }
726
727 // Check for Log Page Offset support
728 bool lpo_sup = !!(id_ctrl.lpa & 0x04);
729
730 // Print Error Information Log
731 if (options.error_log_entries) {
732 unsigned max_entries = id_ctrl.elpe + 1; // 0's based value
733 unsigned want_entries = options.error_log_entries;
734 if (want_entries > max_entries)
735 want_entries = max_entries;
736 raw_buffer error_log_buf(want_entries * sizeof(nvme_error_log_page));
737 nvme_error_log_page * error_log =
738 reinterpret_cast<nvme_error_log_page *>(error_log_buf.data());
739
740 unsigned read_entries = nvme_read_error_log(device, error_log, want_entries, lpo_sup);
741 if (!read_entries) {
742 jerr("Read %u entries from Error Information Log failed: %s\n\n",
743 want_entries, device->get_errmsg());
744 return retval | FAILSMART;
745 }
746 if (read_entries < want_entries)
747 jerr("Read Error Information Log failed, %u entries missing: %s\n",
748 want_entries - read_entries, device->get_errmsg());
749
750 print_error_log(error_log, read_entries, max_entries);
751 }
752
753 // Check for self-test support
754 bool self_test_sup = !!(id_ctrl.oacs & 0x0010);
755
756 // Use broadcast NSID for self-tests if only one namespace is supported.
757 // Some single namespace devices return failure if NSID=1 is used to
758 // address self-tests.
759 // TODO: Support NSID=0 to test controller
760 unsigned self_test_nsid = (id_ctrl.nn == 1 ? 0xffffffff : device->get_nsid());
761
762 // Read and print Self-test log, check for running test
763 int self_test_completion = -1;
764 if (options.smart_selftest_log || options.smart_selftest_type) {
765 if (!self_test_sup)
766 pout("Self-tests not supported\n\n");
767 else {
768 nvme_self_test_log self_test_log;
769 if (!nvme_read_self_test_log(device, self_test_nsid, self_test_log)) {
770 jerr("Read Self-test Log failed: %s\n\n", device->get_errmsg());
771 return retval | FAILSMART;
772 }
773
774 if (options.smart_selftest_log)
775 print_self_test_log(self_test_log, self_test_nsid);
776
777 if (self_test_log.current_operation & 0xf)
778 self_test_completion = self_test_log.current_completion & 0x7f;
779 }
780 }
781
782 // Dump log page
783 if (options.log_page_size) {
784 // Align size to dword boundary
785 unsigned size = ((options.log_page_size + 4-1) / 4) * 4;
786 raw_buffer log_buf(size);
787
788 unsigned nsid;
789 switch (options.log_page) {
790 case 1:
791 case 2:
792 case 3:
793 nsid = 0xffffffff;
794 break;
795 default:
796 nsid = device->get_nsid();
797 break;
798 }
799 unsigned read_bytes = nvme_read_log_page(device, nsid, options.log_page, log_buf.data(),
800 size, lpo_sup);
801 if (!read_bytes) {
802 jerr("Read NVMe Log 0x%02x (NSID 0x%x) failed: %s\n\n", options.log_page, nsid,
803 device->get_errmsg());
804 return retval | FAILSMART;
805 }
806 if (read_bytes < size)
807 jerr("Read NVMe Log 0x%02x failed, 0x%x bytes missing: %s\n",
808 options.log_page, size - read_bytes, device->get_errmsg());
809
810 pout("NVMe Log 0x%02x (NSID 0x%x, 0x%04x bytes)\n", options.log_page, nsid, read_bytes);
811 dStrHex(log_buf.data(), read_bytes, 0);
812 pout("\n");
813 }
814
815 // Start self-test
816 if (self_test_sup && options.smart_selftest_type) {
817 bool self_test_abort = (options.smart_selftest_type == 0xf);
818 if (!self_test_abort && self_test_completion >= 0) {
819 pout("Can't start self-test without aborting current test (%2d%% completed)\n"
820 "Use smartctl -X to abort test\n", self_test_completion);
821 retval |= FAILSMART;
822 }
823 else {
824 if (!nvme_self_test(device, options.smart_selftest_type, self_test_nsid)) {
825 jerr("NVMe Self-test cmd with type=0x%x, nsid=0x%x failed: %s\n\n",
826 options.smart_selftest_type, self_test_nsid, device->get_errmsg());
827 return retval | FAILSMART;
828 }
829
830 if (!self_test_abort)
831 pout("Self-test has begun (NSID 0x%x)\n"
832 "Use smartctl -X to abort test\n", self_test_nsid);
833 else
834 pout("Self-test aborted! (NSID 0x%x)\n", self_test_nsid);
835 }
836 }
837
838 return retval;
839}
bool dont_print_serial_number
Definition: atacmds.cpp:37
Reference to a JSON element.
Definition: json.h:105
void set_unsafe_uint128(uint64_t value_hi, uint64_t value_lo)
Definition: json.cpp:205
void set_unsafe_le128(const void *pvalue)
Definition: json.cpp:231
void set_unsafe_uint64(uint64_t value)
Definition: json.cpp:193
NVMe device access.
unsigned get_nsid() const
Get namespace id.
unsigned char * data()
Definition: utility.h:148
const char * get_errmsg() const
Get last error message.
u32 w[3]
Definition: megaraid.h:19
u16 s[6]
Definition: megaraid.h:18
u32 size
Definition: megaraid.h:0
uint32_t nsid
bool nvme_read_self_test_log(nvme_device *device, uint32_t nsid, smartmontools::nvme_self_test_log &self_test_log)
Definition: nvmecmds.cpp:270
bool nvme_read_id_ns(nvme_device *device, unsigned nsid, nvme_id_ns &id_ns)
Definition: nvmecmds.cpp:169
bool nvme_read_id_ctrl(nvme_device *device, nvme_id_ctrl &id_ctrl)
Definition: nvmecmds.cpp:132
unsigned char nvme_debugmode
Definition: nvmecmds.cpp:27
bool nvme_self_test(nvme_device *device, uint8_t stc, uint32_t nsid)
Definition: nvmecmds.cpp:285
bool nvme_read_smart_log(nvme_device *device, nvme_smart_log &smart_log)
Definition: nvmecmds.cpp:254
unsigned nvme_read_log_page(nvme_device *device, unsigned nsid, unsigned char lid, void *data, unsigned size, bool lpo_sup, unsigned offset)
Definition: nvmecmds.cpp:208
unsigned nvme_read_error_log(nvme_device *device, nvme_error_log_page *error_log, unsigned num_entries, bool lpo_sup)
Definition: nvmecmds.cpp:231
const char * nvme_status_to_info_str(char *buf, size_t bufsize, uint16_t status)
Definition: nvmecmds.cpp:490
static void print_self_test_log(const nvme_self_test_log &self_test_log, unsigned nsid)
Definition: nvmeprint.cpp:545
static void print_drive_info(const nvme_id_ctrl &id_ctrl, const nvme_id_ns &id_ns, unsigned nsid, bool show_all)
Definition: nvmeprint.cpp:108
static const char * le128_to_str(char(&str)[64], uint64_t hi, uint64_t lo, unsigned bytes_per_unit)
Definition: nvmeprint.cpp:43
static void print_drive_capabilities(const nvme_id_ctrl &id_ctrl, const nvme_id_ns &id_ns, unsigned nsid, bool show_all)
Definition: nvmeprint.cpp:226
int nvmePrintMain(nvme_device *device, const nvme_print_options &options)
Definition: nvmeprint.cpp:652
static const char * format_power(char(&str)[16], unsigned power, unsigned scale)
Definition: nvmeprint.cpp:211
static void lbacap_to_js(const json::ref &jref, uint64_t lba_cnt, int lba_bits)
Definition: nvmeprint.cpp:92
static const char * kelvin_to_str(char(&str)[64], int k)
Definition: nvmeprint.cpp:99
static void print_critical_warning(unsigned char w)
Definition: nvmeprint.cpp:336
static void print_smart_log(const nvme_smart_log &smart_log, const nvme_id_ctrl &id_ctrl, bool show_all)
Definition: nvmeprint.cpp:372
static void print_error_log(const nvme_error_log_page *error_log, unsigned read_entries, unsigned max_entries)
Definition: nvmeprint.cpp:448
static const char * lbacap_to_str(char(&str)[64], uint64_t lba_cnt, int lba_bits)
Definition: nvmeprint.cpp:86
static bool le128_is_non_zero(const unsigned char(&val)[16])
Definition: nvmeprint.cpp:32
const char * nvmeprint_cvsid
Definition: nvmeprint.cpp:16
#define NVMEPRINT_H_CVSID
Definition: nvmeprint.h:14
void dStrHex(const uint8_t *up, int len, int no_ascii)
Definition: scsicmds.cpp:368
static uint64_t sg_get_unaligned_le64(const void *p)
Definition: sg_unaligned.h:303
static uint64_t sg_get_unaligned_be(int num_bytes, const void *p)
Definition: sg_unaligned.h:350
static uint16_t sg_get_unaligned_le16(const void *p)
Definition: sg_unaligned.h:292
static uint64_t sg_get_unaligned_le(int num_bytes, const void *p)
Definition: sg_unaligned.h:413
void jout_startup_datetime(const char *prefix)
Definition: smartctl.cpp:1449
json jglb
Definition: smartctl.cpp:53
#define FAILID
Definition: smartctl.h:30
#define FAILSTATUS
Definition: smartctl.h:36
#define FAILSMART
Definition: smartctl.h:33
void void void void jerr(const char *fmt,...) __attribute_format_printf(1
void jout(const char *fmt,...) __attribute_format_printf(1
void pout(const char *fmt,...)
Definition: smartd.cpp:1338
bool smart_selftest_log
Definition: nvmeprint.h:25
unsigned char smart_selftest_type
Definition: nvmeprint.h:26
unsigned char log_page
Definition: nvmeprint.h:28
unsigned log_page_size
Definition: nvmeprint.h:29
bool smart_vendor_attrib
Definition: nvmeprint.h:24
unsigned error_log_entries
Definition: nvmeprint.h:27
bool drive_capabilities
Definition: nvmeprint.h:22
bool smart_check_status
Definition: nvmeprint.h:23
unsigned short parm_error_location
Definition: nvmecmds.h:39
unsigned short wctemp
Definition: nvmecmds.h:92
unsigned short ssvid
Definition: nvmecmds.h:68
unsigned short cntlid
Definition: nvmecmds.h:76
unsigned char unvmcap[16]
Definition: nvmecmds.h:98
struct nvme_id_power_state psd[32]
Definition: nvmecmds.h:133
unsigned char ieee[3]
Definition: nvmecmds.h:73
unsigned short vid
Definition: nvmecmds.h:67
unsigned char tnvmcap[16]
Definition: nvmecmds.h:97
unsigned short oacs
Definition: nvmecmds.h:83
unsigned short cctemp
Definition: nvmecmds.h:93
struct nvme_lbaf lbaf[16]
Definition: nvmecmds.h:170
unsigned char nsfeat
Definition: nvmecmds.h:149
unsigned char nlbaf
Definition: nvmecmds.h:150
unsigned char flbas
Definition: nvmecmds.h:151
unsigned char eui64[8]
Definition: nvmecmds.h:169
unsigned short ms
Definition: nvmecmds.h:139
unsigned char ds
Definition: nvmecmds.h:140
unsigned char rp
Definition: nvmecmds.h:141
nvme_self_test_result results[20]
Definition: nvmecmds.h:248
unsigned char data_units_read[16]
Definition: nvmecmds.h:183
unsigned char spare_thresh
Definition: nvmecmds.h:180
unsigned char critical_warning
Definition: nvmecmds.h:177
unsigned char host_writes[16]
Definition: nvmecmds.h:186
unsigned char data_units_written[16]
Definition: nvmecmds.h:184
unsigned char power_on_hours[16]
Definition: nvmecmds.h:189
unsigned int thm_temp1_total_time
Definition: nvmecmds.h:198
unsigned char host_reads[16]
Definition: nvmecmds.h:185
unsigned char temperature[2]
Definition: nvmecmds.h:178
unsigned char power_cycles[16]
Definition: nvmecmds.h:188
unsigned char media_errors[16]
Definition: nvmecmds.h:191
unsigned char percent_used
Definition: nvmecmds.h:181
unsigned int critical_comp_time
Definition: nvmecmds.h:194
unsigned char num_err_log_entries[16]
Definition: nvmecmds.h:192
unsigned short temp_sensor[8]
Definition: nvmecmds.h:195
unsigned char unsafe_shutdowns[16]
Definition: nvmecmds.h:190
unsigned char ctrl_busy_time[16]
Definition: nvmecmds.h:187
unsigned int thm_temp2_total_time
Definition: nvmecmds.h:199
unsigned int thm_temp2_trans_count
Definition: nvmecmds.h:197
unsigned int warning_temp_time
Definition: nvmecmds.h:193
unsigned int thm_temp1_trans_count
Definition: nvmecmds.h:196
const char * format_char_array(char *str, int strsize, const char *chr, int chrsize)
Definition: utility.cpp:692
const char * format_capacity(char *str, int strsize, uint64_t val, const char *decimal_point)
Definition: utility.cpp:748
const char * format_with_thousands_sep(char *str, int strsize, uint64_t val, const char *thousands_sep)
Definition: utility.cpp:716
bool nonempty(const void *data, int size)
Definition: utility.cpp:682
const char * uint128_hilo_to_str(char *str, int strsize, uint64_t value_hi, uint64_t value_lo)
Definition: utility.cpp:856
int uint128_to_str_precision_bits()
Definition: utility.h:296