xref: /illumos-gate/usr/src/uts/common/sys/nvme/micron.h (revision f334afcfaebea1b7dc3430015651d8d748fa8a3e)
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/debug.h>
31 #include <sys/stdint.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #define	MICRON_PCI_VID	0x1344
38 
39 /*
40  * All data structures must be packed to account for the layout from the various
41  * programmer's manuals.
42  */
43 #pragma pack(1)
44 
45 /*
46  * Micron has a common extended SMART log that is used between multiple device
47  * families. Some fields have been added in newer device generations and they
48  * are reserved otherwise.
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_rsvd1[24];
56 	uint32_t mes_wp_reason;
57 	uint8_t mes_rsvd2[12];
58 	uint64_t mes_cap;
59 	uint8_t mes_rsvd3[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_rsvd4[8];
67 	uint64_t mes_uecc;
68 	uint8_t mes_rsvd5[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_rsvd6[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_size;
80 	uint8_t mes_rsvd7[16];
81 	uint32_t mes_user_erase_min;
82 	uint32_t mes_user_erase_max;
83 	uint32_t mes_user_erase_avg;
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