summaryrefslogtreecommitdiffstats
path: root/plugins/ssstc/ssstc-nvme.c
blob: 03e4fe3f9f640ae25371a5605a290a09800a8e01 (plain)
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
// SPDX-License-Identifier: GPL-2.0-or-later
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>

#include "common.h"
#include "nvme.h"
#include "libnvme.h"
#include "plugin.h"
#include "linux/types.h"
#include "nvme-print.h"

#define CREATE_CMD
#include "ssstc-nvme.h"

struct  __packed nvme_additional_smart_log_item
{
	__u8 key;
	__u8 norm;
	union __packed {
		__u8 raw[6];
		struct __packed wear_level
		{
			__le16	min;
			__le16	max;
			__le16	avg;
		} wear_level;
	};
	__u8 _rp[2];
};

struct nvme_additional_smart_log {
	struct nvme_additional_smart_log_item	program_fail_cnt;
	struct nvme_additional_smart_log_item	erase_fail_cnt;
	struct nvme_additional_smart_log_item	wear_leveling_cnt;
	struct nvme_additional_smart_log_item	e2e_err_cnt;
	struct nvme_additional_smart_log_item	crc_err_cnt;
	struct nvme_additional_smart_log_item	nand_bytes_written;
	struct nvme_additional_smart_log_item	host_bytes_written;
	struct nvme_additional_smart_log_item	reallocated_sector_count;
	struct nvme_additional_smart_log_item	uncorrectable_sector_count;
	struct nvme_additional_smart_log_item	NAND_ECC_Detection_Count;
	struct nvme_additional_smart_log_item	NAND_ECC_Correction_Count;
	struct nvme_additional_smart_log_item	Bad_Block_Failure_Rate;
	struct nvme_additional_smart_log_item	GC_Count;
	struct nvme_additional_smart_log_item	DRAM_UECC_Detection_Count;
	struct nvme_additional_smart_log_item	SRAM_UECC_Detection_Count;
	struct nvme_additional_smart_log_item	Raid_Recovery_Fail_Count;
	struct nvme_additional_smart_log_item	Inflight_Command;
	struct nvme_additional_smart_log_item	Internal_End_to_End_Dect_Count;
	struct nvme_additional_smart_log_item	PCIe_Correctable_Error_Count;
	struct nvme_additional_smart_log_item	die_fail_count;
	struct nvme_additional_smart_log_item	wear_leveling_exec_count;
	struct nvme_additional_smart_log_item	read_disturb_count;
	struct nvme_additional_smart_log_item	data_retention_count;
};


