xref: /illumos-gate/usr/src/uts/common/sys/scsi/adapters/mfi/mfi_ld.h (revision 98f0a994ee13c4f450852a3d01f2e340abe69fb8)
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 Racktop Systems, Inc.
14  */
15 
16 #ifndef	_MFI_LD_H
17 #define	_MFI_LD_H
18 
19 #include <sys/debug.h>
20 #include <sys/types.h>
21 
22 #include <sys/scsi/adapters/mfi/mfi.h>
23 #include <sys/scsi/adapters/mfi/mfi_pd.h>
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #define	MFI_SPARE_DEDICATED		1
30 #define	MFI_SPARE_REVERTIBLE		2
31 #define	MFI_SPARE_ENCL_AFFINITY		4
32 
33 #define	MFI_LD_STATE_OFFLINE		0
34 #define	MFI_LD_STATE_PARTIALLY_DEGRADED	1
35 #define	MFI_LD_STATE_DEGRADED		2
36 #define	MFI_LD_STATE_OPTIMAL		3
37 
38 #define	MFI_LD_PARAMS_INIT_NO		0
39 #define	MFI_LD_PARAMS_INIT_QUICK	1
40 #define	MFI_LD_PARAMS_INIT_FULL		2
41 
42 #define	MFI_LD_ACCESS_RW		0
43 #define	MFI_LD_ACCESS_RO		2
44 #define	MFI_LD_ACCESS_BLOCKED		3
45 
46 #define	MFI_LD_CACHE_WRITE_BACK			0x01
47 #define	MFI_LD_CACHE_WRITE_ADAPTIVE		0x02
48 #define	MFI_LD_CACHE_READ_AHEAD			0x04
49 #define	MFI_LD_CACHE_READ_ADAPTIVE		0x08
50 #define	MFI_LD_CACHE_WRITE_CACHE_BAD_BBU	0x10
51 #define	MFI_LD_CACHE_ALLOW_WRITE_CACHE		0x20
52 #define	MFI_LD_CACHE_ALLOW_READ_CACHE		0x40
53 
54 #define	MFI_MAX_ARRAYS			16
55 #define	MFI_MAX_ROW_SIZE		32
56 #define	MFI_MAX_SPAN_DEPTH		8
57 
58 #pragma pack(1)
59 
60 /*
61  * Array configuration
62  */
63 struct mfi_array {
64 	uint64_t	ar_size;
65 	uint8_t		ar_ndrive;
66 	uint8_t		ar_rsvd;
67 	uint16_t	ar_ref;
68 	uint8_t		ar_pad[20];
69 	struct {
70 		mfi_pd_ref_t	pd_ref;
71 		uint16_t	pd_fw_state;
72 		struct {
73 			uint8_t	e_idx;
74 			uint8_t	e_slot;
75 		} pd_encl;
76 	} ar_pd[MFI_MAX_ROW_SIZE];
77 };
78 CTASSERT(sizeof (mfi_array_t) == 288);
79 
80 /*
81  * Spare
82  */
83 struct mfi_spare {
84 	mfi_pd_ref_t	s_pd_ref;
85 	uint8_t		s_type;
86 	uint8_t		s_rsvd[2];
87 	uint8_t		s_array_cnt;
88 	uint16_t	s_array_ref[MFI_MAX_ARRAYS];
89 };
90 CTASSERT(sizeof (mfi_spare_t) == 40);
91 
92 /*
93  * LD reference
94  */
95 struct mfi_ld_ref {
96 	uint8_t		lr_tgtid;
97 	uint8_t		lr_rsvd;
98 	uint16_t	lr_seqnum;
99 };
100 CTASSERT(sizeof (mfi_ld_ref_t) == 4);
101 
102 /*
103  * LD list
104  */
105 struct mfi_ld_list {
106 	uint32_t	ll_ld_count;
107 	uint32_t	ll_rsvd;
108 	struct {
109 		mfi_ld_ref_t	ld_ref;
110 		uint8_t		ld_state;
111 		uint8_t		ld_rsvd[3];
112 		uint64_t	ld_size;
113 	} ll_ld[MFI_MAX_LOGICAL_DRIVES];
114 };
115 CTASSERT(sizeof (mfi_ld_list_t) == 1032);
116 
117 /*
118  * LD parameters
119  */
120 struct mfi_ld_parameters {
121 	uint8_t		lp_primary_raid_lvl;
122 	uint8_t		lp_raid_lvl_qual;
123 	uint8_t		lp_secondary_raid_lvl;
124 	uint8_t		lp_stripe_size;
125 	uint8_t		lp_ndrive;
126 	uint8_t		lp_span_depth;
127 	uint8_t		lp_state;
128 	uint8_t		lp_init_state;
129 	uint8_t		lp_is_consistent;
130 	uint8_t		lp_rsvd1[6];
131 	uint8_t		lp_is_sscd;
132 	uint8_t		lp_rsvd2[16];
133 };
134 CTASSERT(sizeof (mfi_ld_parameters_t) == 32);
135 
136 /*
137  * LD properties
138  */
139 struct mfi_ld_properties {
140 	mfi_ld_ref_t	lp_ld;
141 	char		lp_name[16];
142 	uint8_t		lp_def_cache_policy;
143 	uint8_t		lp_access_policy;
144 	uint8_t		lp_disk_cache_policy;
145 	uint8_t		lp_cur_cache_policy;
146 	uint8_t		lp_no_bgi;
147 	uint8_t		lp_rsvd[7];
148 };
149 CTASSERT(sizeof (mfi_ld_properties_t) == 32);
150 
151 /*
152  * LD span
153  */
154 struct mfi_span {
155 	uint64_t	s_start_block;
156 	uint64_t	s_num_blocks;
157 	uint16_t	s_array_ref;
158 	uint8_t		s_rsvd[6];
159 };
160 CTASSERT(sizeof (mfi_span_t) == 24);
161 
162 /*
163  * LD configuration
164  */
165 struct mfi_ld_config {
166 	mfi_ld_properties_t	lc_props;
167 	mfi_ld_parameters_t	lc_params;
168 	mfi_span_t		lc_span[MFI_MAX_SPAN_DEPTH];
169 };
170 CTASSERT(sizeof (mfi_ld_config_t) == 256);
171 
172 /*
173  * LD progress
174  */
175 struct mfi_ld_progress {
176 	struct {
177 		uint32_t	lp_active_cc:1;
178 		uint32_t	lp_active_bgi:1;
179 		uint32_t	lp_active_fgi:1;
180 		uint32_t	lp_active_recon:1;
181 		uint32_t	lp_active_rsvd:28;
182 	};
183 	mfi_progress_t		lp_cc;
184 	mfi_progress_t		lp_bgi;
185 	mfi_progress_t		lp_fgi;
186 	mfi_progress_t		lp_recon;
187 	mfi_progress_t		lp_rsvd[4];
188 };
189 CTASSERT(sizeof (mfi_ld_progress_t) == 36);
190 
191 /*
192  * LD information
193  */
194 struct mfi_ld_info {
195 	mfi_ld_config_t		li_config;
196 	uint64_t		li_size;
197 	mfi_ld_progress_t	li_progress;
198 	uint16_t		li_cluster_owner;
199 	uint8_t			li_recon_active;
200 	uint8_t			li_resvd1;
201 	uint8_t			li_vpd_page83[64];
202 	uint8_t			li_resvd2[16];
203 };
204 CTASSERT(sizeof (mfi_ld_info_t) == 384);
205 
206 /*
207  * LD target ID list
208  */
209 struct mfi_ld_tgtid_list {
210 	uint32_t	ltl_size;
211 	uint32_t	ltl_count;
212 	uint8_t		ltl_rsvd[3];
213 	uint8_t		ltl_tgtid[0];
214 };
215 
216 /*
217  * RAID configuration
218  */
219 struct mfi_config_data {
220 	uint32_t	cd_size;
221 	uint16_t	cd_array_cnt;
222 	uint16_t	cd_array_size;
223 	uint16_t	cd_ld_cnt;
224 	uint16_t	cd_ld_size;
225 	uint16_t	cd_spare_cnt;
226 	uint16_t	cd_spare_size;
227 	uint8_t		cd_rsvd[16];
228 	mfi_array_t	cd_array[0];
229 	mfi_ld_config_t	cd_ld[0];
230 	mfi_spare_t	cd_spare[0];
231 };
232 
233 #pragma pack(0)
234 #ifdef __cplusplus
235 }
236 #endif
237 
238 #endif	/* _MFI_LD_H */
239