]>
git.proxmox.com Git - mirror_smartmontools-debian.git/blob - nvmecmds.h
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 4297 2016-04-16 16:48:01Z chrfranke $"
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
;
95 unsigned char rsvd96
[160];
105 unsigned short wctemp
;
106 unsigned short cctemp
;
110 unsigned char tnvmcap
[16];
111 unsigned char unvmcap
[16];
113 unsigned char rsvd316
[196];
116 unsigned char rsvd514
[2];
119 unsigned short fuses
;
123 unsigned short awupf
;
125 unsigned char rsvd531
;
127 unsigned char rsvd534
[2];
129 unsigned char rsvd540
[1508];
130 struct nvme_id_power_state psd
[32];
131 unsigned char vs
[1024];
144 unsigned char nsfeat
;
151 unsigned char rescap
;
153 unsigned char rsvd33
;
154 unsigned short nawun
;
155 unsigned short nawupf
;
156 unsigned short nacwu
;
157 unsigned short nabsn
;
159 unsigned short nabspf
;
160 unsigned char rsvd46
[2];
161 unsigned char nvmcap
[16];
162 unsigned char rsvd64
[40];
163 unsigned char nguid
[16];
164 unsigned char eui64
[8];
165 struct nvme_lbaf lbaf
[16];
166 unsigned char rsvd192
[192];
167 unsigned char vs
[3712];
170 struct nvme_smart_log
{
171 unsigned char critical_warning
;
172 unsigned char temperature
[2];
173 unsigned char avail_spare
;
174 unsigned char spare_thresh
;
175 unsigned char percent_used
;
176 unsigned char rsvd6
[26];
177 unsigned char data_units_read
[16];
178 unsigned char data_units_written
[16];
179 unsigned char host_reads
[16];
180 unsigned char host_writes
[16];
181 unsigned char ctrl_busy_time
[16];
182 unsigned char power_cycles
[16];
183 unsigned char power_on_hours
[16];
184 unsigned char unsafe_shutdowns
[16];
185 unsigned char media_errors
[16];
186 unsigned char num_err_log_entries
[16];
187 unsigned int warning_temp_time
;
188 unsigned int critical_comp_time
;
189 unsigned short temp_sensor
[8];
190 unsigned char rsvd216
[296];
193 enum nvme_admin_opcode
{
194 //nvme_admin_delete_sq = 0x00,
195 //nvme_admin_create_sq = 0x01,
196 nvme_admin_get_log_page
= 0x02,
197 //nvme_admin_delete_cq = 0x04,
198 //nvme_admin_create_cq = 0x05,
199 nvme_admin_identify
= 0x06,
200 //nvme_admin_abort_cmd = 0x08,
201 //nvme_admin_set_features = 0x09,
202 //nvme_admin_get_features = 0x0a,
203 //nvme_admin_async_event = 0x0c,
204 //nvme_admin_ns_mgmt = 0x0d,
205 //nvme_admin_activate_fw = 0x10,
206 //nvme_admin_download_fw = 0x11,
207 //nvme_admin_ns_attach = 0x15,
208 //nvme_admin_format_nvm = 0x80,
209 //nvme_admin_security_send = 0x81,
210 //nvme_admin_security_recv = 0x82,
213 // END: From <linux/nvme.h>
214 ////////////////////////////////////////////////////////////////////////////
216 } // namespace smartmontools
220 // Print NVMe debug messages?
221 extern unsigned char nvme_debugmode
;
223 // Read NVMe Identify Controller data structure.
224 bool nvme_read_id_ctrl(nvme_device
* device
, smartmontools::nvme_id_ctrl
& id_ctrl
);
226 // Read NVMe Identify Namespace data structure for namespace NSID.
227 bool nvme_read_id_ns(nvme_device
* device
, unsigned nsid
, smartmontools::nvme_id_ns
& id_ns
);
229 // Read NVMe log page with identifier LID.
230 bool nvme_read_log_page(nvme_device
* device
, unsigned char lid
, void * data
, unsigned size
);
232 // Read NVMe Error Information Log.
233 bool nvme_read_error_log(nvme_device
* device
, smartmontools::nvme_error_log_page
* error_log
,
234 unsigned num_entries
);
236 // Read NVMe SMART/Health Information log.
237 bool nvme_read_smart_log(nvme_device
* device
, smartmontools::nvme_smart_log
& smart_log
);