static
void show_ssstc_add_smart_log_jsn(struct nvme_additional_smart_log *smart,
		unsigned int nsid, const char *devname)
{
	struct json_object *root, *entry_stats, *dev_stats, *multi;
	__uint16_t wear_level_min = 0;
	__uint16_t wear_level_max = 0;
	__uint16_t wear_level_avg = 0;
	uint64_t raw_val = 0;

	root = json_create_object();
	json_object_add_value_string(root, "SSSTC Smart log", devname);

	dev_stats = json_create_object();

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->program_fail_cnt.key);
	json_object_add_value_int(entry_stats, "normalized", smart->program_fail_cnt.norm);
	raw_val = int48_to_long(smart->program_fail_cnt.raw);
	json_object_add_value_int(entry_stats, "raw", raw_val);
	json_object_add_value_object(dev_stats, "program_fail_count", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->erase_fail_cnt.key);
	json_object_add_value_int(entry_stats, "normalized", smart->erase_fail_cnt.norm);
	raw_val = int48_to_long(smart->erase_fail_cnt.raw);
	json_object_add_value_int(entry_stats, "raw", raw_val);
	json_object_add_value_object(dev_stats, "erase_fail_count", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->wear_leveling_cnt.key);
	json_object_add_value_int(entry_stats, "normalized", smart->wear_leveling_cnt.norm);
	multi = json_create_object();
	wear_level_min = le16_to_cpu(smart->wear_leveling_cnt.wear_level.min);
	wear_level_max = le16_to_cpu(smart->wear_leveling_cnt.wear_level.max);
	wear_level_avg = le16_to_cpu(smart->wear_leveling_cnt.wear_level.avg);
	json_object_add_value_int(multi, "min", wear_level_min);
	json_object_add_value_int(multi, "max", wear_level_max);
	json_object_add_value_int(multi, "avg", wear_level_avg);
	json_object_add_value_object(entry_stats, "raw", multi);
	json_object_add_value_object(dev_stats, "wear_leveling", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->e2e_err_cnt.key);
	json_object_add_value_int(entry_stats, "normalized", smart->e2e_err_cnt.norm);
	multi = json_create_object();
	wear_level_min = le16_to_cpu(smart->e2e_err_cnt.wear_level.min);
	wear_level_max = le16_to_cpu(smart->e2e_err_cnt.wear_level.max);
	wear_level_avg = le16_to_cpu(smart->e2e_err_cnt.wear_level.avg);
	json_object_add_value_int(multi, "guard check error", wear_level_min);
	json_object_add_value_int(multi, "application tag check error", wear_level_max);
	json_object_add_value_int(multi, "reference tag check error", wear_level_avg);
	json_object_add_value_object(entry_stats, "raw", multi);
	json_object_add_value_object(dev_stats, "end_to_end_error_dect_count", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->crc_err_cnt.key);
	json_object_add_value_int(entry_stats, "normalized", smart->crc_err_cnt.norm);
	raw_val = int48_to_long(smart->crc_err_cnt.raw);
	json_object_add_value_int(entry_stats, "raw", raw_val);
	json_object_add_value_object(dev_stats, "crc_error_count", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->nand_bytes_written.key);
	json_object_add_value_int(entry_stats, "normalized", smart->nand_bytes_written.norm);
	raw_val = int48_to_long(smart->nand_bytes_written.raw);
	json_object_add_value_int(entry_stats, "raw", raw_val);
	json_object_add_value_object(dev_stats, "nand_bytes_written", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->host_bytes_written.key);
	json_object_add_value_int(entry_stats, "normalized", smart->host_bytes_written.norm);
	raw_val = int48_to_long(smart->host_bytes_written.raw);
	json_object_add_value_int(entry_stats, "raw", raw_val);
	json_object_add_value_object(dev_stats, "host_bytes_written", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->reallocated_sector_count.key);
	json_object_add_value_int(entry_stats, "normalized", smart->reallocated_sector_count.norm);
	raw_val = int48_to_long(smart->reallocated_sector_count.raw);
	json_object_add_value_int(entry_stats, "raw", raw_val);
	json_object_add_value_object(dev_stats, "reallocated_sector_count", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->uncorrectable_sector_count.key);
	json_object_add_value_int(entry_stats, "normalized",
		smart->uncorrectable_sector_count.norm);
	raw_val = int48_to_long(smart->uncorrectable_sector_count.raw);
	json_object_add_value_int(entry_stats, "raw", raw_val);
	json_object_add_value_object(dev_stats, "uncorrectable_sector_count", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->NAND_ECC_Detection_Count.key);
	json_object_add_value_int(entry_stats, "normalized", smart->NAND_ECC_Detection_Count.norm);
	raw_val = int48_to_long(smart->NAND_ECC_Detection_Count.raw);
	json_object_add_value_int(entry_stats, "raw", raw_val);
	json_object_add_value_object(dev_stats, "NAND_ECC_detection_count", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->NAND_ECC_Correction_Count.key);
	json_object_add_value_int(entry_stats, "normalized", smart->NAND_ECC_Correction_Count.norm);
	raw_val = int48_to_long(smart->NAND_ECC_Correction_Count.raw);
	json_object_add_value_int(entry_stats, "raw", raw_val);
	json_object_add_value_object(dev_stats, "NAND_ECC_correction_count", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->GC_Count.key);
	json_object_add_value_int(entry_stats, "normalized", smart->GC_Count.norm);
	raw_val = int48_to_long(smart->GC_Count.raw);
	json_object_add_value_int(entry_stats, "raw", raw_val);
	json_object_add_value_object(dev_stats, "GC_count", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->DRAM_UECC_Detection_Count.key);
	json_object_add_value_int(entry_stats, "normalized", smart->DRAM_UECC_Detection_Count.norm);
	multi = json_create_object();
	wear_level_max = le16_to_cpu(smart->DRAM_UECC_Detection_Count.wear_level.max);
	wear_level_avg = le16_to_cpu(smart->DRAM_UECC_Detection_Count.wear_level.avg);
	json_object_add_value_int(multi, "1-Bit Err", wear_level_max);
	json_object_add_value_int(multi, "2-Bit Err", wear_level_avg);
	json_object_add_value_object(entry_stats, "raw", multi);
	json_object_add_value_object(dev_stats, "DRAM_UECC_detection_count", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->SRAM_UECC_Detection_Count.key);
	json_object_add_value_int(entry_stats, "normalized", smart->SRAM_UECC_Detection_Count.norm);
	multi = json_create_object();
	wear_level_min = le16_to_cpu(smart->SRAM_UECC_Detection_Count.wear_level.min);
	wear_level_max = le16_to_cpu(smart->SRAM_UECC_Detection_Count.wear_level.max);
	wear_level_avg = le16_to_cpu(smart->SRAM_UECC_Detection_Count.wear_level.avg);
	json_object_add_value_int(multi, "parity error detected", wear_level_min);
	json_object_add_value_int(multi, "ecc error detection", wear_level_max);
	json_object_add_value_int(multi, "axi data parity errors", wear_level_avg);
	json_object_add_value_object(entry_stats, "raw", multi);
	json_object_add_value_object(dev_stats, "SRAM_UECC_Detection_Count", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->Raid_Recovery_Fail_Count.key);
	json_object_add_value_int(entry_stats, "normalized", smart->Raid_Recovery_Fail_Count.norm);
	raw_val = int48_to_long(smart->Raid_Recovery_Fail_Count.raw);
	json_object_add_value_int(entry_stats, "raw", raw_val);
	json_object_add_value_object(dev_stats, "raid_Recovery_fail_count", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->Inflight_Command.key);
	json_object_add_value_int(entry_stats, "normalized", smart->Inflight_Command.norm);
	multi = json_create_object();
	wear_level_min = le16_to_cpu(smart->Inflight_Command.wear_level.min);
	wear_level_max = le16_to_cpu(smart->Inflight_Command.wear_level.max);
	wear_level_avg = le16_to_cpu(smart->Inflight_Command.wear_level.avg);
	json_object_add_value_int(multi, "Read Cmd", wear_level_min);
	json_object_add_value_int(multi, "Write Cmd", wear_level_max);
	json_object_add_value_int(multi, "Admin Cmd", wear_level_avg);
	json_object_add_value_object(entry_stats, "raw", multi);
	json_object_add_value_object(dev_stats, "Inflight_Command", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->Internal_End_to_End_Dect_Count.key);
	json_object_add_value_int(entry_stats, "normalized", 100);
	multi = json_create_object();
	wear_level_min = le16_to_cpu(smart->Internal_End_to_End_Dect_Count.wear_level.min);
	wear_level_max = le16_to_cpu(smart->Internal_End_to_End_Dect_Count.wear_level.max);
	wear_level_avg = le16_to_cpu(smart->Internal_End_to_End_Dect_Count.wear_level.avg);
	json_object_add_value_int(multi, "read hcrc", wear_level_min);
	json_object_add_value_int(multi, "write hcrc", wear_level_max);
	json_object_add_value_int(multi, "reserved", wear_level_avg);
	json_object_add_value_object(entry_stats, "raw", multi);
	json_object_add_value_object(dev_stats, "internal_end_to_end_dect_count", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->die_fail_count.key);
	json_object_add_value_int(entry_stats, "normalized", smart->die_fail_count.norm);
	raw_val = int48_to_long(smart->die_fail_count.raw);
	json_object_add_value_int(entry_stats, "raw", raw_val);
	json_object_add_value_object(dev_stats, "die_fail_count", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->wear_leveling_exec_count.key);
	json_object_add_value_int(entry_stats, "normalized", smart->wear_leveling_exec_count.norm);
	raw_val = int48_to_long(smart->wear_leveling_exec_count.raw);
	json_object_add_value_int(entry_stats, "raw", raw_val);
	json_object_add_value_object(dev_stats, "wear_leveling_exec_count", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->read_disturb_count.key);
	json_object_add_value_int(entry_stats, "normalized", smart->read_disturb_count.norm);
	raw_val = int48_to_long(smart->read_disturb_count.raw);
	json_object_add_value_int(entry_stats, "raw", raw_val);
	json_object_add_value_object(dev_stats, "read_disturb_count", entry_stats);

	entry_stats = json_create_object();
	json_object_add_value_int(entry_stats, "#id", smart->data_retention_count.key);
	json_object_add_value_int(entry_stats, "normalized", smart->data_retention_count.norm);
	raw_val = int48_to_long(smart->data_retention_count.raw);
	json_object_add_value_int(entry_stats, "raw", raw_val);
	json_object_add_value_object(dev_stats, "data_retention_count", entry_stats);

	json_object_add_value_object(root, "Device stats", dev_stats);

	json_print_object(root, NULL);
	json_free_object(root);
}

