]>
git.proxmox.com Git - mirror_smartmontools-debian.git/blob - nvmecmds.h
3e8f62f84789379ef3f2500f9fa1d265ac82b2c2
4 * Home page of code is: http://www.smartmontools.org
6 * Copyright (C) 2016 Christian Franke
8 * Original code from <linux/nvme.h>:
9 * Copyright (C) 2011-2014 Intel Corporation
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
16 * You should have received a copy of the GNU General Public License
17 * (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
24 #define NVMECMDS_H_CVSID "$Id: nvmecmds.h 4488 2017-09-25 11:54:15Z samm2 $"
28 // The code below was orginally imported from <linux/nvme.h> include file from
29 // Linux kernel sources. Types from <linux/types.h> were replaced.
30 // Symbol names are unchanged but placed in a namespace to allow inclusion
31 // of the original <linux/nvme.h>.
32 namespace smartmontools
{
34 ////////////////////////////////////////////////////////////////////////////
35 // BEGIN: From <linux/nvme.h>
37 * Definitions for the NVM Express interface
38 * Copyright (c) 2011-2014, Intel Corporation.
40 * This program is free software; you can redistribute it and/or modify it
41 * under the terms and conditions of the GNU General Public License,
42 * version 2, as published by the Free Software Foundation.
44 * This program is distributed in the hope it will be useful, but WITHOUT
45 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
46 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
50 struct nvme_error_log_page
{
54 unsigned short status_field
;
55 unsigned short parm_error_location
;
59 unsigned char resv
[35];
62 struct nvme_id_power_state
{
63 unsigned short max_power
; // centiwatts
66 unsigned int entry_lat
; // microseconds
67 unsigned int exit_lat
; // microseconds
68 unsigned char read_tput
;
69 unsigned char read_lat
;
70 unsigned char write_tput
;
71 unsigned char write_lat
;
72 unsigned short idle_power
;
73 unsigned char idle_scale
;
75 unsigned short active_power
;
76 unsigned char active_work_scale
;
77 unsigned char rsvd23
[9];
87 unsigned char ieee
[3];
90 unsigned short cntlid
;
96 unsigned char rsvd100
[156];
106 unsigned short wctemp
;
107 unsigned short cctemp
;
111 unsigned char tnvmcap
[16];
112 unsigned char unvmcap
[16];
114 unsigned short edstt
;
118 unsigned short hctma
;
119 unsigned short mntmt
;
120 unsigned short mxtmt
;
121 unsigned int sanicap
;
122 unsigned char rsvd332
[180];
125 unsigned short maxcmd
;
128 unsigned short fuses
;
132 unsigned short awupf
;
134 unsigned char rsvd531
;
136 unsigned char rsvd534
[2];
138 unsigned char rsvd540
[228];
140 unsigned char rsvd1024
[768];
143 unsigned short icdoff
;
144 unsigned char ctrattr
;
146 unsigned char rsvd1804
[244];
147 struct nvme_id_power_state psd
[32];
148 unsigned char vs
[1024];
161 unsigned char nsfeat
;
168 unsigned char rescap
;
170 unsigned char rsvd33
;
171 unsigned short nawun
;
172 unsigned short nawupf
;
173 unsigned short nacwu
;
174 unsigned short nabsn
;
176 unsigned short nabspf
;
177 unsigned char rsvd46
[2];
178 unsigned char nvmcap
[16];
179 unsigned char rsvd64
[40];
180 unsigned char nguid
[16];
181 unsigned char eui64
[8];
182 struct nvme_lbaf lbaf
[16];
183 unsigned char rsvd192
[192];
184 unsigned char vs
[3712];
187 struct nvme_smart_log
{
188 unsigned char critical_warning
;
189 unsigned char temperature
[2];
190 unsigned char avail_spare
;
191 unsigned char spare_thresh
;
192 unsigned char percent_used
;
193 unsigned char rsvd6
[26];
194 unsigned char data_units_read
[16];
195 unsigned char data_units_written
[16];
196 unsigned char host_reads
[16];
197 unsigned char host_writes
[16];
198 unsigned char ctrl_busy_time
[16];
199 unsigned char power_cycles
[16];
200 unsigned char power_on_hours
[16];
201 unsigned char unsafe_shutdowns
[16];
202 unsigned char media_errors
[16];
203 unsigned char num_err_log_entries
[16];
204 unsigned int warning_temp_time
;
205 unsigned int critical_comp_time
;
206 unsigned short temp_sensor
[8];
207 unsigned int thm_temp1_trans_count
;
208 unsigned int thm_temp2_trans_count
;
209 unsigned int thm_temp1_total_time
;
210 unsigned int thm_temp2_total_time
;
211 unsigned char rsvd232
[280];
214 enum nvme_admin_opcode
{
215 //nvme_admin_delete_sq = 0x00,
216 //nvme_admin_create_sq = 0x01,
217 nvme_admin_get_log_page
= 0x02,
218 //nvme_admin_delete_cq = 0x04,
219 //nvme_admin_create_cq = 0x05,
220 nvme_admin_identify
= 0x06,
221 //nvme_admin_abort_cmd = 0x08,
222 //nvme_admin_set_features = 0x09,
223 //nvme_admin_get_features = 0x0a,
224 //nvme_admin_async_event = 0x0c,
225 //nvme_admin_ns_mgmt = 0x0d,
226 //nvme_admin_activate_fw = 0x10,
227 //nvme_admin_download_fw = 0x11,
228 //nvme_admin_ns_attach = 0x15,
229 //nvme_admin_format_nvm = 0x80,
230 //nvme_admin_security_send = 0x81,
231 //nvme_admin_security_recv = 0x82,
234 // END: From <linux/nvme.h>
235 ////////////////////////////////////////////////////////////////////////////
237 } // namespace smartmontools
241 // Print NVMe debug messages?
242 extern unsigned char nvme_debugmode
;
244 // Read NVMe Identify Controller data structure.
245 bool nvme_read_id_ctrl(nvme_device
* device
, smartmontools::nvme_id_ctrl
& id_ctrl
);
247 // Read NVMe Identify Namespace data structure for namespace NSID.
248 bool nvme_read_id_ns(nvme_device
* device
, unsigned nsid
, smartmontools::nvme_id_ns
& id_ns
);
250 // Read NVMe log page with identifier LID.
251 bool nvme_read_log_page(nvme_device
* device
, unsigned char lid
, void * data
, unsigned size
);
253 // Read NVMe Error Information Log.
254 bool nvme_read_error_log(nvme_device
* device
, smartmontools::nvme_error_log_page
* error_log
,
255 unsigned num_entries
);
257 // Read NVMe SMART/Health Information log.
258 bool nvme_read_smart_log(nvme_device
* device
, smartmontools::nvme_smart_log
& smart_log
);