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