static
void show_ssstc_add_smart_log(struct nvme_additional_smart_log *smart,
		unsigned int nsid, const char *devname)
{
	printf("Additional Smart Log for NVME device:%s namespace-id:%x\n",
		devname, nsid);
	printf("key                               #id  normalized raw\n");
	printf("program_fail_count              : %03d  %3d%%       %"PRIu64"\n",
		smart->program_fail_cnt.key,
		smart->program_fail_cnt.norm,
		int48_to_long(smart->program_fail_cnt.raw));
	printf("erase_fail_count                : %03d  %3d%%       %"PRIu64"\n",
		smart->erase_fail_cnt.key,
		smart->erase_fail_cnt.norm,
		int48_to_long(smart->erase_fail_cnt.raw));
	printf("wear_leveling                   : %03d  %3d%%       min: %u, max: %u, avg: %u\n",
		smart->wear_leveling_cnt.key,
		smart->wear_leveling_cnt.norm,
		le16_to_cpu(smart->wear_leveling_cnt.wear_level.min),
		le16_to_cpu(smart->wear_leveling_cnt.wear_level.max),
		le16_to_cpu(smart->wear_leveling_cnt.wear_level.avg));
	printf("end_to_end_error_dect_count     : %03d  %3d%%       "
		"guard check error: %u, "
		"application tag check error: %u, "
		"reference tag check error: %u\n",
		smart->e2e_err_cnt.key,
		smart->e2e_err_cnt.norm,
		le16_to_cpu(smart->e2e_err_cnt.wear_level.min),
		le16_to_cpu(smart->e2e_err_cnt.wear_level.max),
		le16_to_cpu(smart->e2e_err_cnt.wear_level.avg));
	printf("crc_error_count                 : %03d  %3d%%       %"PRIu64"\n",
		smart->crc_err_cnt.key,
		smart->crc_err_cnt.norm,
		int48_to_long(smart->crc_err_cnt.raw));
	printf("nand_bytes_written              : %03d  %3d%%       sectors: %"PRIu64"\n",
		smart->nand_bytes_written.key,
		smart->nand_bytes_written.norm,
		int48_to_long(smart->nand_bytes_written.raw));
	printf("host_bytes_written              : %3d  %3d%%       sectors: %"PRIu64"\n",
		smart->host_bytes_written.key,
		smart->host_bytes_written.norm,
		int48_to_long(smart->host_bytes_written.raw));
	printf("reallocated_sector_count        : %03d  %3d%%       %"PRIu64"\n",
		smart->reallocated_sector_count.key,
		smart->reallocated_sector_count.norm,
		int48_to_long(smart->reallocated_sector_count.raw));
	printf("uncorrectable_sector_count      : %03d  %3d%%       %"PRIu64"\n",
		smart->uncorrectable_sector_count.key,
		smart->uncorrectable_sector_count.norm,
		int48_to_long(smart->uncorrectable_sector_count.raw));
	printf("NAND_ECC_detection_count        : %03d  %3d%%       %"PRIu64"\n",
		smart->NAND_ECC_Detection_Count.key,
		smart->NAND_ECC_Detection_Count.norm,
		int48_to_long(smart->NAND_ECC_Detection_Count.raw));
	printf("NAND_ECC_correction_count       : %03d  %3d%%       %"PRIu64"\n",
		smart->NAND_ECC_Correction_Count.key,
		smart->NAND_ECC_Correction_Count.norm,
		int48_to_long(smart->NAND_ECC_Correction_Count.raw));
	printf("GC_count                        : %03d  %3d%%       %"PRIu64"\n",
		smart->GC_Count.key,
		smart->GC_Count.norm,
		int48_to_long(smart->GC_Count.raw));
	printf("DRAM_UECC_detection_count       : %03d  %3d%%       1-Bit Err: %u, 2-Bit Err: %u\n",
		smart->DRAM_UECC_Detection_Count.key,
		smart->DRAM_UECC_Detection_Count.norm,
		le16_to_cpu(smart->DRAM_UECC_Detection_Count.wear_level.max),
		le16_to_cpu(smart->DRAM_UECC_Detection_Count.wear_level.avg));
	printf("SRAM_UECC_Detection_Count       : %03d  %3d%%       "
		"parity error detected: %u, "
		"ecc error detection: %u, "
		"axi data parity errors: %u\n",
		smart->SRAM_UECC_Detection_Count.key,
		smart->SRAM_UECC_Detection_Count.norm,
		le16_to_cpu(smart->SRAM_UECC_Detection_Count.wear_level.min),
		le16_to_cpu(smart->SRAM_UECC_Detection_Count.wear_level.max),
		le16_to_cpu(smart->SRAM_UECC_Detection_Count.wear_level.avg));
	printf("raid_recovery_fail_count        : %03d  %3d%%       %"PRIu64"\n",
		smart->Raid_Recovery_Fail_Count.key,
		smart->Raid_Recovery_Fail_Count.norm,
		int48_to_long(smart->Raid_Recovery_Fail_Count.raw));
	printf("Inflight_Command                : %03d  %3d%%       "
		"Read Cmd: %u, Write Cmd: %u, Admin Cmd: %u\n",
		smart->Inflight_Command.key,
		smart->Inflight_Command.norm,
		le16_to_cpu(smart->Inflight_Command.wear_level.min),
		le16_to_cpu(smart->Inflight_Command.wear_level.max),
		le16_to_cpu(smart->Inflight_Command.wear_level.avg));
	printf("internal_end_to_end_dect_count  : %03d  %3d%%       "
		"read hcrc: %u, write hcrc: %u, reserved: %u\n",
		smart->Internal_End_to_End_Dect_Count.key,
		100,
		le16_to_cpu(smart->Internal_End_to_End_Dect_Count.wear_level.min),
		le16_to_cpu(smart->Internal_End_to_End_Dect_Count.wear_level.max),
		le16_to_cpu(smart->Internal_End_to_End_Dect_Count.wear_level.avg));
	printf("die_fail_count                  : %03d  %3d%%       %"PRIu64"\n",
		smart->die_fail_count.key,
		smart->die_fail_count.norm,
		int48_to_long(smart->die_fail_count.raw));
	printf("wear_leveling_exec_count        : %03d  %3d%%       %"PRIu64"\n",
		smart->wear_leveling_exec_count.key,
		smart->wear_leveling_exec_count.norm,
		int48_to_long(smart->wear_leveling_exec_count.raw));
	printf("read_disturb_count              : %03d  %3d%%       %"PRIu64"\n",
		smart->read_disturb_count.key,
		smart->read_disturb_count.norm,
		int48_to_long(smart->read_disturb_count.raw));
	printf("data_retention_count            : %03d  %3d%%       %"PRIu64"\n",
		smart->data_retention_count.key,
		smart->data_retention_count.norm,
		int48_to_long(smart->data_retention_count.raw));
}

