2 * Copyright (c) 2016 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * Get Log Page - Error Information (Log ID 01) (64 bytes)
50 uint64_t csi
; /* command specific information */
51 uint8_t reserved40
[24];
52 } __packed nvme_log_error_data_t
;
55 * Get Log Page - Smart/ Health Information (Log ID 02) (512 bytes)
61 uint8_t spare_cap
; /* normalized spare capacity 0-100 */
62 uint8_t spare_thresh
; /* event when cap falls below value */
63 uint8_t rated_life
; /* 0-100, may exceed capped at 255 */
64 uint8_t reserved6
[26];
66 /* 16-byte fields lo, hi */
67 uint64_t read_count
[2]; /* in 512000 byte units */
68 uint64_t write_count
[2]; /* in 512000 byte units */
69 uint64_t read_cmds
[2];
70 uint64_t write_cmds
[2];
71 uint64_t busy_time
[2]; /* in minutes */
72 uint64_t power_cycles
[2];
73 uint64_t powon_hours
[2];
74 uint64_t unsafe_shutdowns
[2];
75 uint64_t unrecoverable_errors
[2];
76 uint64_t error_log_entries
[2];
78 uint32_t warn_comp_temp_time
; /* minutes temp > warn level */
79 uint32_t crit_comp_temp_time
; /* minutes temp > crit level */
81 uint16_t temp_sensors
[8]; /* sensors 1-8 in kelvin 0=unimp */
83 uint8_t reserved216
[296];
84 } __packed nvme_log_smart_data_t
;
86 #define NVME_SMART_CRF_BELOW_THRESH 0x01
87 #define NVME_SMART_CRF_ABOVE_THRESH 0x02 /* or below under-temp thresh*/
88 #define NVME_SMART_CRF_UNRELIABLE 0x04
89 #define NVME_SMART_CRF_MEDIA_RO 0x08
90 #define NVME_SMART_CRF_VOLTL_BKUP_FAIL 0x10
91 #define NVME_SMART_CRF_RES20 0x20
92 #define NVME_SMART_CRF_RES40 0x40
93 #define NVME_SMART_CRF_RES80 0x80
96 * Firmware Slot Information (Log ID 03) (512 bytes)
100 uint8_t reserved1
[7];
101 uint64_t revision
[7]; /* revision slot 1-7 */
102 uint8_t reserved64
[448];
103 } __packed nvme_fw_slot_data_t
;
105 #define NVME_FWSLOT_CRF_RESERVED_80 0x80
106 #define NVME_FWSLOT_CRF_FWNEXT_MASK 0x70
107 #define NVME_FWSLOT_CRF_RESERVED_08 0x08
108 #define NVME_FWSLOT_CRF_FWCURR_MASK 0x07
110 #define NVME_FWSLOT_CRF_FWNEXT_GET(data) \
111 (((data) & NVME_FWSLOT_CRF_FWNEXT_MASK) >> 4)
112 #define NVME_FWSLOT_CRF_FWCURR_GET(data) \
113 ((data) & NVME_FWSLOT_CRF_FWCURR_MASK)
116 * Command Supported and Effects (Log ID 05) (4096 bytes)
118 * Iterates available admin and I/O commands, one command-effects data
119 * structure for each command, indexed by command id.
121 * CSE - Indicates whether command must be serialized (i.e. no other
122 * commands may be pending in the namespace or globally).
124 * CSUPP - Indicates that the command is supported by the controller
125 * (use for iteration skip).
128 uint32_t admin_cmds
[256];
129 uint32_t io_cmds
[256];
130 } __packed nvme_cmdeff_data_t
;
132 #define NVME_CMDEFF_RESERVED19 0xFFF80000U
133 #define NVME_CMDEFF_CSE_MASK 0x00007000U
134 #define NVME_CMDEFF_RESERVED05 0x00000FE0U
135 #define NVME_CMDEFF_CCC 0x00000010U
136 #define NVME_CMDEFF_NIC 0x00000008U
137 #define NVME_CMDEFF_NCC 0x00000004U
138 #define NVME_CMDEFF_LBCC 0x00000002U
139 #define NVME_CMDEFF_CSUPP 0x00000001U
141 #define NVME_CMDEFF_CSE_NORM 0x00000000U
142 #define NVME_CMDEFF_CSE_NS_SERIALIZE 0x00001000U
143 #define NVME_CMDEFF_CSE_GLOB_SERIALIZE 0x00002000U
146 * Reservation Notification (Log ID 0x80) (64 bytes)
149 uint64_t logpg_count
;
152 uint8_t reserved10
[2];
154 uint8_t reserved16
[48];
155 } __packed nvme_resnotify_data_t
;
157 #define NVME_RESNOTIFY_EMPTY 0x00
158 #define NVME_RESNOTIFY_REG_PREEMPTED 0x01
159 #define NVME_RESNOTIFY_RES_RELEASED 0x02
160 #define NVME_RESNOTIFY_RES_PREEMPTED 0x03
163 /* TYPE_CSS status */
164 #define NVME_RESNOTIFY_INVALID 0x09