xref: /illumos-gate/usr/src/uts/common/sys/nvme/micron.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_MICRON_H
17 #define	_SYS_NVME_MICRON_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 known
24  * Micron devices as well as common structures and definitions that are shared
25  * across multiple device families.
26  */
27 
28 #include <sys/nvme/micron_7300.h>
29 #include <sys/nvme/micron_74x0.h>
30 #include <sys/nvme/micron_x500.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #define	MICRON_PCI_VID	0x1344
37 
38 /*
39  * All data structures must be packed to account for the layout from the various
40  * programmer's manuals.
41  */
42 #pragma pack(1)
43 
44 /*
45  * Micron has a common extended SMART log that is used between multiple device
46  * families. Some fields have been added in newer device generations and they
47  * are reserved otherwise. Starting in the 6500/7500+ generation, the structure
48  * was extended in size and is defined in its device-specific section.
49  */
50 typedef struct {
51 	uint8_t mes_rsvd0[12];
52 	uint32_t mes_gbb;
53 	uint32_t mes_max_erase;
54 	uint32_t mes_power_on;
55 	uint8_t mes_rsvd24[24];
56 	uint32_t mes_wp_reason;
57 	uint8_t mes_rsvd52[12];
58 	uint64_t mes_cap;
59 	uint8_t mes_rsvd72[8];
60 	uint64_t mes_erase_count;
61 	uint64_t mes_use_rate;
62 	/*
63 	 * Begin 7400+ specific fields.
64 	 */
65 	uint64_t mes_erase_fail;
66 	uint8_t mes_rsvd104[8];
67 	uint64_t mes_uecc;
68 	uint8_t mes_rsvd120[24];
69 	uint8_t mes_prog_fail[16];
70 	uint8_t mes_read_bytes[16];
71 	uint8_t mes_write_bytes[16];
72 	uint8_t mes_rsvd192[16];
73 	/*
74 	 * End 7400+ specific fields.
75 	 */
76 	uint32_t mes_trans_size;
77 	uint32_t mes_bs_total;
78 	uint32_t mes_bs_free;
79 	uint64_t mes_bs_cap;
80 	uint8_t mes_rsvd228[16];
81 	uint32_t mes_user_erase_min;
82 	uint32_t mes_user_erase_avg;
83 	uint32_t mes_user_erase_max;
84 } micron_vul_ext_smart_t;
85 
86 typedef enum {
87 	MICRON_VUL_WP_R_DRAM_DOUBLE_BIT		= 1 << 0,
88 	MICRON_VUL_WP_R_LOW_SPARE_BLOCKS	= 1 << 1,
89 	MICRON_VUL_WP_R_CAP_FAILURE		= 1 << 2,
90 	MICRON_VUL_WP_R_NVRAM_CKSUM		= 1 << 3,
91 	MICRON_VUL_WP_R_DRAM_RANGE		= 1 << 4,
92 	MICRON_VUL_WP_R_OVERTEMP		= 1 << 5
93 } micron_vul_wp_reason_t;
94 
95 /*
96  * Smatch can't handle packed structure sizeof calculations correctly,
97  * unfortunately.
98  */
99 #ifndef __CHECKER__
100 CTASSERT(sizeof (micron_vul_ext_smart_t) == 0x100);
101 #endif
102 
103 #pragma	pack()	/* pack(1) */
104 
105 #ifdef __cplusplus
106 }
107 #endif
108 
109 #endif /* _SYS_NVME_MICRON_H */
110