static
int ssstc_get_add_smart_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
{

	const char *desc =
		"Get SSSTC vendor specific additional smart log\n"
		"(optionally, for the specified namespace), and show it.";
	const char *namespace = "(optional) desired namespace";
	const char *raw = "Dump output in binary format";
	const char *json = "Dump output in json format";

	struct nvme_additional_smart_log smart_log_add;
	struct nvme_dev *dev;
	int err;

	struct config {
		__u32 namespace_id;
		bool  raw_binary;
		bool  json;
	};

	struct config cfg = {
		.namespace_id = NVME_NSID_ALL,
	};

	OPT_ARGS(opts) = {
		OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace),
		OPT_FLAG("raw-binary",   'b', &cfg.raw_binary,   raw),
		OPT_FLAG("json",         'j', &cfg.json,         json),
		OPT_END()
	};

	err = parse_and_open(&dev, argc, argv, desc, opts);
	if (err)
		return err;

	err = nvme_get_log_simple(dev_fd(dev), 0xca, sizeof(smart_log_add),
				  &smart_log_add);
	if (!err) {
		if (cfg.json)
			show_ssstc_add_smart_log_jsn(&smart_log_add, cfg.namespace_id,
						 dev->name);
		else if (!cfg.raw_binary)
			show_ssstc_add_smart_log(&smart_log_add, cfg.namespace_id,
					     dev->name);
		else
			d_raw((unsigned char *)&smart_log_add, sizeof(smart_log_add));
	} else if (err > 0) {
		nvme_show_status(err);
	}
	dev_close(dev);
	return err;

}