smartmontools SVN Rev 5407
Utility to control and monitor storage systems with "S.M.A.R.T."
nvmecmds.h
Go to the documentation of this file.
1/*
2 * nvmecmds.h
3 *
4 * Home page of code is: https://www.smartmontools.org
5 *
6 * Copyright (C) 2016-20 Christian Franke
7 *
8 * Original code from <linux/nvme.h>:
9 * Copyright (C) 2011-2014 Intel Corporation
10 *
11 * SPDX-License-Identifier: GPL-2.0-or-later
12 */
13
14#ifndef NVMECMDS_H
15#define NVMECMDS_H
16
17#define NVMECMDS_H_CVSID "$Id: nvmecmds.h 5124 2020-12-04 20:40:43Z chrfranke $"
18
19#include "static_assert.h"
20
21#include <stdint.h>
22
23// The code below was originally imported from <linux/nvme.h> include file from
24// Linux kernel sources. Types from <linux/types.h> were replaced.
25// Symbol names are unchanged but placed in a namespace to allow inclusion
26// of the original <linux/nvme.h>.
27namespace smartmontools {
28
29////////////////////////////////////////////////////////////////////////////
30// BEGIN: From <linux/nvme.h>
31
33 uint64_t error_count;
34 unsigned short sqid;
35 unsigned short cmdid;
36 unsigned short status_field;
37 unsigned short parm_error_location;
38 uint64_t lba;
39 unsigned int nsid;
40 unsigned char vs;
41 unsigned char resv[35];
42};
44
46 unsigned short max_power; // centiwatts
47 unsigned char rsvd2;
48 unsigned char flags;
49 unsigned int entry_lat; // microseconds
50 unsigned int exit_lat; // microseconds
51 unsigned char read_tput;
52 unsigned char read_lat;
53 unsigned char write_tput;
54 unsigned char write_lat;
55 unsigned short idle_power;
56 unsigned char idle_scale;
57 unsigned char rsvd19;
58 unsigned short active_power;
59 unsigned char active_work_scale;
60 unsigned char rsvd23[9];
61};
63
65 unsigned short vid;
66 unsigned short ssvid;
67 char sn[20];
68 char mn[40];
69 char fr[8];
70 unsigned char rab;
71 unsigned char ieee[3];
72 unsigned char cmic;
73 unsigned char mdts;
74 unsigned short cntlid;
75 unsigned int ver;
76 unsigned int rtd3r;
77 unsigned int rtd3e;
78 unsigned int oaes;
79 unsigned int ctratt;
80 unsigned char rsvd100[156];
81 unsigned short oacs;
82 unsigned char acl;
83 unsigned char aerl;
84 unsigned char frmw;
85 unsigned char lpa;
86 unsigned char elpe;
87 unsigned char npss;
88 unsigned char avscc;
89 unsigned char apsta;
90 unsigned short wctemp;
91 unsigned short cctemp;
92 unsigned short mtfa;
93 unsigned int hmpre;
94 unsigned int hmmin;
95 unsigned char tnvmcap[16];
96 unsigned char unvmcap[16];
97 unsigned int rpmbs;
98 unsigned short edstt;
99 unsigned char dsto;
100 unsigned char fwug;
101 unsigned short kas;
102 unsigned short hctma;
103 unsigned short mntmt;
104 unsigned short mxtmt;
105 unsigned int sanicap;
106 unsigned char rsvd332[180];
107 unsigned char sqes;
108 unsigned char cqes;
109 unsigned short maxcmd;
110 unsigned int nn;
111 unsigned short oncs;
112 unsigned short fuses;
113 unsigned char fna;
114 unsigned char vwc;
115 unsigned short awun;
116 unsigned short awupf;
117 unsigned char nvscc;
118 unsigned char rsvd531;
119 unsigned short acwu;
120 unsigned char rsvd534[2];
121 unsigned int sgls;
122 unsigned char rsvd540[228];
123 char subnqn[256];
124 unsigned char rsvd1024[768];
125 unsigned int ioccsz;
126 unsigned int iorcsz;
127 unsigned short icdoff;
128 unsigned char ctrattr;
129 unsigned char msdbd;
130 unsigned char rsvd1804[244];
132 unsigned char vs[1024];
133};
135
136struct nvme_lbaf {
137 unsigned short ms;
138 unsigned char ds;
139 unsigned char rp;
140};
142
144 uint64_t nsze;
145 uint64_t ncap;
146 uint64_t nuse;
147 unsigned char nsfeat;
148 unsigned char nlbaf;
149 unsigned char flbas;
150 unsigned char mc;
151 unsigned char dpc;
152 unsigned char dps;
153 unsigned char nmic;
154 unsigned char rescap;
155 unsigned char fpi;
156 unsigned char rsvd33;
157 unsigned short nawun;
158 unsigned short nawupf;
159 unsigned short nacwu;
160 unsigned short nabsn;
161 unsigned short nabo;
162 unsigned short nabspf;
163 unsigned char rsvd46[2];
164 unsigned char nvmcap[16];
165 unsigned char rsvd64[40];
166 unsigned char nguid[16];
167 unsigned char eui64[8];
168 struct nvme_lbaf lbaf[16];
169 unsigned char rsvd192[192];
170 unsigned char vs[3712];
171};
172STATIC_ASSERT(sizeof(nvme_id_ns) == 4096);
173
175 unsigned char critical_warning;
176 unsigned char temperature[2];
177 unsigned char avail_spare;
178 unsigned char spare_thresh;
179 unsigned char percent_used;
180 unsigned char rsvd6[26];
181 unsigned char data_units_read[16];
182 unsigned char data_units_written[16];
183 unsigned char host_reads[16];
184 unsigned char host_writes[16];
185 unsigned char ctrl_busy_time[16];
186 unsigned char power_cycles[16];
187 unsigned char power_on_hours[16];
188 unsigned char unsafe_shutdowns[16];
189 unsigned char media_errors[16];
190 unsigned char num_err_log_entries[16];
191 unsigned int warning_temp_time;
192 unsigned int critical_comp_time;
193 unsigned short temp_sensor[8];
198 unsigned char rsvd232[280];
199};
201
203//nvme_admin_delete_sq = 0x00,
204//nvme_admin_create_sq = 0x01,
206//nvme_admin_delete_cq = 0x04,
207//nvme_admin_create_cq = 0x05,
209//nvme_admin_abort_cmd = 0x08,
210//nvme_admin_set_features = 0x09,
211//nvme_admin_get_features = 0x0a,
212//nvme_admin_async_event = 0x0c,
213//nvme_admin_ns_mgmt = 0x0d,
214//nvme_admin_activate_fw = 0x10,
215//nvme_admin_download_fw = 0x11,
216//nvme_admin_ns_attach = 0x15,
217//nvme_admin_format_nvm = 0x80,
218//nvme_admin_security_send = 0x81,
219//nvme_admin_security_recv = 0x82,
220};
221
222// END: From <linux/nvme.h>
223////////////////////////////////////////////////////////////////////////////
224
225} // namespace smartmontools
226
227class nvme_device;
228
229// Print NVMe debug messages?
230extern unsigned char nvme_debugmode;
231
232// Read NVMe Identify Controller data structure.
234
235// Read NVMe Identify Namespace data structure for namespace NSID.
236bool nvme_read_id_ns(nvme_device * device, unsigned nsid, smartmontools::nvme_id_ns & id_ns);
237
238// Read NVMe log page with identifier LID.
239unsigned nvme_read_log_page(nvme_device * device, unsigned nsid, unsigned char lid,
240 void * data, unsigned size, bool lpo_sup, unsigned offset = 0);
241
242// Read NVMe Error Information Log.
244 unsigned num_entries, bool lpo_sup);
245
246// Read NVMe SMART/Health Information log.
248
249#endif // NVMECMDS_H
NVMe device access.
ptr_t data
Definition: megaraid.h:15
u32 size
Definition: megaraid.h:0
@ nvme_admin_identify
Definition: nvmecmds.h:208
@ nvme_admin_get_log_page
Definition: nvmecmds.h:205
STATIC_ASSERT(sizeof(nvme_error_log_page)==64)
uint32_t nsid
bool nvme_read_id_ns(nvme_device *device, unsigned nsid, smartmontools::nvme_id_ns &id_ns)
Definition: nvmecmds.cpp:163
unsigned char nvme_debugmode
Definition: nvmecmds.cpp:27
bool nvme_read_smart_log(nvme_device *device, smartmontools::nvme_smart_log &smart_log)
Definition: nvmecmds.cpp:247
unsigned nvme_read_error_log(nvme_device *device, smartmontools::nvme_error_log_page *error_log, unsigned num_entries, bool lpo_sup)
Definition: nvmecmds.cpp:225
bool nvme_read_id_ctrl(nvme_device *device, smartmontools::nvme_id_ctrl &id_ctrl)
Definition: nvmecmds.cpp:126
unsigned nvme_read_log_page(nvme_device *device, unsigned nsid, unsigned char lid, void *data, unsigned size, bool lpo_sup, unsigned offset=0)
Definition: nvmecmds.cpp:202
unsigned short parm_error_location
Definition: nvmecmds.h:37
unsigned short wctemp
Definition: nvmecmds.h:90
unsigned short ssvid
Definition: nvmecmds.h:66
unsigned short mntmt
Definition: nvmecmds.h:103
unsigned short mxtmt
Definition: nvmecmds.h:104
unsigned short cntlid
Definition: nvmecmds.h:74
unsigned char rsvd1024[768]
Definition: nvmecmds.h:124
unsigned char vs[1024]
Definition: nvmecmds.h:132
unsigned short maxcmd
Definition: nvmecmds.h:109
unsigned short hctma
Definition: nvmecmds.h:102
unsigned char unvmcap[16]
Definition: nvmecmds.h:96
struct nvme_id_power_state psd[32]
Definition: nvmecmds.h:131
unsigned short fuses
Definition: nvmecmds.h:112
unsigned char rsvd534[2]
Definition: nvmecmds.h:120
unsigned char rsvd1804[244]
Definition: nvmecmds.h:130
unsigned short mtfa
Definition: nvmecmds.h:92
unsigned short edstt
Definition: nvmecmds.h:98
unsigned short icdoff
Definition: nvmecmds.h:127
unsigned char rsvd332[180]
Definition: nvmecmds.h:106
unsigned char rsvd100[156]
Definition: nvmecmds.h:80
unsigned char ieee[3]
Definition: nvmecmds.h:71
unsigned short vid
Definition: nvmecmds.h:65
unsigned char rsvd540[228]
Definition: nvmecmds.h:122
unsigned char tnvmcap[16]
Definition: nvmecmds.h:95
unsigned short oacs
Definition: nvmecmds.h:81
unsigned short awupf
Definition: nvmecmds.h:116
unsigned short cctemp
Definition: nvmecmds.h:91
unsigned char rsvd192[192]
Definition: nvmecmds.h:169
struct nvme_lbaf lbaf[16]
Definition: nvmecmds.h:168
unsigned char nsfeat
Definition: nvmecmds.h:147
unsigned char vs[3712]
Definition: nvmecmds.h:170
unsigned short nabspf
Definition: nvmecmds.h:162
unsigned char rsvd64[40]
Definition: nvmecmds.h:165
unsigned short nacwu
Definition: nvmecmds.h:159
unsigned short nawun
Definition: nvmecmds.h:157
unsigned short nabo
Definition: nvmecmds.h:161
unsigned char nvmcap[16]
Definition: nvmecmds.h:164
unsigned short nabsn
Definition: nvmecmds.h:160
unsigned short nawupf
Definition: nvmecmds.h:158
unsigned char rescap
Definition: nvmecmds.h:154
unsigned char nlbaf
Definition: nvmecmds.h:148
unsigned char flbas
Definition: nvmecmds.h:149
unsigned char rsvd33
Definition: nvmecmds.h:156
unsigned char nguid[16]
Definition: nvmecmds.h:166
unsigned char rsvd46[2]
Definition: nvmecmds.h:163
unsigned char eui64[8]
Definition: nvmecmds.h:167
unsigned char nmic
Definition: nvmecmds.h:153
unsigned short ms
Definition: nvmecmds.h:137
unsigned char ds
Definition: nvmecmds.h:138
unsigned char rp
Definition: nvmecmds.h:139
unsigned char data_units_read[16]
Definition: nvmecmds.h:181
unsigned char spare_thresh
Definition: nvmecmds.h:178
unsigned char critical_warning
Definition: nvmecmds.h:175
unsigned char host_writes[16]
Definition: nvmecmds.h:184
unsigned char data_units_written[16]
Definition: nvmecmds.h:182
unsigned char power_on_hours[16]
Definition: nvmecmds.h:187
unsigned int thm_temp1_total_time
Definition: nvmecmds.h:196
unsigned char host_reads[16]
Definition: nvmecmds.h:183
unsigned char temperature[2]
Definition: nvmecmds.h:176
unsigned char power_cycles[16]
Definition: nvmecmds.h:186
unsigned char rsvd232[280]
Definition: nvmecmds.h:198
unsigned char media_errors[16]
Definition: nvmecmds.h:189
unsigned char percent_used
Definition: nvmecmds.h:179
unsigned int critical_comp_time
Definition: nvmecmds.h:192
unsigned char rsvd6[26]
Definition: nvmecmds.h:180
unsigned char num_err_log_entries[16]
Definition: nvmecmds.h:190
unsigned short temp_sensor[8]
Definition: nvmecmds.h:193
unsigned char unsafe_shutdowns[16]
Definition: nvmecmds.h:188
unsigned char ctrl_busy_time[16]
Definition: nvmecmds.h:185
unsigned int thm_temp2_total_time
Definition: nvmecmds.h:197
unsigned int thm_temp2_trans_count
Definition: nvmecmds.h:195
unsigned int warning_temp_time
Definition: nvmecmds.h:191
unsigned int thm_temp1_trans_count
Definition: nvmecmds.h:194