xref: /illumos-gate/usr/src/uts/common/sys/nvme/solidigm.h (revision 7655c6d53c36750b508636f48c73a2de57754e5a)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2024 Oxide Computer company
14  */
15 
16 #ifndef _SYS_NVME_SOLIDIGM_H
17 #define	_SYS_NVME_SOLIDIGM_H
18 
19 /*
20  * This header defines vendor-specific NVMe interfaces and is not a committed
21  * interface. Its contents and existence are subject to change.
22  *
23  * This header contains all of the current vendor-specific entries for supported
24  * Solidigm devices as well as common structures and definitions that are shared
25  * across multiple device families. This also contains the Intel variants as
26  * these devices have been rebranded over time and therefore works as a
27  * reasonable consolidation point for the Intel branded devices too.
28  */
29 
30 #include <sys/nvme/solidigm_p5xxx.h>
31 #include <sys/nvme/solidigm_ps10x0.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #define	INTEL_PCI_VID		0x8086
38 #define	SOLIDIGM_PCI_VID	0x25e
39 
40 /*
41  * All data structures must be packed to account for the layout from the various
42  * programmer's manuals.
43  */
44 #pragma pack(1)
45 
46 /*
47  * This represents a single entry which is used as part of the device-specific
48  * SMART log (generally opcode 0xca).
49  */
50 typedef struct {
51 	uint8_t sse_type;
52 	uint8_t sse_rsvd2[2];
53 	uint8_t sse_norm;
54 	uint8_t sse_rsvd4;
55 	uint8_t sse_raw[6];
56 	uint8_t sse_rsvd11;
57 } solidigm_smart_ent_t;
58 
59 /*
60  * These are the different type keys that exist for the solidigm_smart_ent_t
61  * above. These will show up in an arbitrary order in the device log.
62  */
63 typedef enum {
64 	SOLIDIGM_SMART_TYPE_PROGRAM_FAIL	= 0xab,
65 	SOLIDIGM_SMART_TYPE_ERASE_FAIL		= 0xac,
66 	SOLIDIGM_SMART_TYPE_WEAR_LEVEL		= 0xad,
67 	SOLIDIGM_SMART_TYPE_E2E_ERROR_DET	= 0xb8,
68 	SOLIDIGM_SMART_TYPE_CRC_ERROR		= 0xc7,
69 	SOLIDIGM_SMART_TYPE_TIMED_MEDIA_WEAR	= 0xe2,
70 	SOLIDIGM_SMART_TYPE_TIMED_HOST_READ	= 0xe3,
71 	SOLIDIGM_SMART_TYPE_TIMED_TIMER		= 0xe4,
72 	SOLIDIGM_SMART_TYPE_IN_FLIGHT_READ	= 0xe5,
73 	SOLIDIGM_SMART_TYPE_IN_FLIGHT_WRITE	= 0xe6,
74 	SOLIDIGM_SMART_TYPE_THERM_THROTTLE	= 0xea,
75 	SOLIDIGM_SMART_TYPE_RESKU		= 0xee,
76 	SOLIDIGM_SMART_TYPE_RETRY_BUF_OVRFLW	= 0xf0,
77 	SOLIDIGM_SMART_TYPE_PLL_LOSS		= 0xf3,
78 	SOLIDIGM_SMART_TYPE_NAND_WRITE		= 0xf4,
79 	SOLIDIGM_SMART_TYPE_HOST_WRITE		= 0xf5,
80 	SOLIDIGM_SMART_TYPE_SYS_LIFE		= 0xf6,
81 	SOLIDIGM_SMART_TYPE_NAND_READ		= 0xf8,
82 	SOLIDIGM_SMART_TYPE_AVAIL_FW_DOWN	= 0xf9,
83 	SOLIDIGM_SMART_TYPE_READ_COLL		= 0xfa,
84 	SOLIDIGM_SMART_TYPE_WRITE_COLL		= 0xfb,
85 	SOLIDIGM_SMART_TYPE_XOR_PASS		= 0xfc,
86 	SOLIDIGM_SMART_TYPE_XOR_FAIL		= 0xfd,
87 	SOLIDIGM_SMART_TYPE_XOR_INVOKE		= 0xfe,
88 } solidigm_smart_type_t;
89 
90 /*
91  * We size this based on the number of items that'll fit into a single 512 byte
92  * log page.
93  */
94 typedef struct {
95 	solidigm_smart_ent_t vsl_data[512 / sizeof (solidigm_smart_ent_t)];
96 } solidigm_vul_smart_log_t;
97 
98 /*
99  * Common temperature structure across different device generations.
100  * Temperatures are all measured in units of degrees C.
101  */
102 typedef struct {
103 	uint64_t temp_cur;
104 	uint64_t temp_over_last;
105 	uint64_t temp_over_life;
106 	uint64_t temp_comp_life_high;
107 	uint64_t temp_comp_life_low;
108 	uint8_t temp_rsvd40[40];
109 	uint64_t temp_norm_max_warn;
110 	uint8_t temp_rsvd88[8];
111 	uint64_t temp_spec_min_op;
112 	uint64_t temp_est_off;
113 } solidigm_vul_temp_t;
114 
115 #pragma	pack()	/* pack(1) */
116 
117 /*
118  * Our current version of smatch cannot handle packed structures.
119  */
120 #ifndef __CHECKER__
121 CTASSERT(sizeof (solidigm_smart_ent_t) == 12);
122 CTASSERT(sizeof (solidigm_vul_smart_log_t) <= 512);
123 CTASSERT(sizeof (solidigm_vul_smart_log_t) > 500);
124 CTASSERT(sizeof (solidigm_vul_temp_t) == 112);
125 #endif	/* __CHECKER__ */
126 
127 #ifdef __cplusplus
128 }
129 #endif
130 
131 #endif /* _SYS_NVME_SOLIDIGM_H */
132