xref: /freebsd/sys/dev/isci/scil/sati_mode_pages.c (revision 43a5ec4eb41567cc92586503212743d89686d78f)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3  *
4  * This file is provided under a dual BSD/GPLv2 license.  When using or
5  * redistributing this file, you may do so under either license.
6  *
7  * GPL LICENSE SUMMARY
8  *
9  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of version 2 of the GNU General Public License as
13  * published by the Free Software Foundation.
14  *
15  * This program is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
23  * The full GNU General Public License is included in this distribution
24  * in the file called LICENSE.GPL.
25  *
26  * BSD LICENSE
27  *
28  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
29  * All rights reserved.
30  *
31  * Redistribution and use in source and binary forms, with or without
32  * modification, are permitted provided that the following conditions
33  * are met:
34  *
35  *   * Redistributions of source code must retain the above copyright
36  *     notice, this list of conditions and the following disclaimer.
37  *   * Redistributions in binary form must reproduce the above copyright
38  *     notice, this list of conditions and the following disclaimer in
39  *     the documentation and/or other materials provided with the
40  *     distribution.
41  *
42  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
46  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53  */
54 
55 #include <sys/cdefs.h>
56 __FBSDID("$FreeBSD$");
57 
58 /**
59  * @file
60  * @brief This file contains the mode page constants and data for the mode
61  *        pages supported by this translation implementation.
62  */
63 
64 // DO NOT MOVE THIS INCLUDE STATEMENT! This include must occur before
65 // the below check for ENABLE_SATI_MODE_PAGES.
66 #include <dev/isci/scil/sati_types.h>
67 
68 #if defined(ENABLE_SATI_MODE_PAGES)
69 
70 #include <dev/isci/scil/sati_mode_pages.h>
71 #include <dev/isci/scil/intel_scsi.h>
72 
73 //******************************************************************************
74 //* C O N S T A N T S
75 //******************************************************************************
76 
77 #define SCSI_MODE_PAGE19_SAS_ID         0x6
78 #define SCSI_MODE_PAGE19_SUB1_PAGE_NUM  0x1
79 #define SCSI_MODE_PAGE19_SUB1_PC        0x59
80 
81 //******************************************************************************
82 //* M O D E   P A G E S
83 //******************************************************************************
84 
85 U8 sat_default_mode_page_01[] =
86 {
87    SCSI_MODE_PAGE_READ_WRITE_ERROR, // Byte 0 - Page Code, SPF(0), PS(0)
88    SCSI_MODE_PAGE_01_LENGTH-2,      // Byte 1 - Page Length
89    0x80, // Byte 2 - AWRE, ARRE, TB, RC, EER, PER, DTE, DCR
90    0x00, // Byte 3 - Read Retry Count
91 
92    0x00, // Byte 4 - Obsolete
93    0x00, // Byte 5 - Obsolete
94    0x00, // Byte 6 - Obsolete
95    0x00, // Byte 7 - Restricted for MMC-4
96 
97    0x00, // Byte 8 - Write Retry Count
98    0x00, // Byte 9 - Reserved
99    0x00, // Byte 10 - Recovery Time Limit
100    0x00, // Byte 11
101 };
102 
103 U8 sat_changeable_mode_page_01[] =
104 {
105    SCSI_MODE_PAGE_READ_WRITE_ERROR,
106    SCSI_MODE_PAGE_01_LENGTH-2,
107    0x00,
108    0x00,
109 
110    0x00,
111    0x00,
112    0x00,
113    0x00,
114 
115    0x00,
116    0x00,
117    0x00,
118    0x00,
119 };
120 
121 U8 sat_default_mode_page_02[] =
122 {
123    SCSI_MODE_PAGE_DISCONNECT_RECONNECT, // Byte 0 - Page Code, SPF(0), PS(0)
124    SCSI_MODE_PAGE_02_LENGTH-2,          // Byte 1 - Page Length
125    0x00, // Byte 2 - Buffer Full Ratio
126    0x00, // Byte 3 - Buffer Empty Ratio
127 
128    0x00, // Byte 4 - Bus Inactivity Limit
129    0x00, // Byte 5
130    0x00, // Byte 6 - Disconnect Time Limit
131    0x00, // Byte 7
132 
133    0x00, // Byte 8 - Connect Time Limit
134    0x00, // Byte 9
135    0x00, // Byte 10 - Maximum Burst Size
136    0x00, // Byte 11
137 
138    0x00, // Byte 12 - EMDP, FAIR_ARB, DIMM, DTDC
139    0x00, // Byte 13
140    0x00, // Byte 14 - First Burst Size
141    0x00, // Byte 15
142 };
143 
144 U8 sat_changeable_mode_page_02[] =
145 {
146    SCSI_MODE_PAGE_DISCONNECT_RECONNECT,
147    SCSI_MODE_PAGE_02_LENGTH-2,
148    0x00,
149    0x00,
150 
151    0x00,
152    0x00,
153    0x00,
154    0x00,
155 
156    0x00,
157    0x00,
158    0x00,
159    0x00,
160 
161    0x00,
162    0x00,
163    0x00,
164    0x00,
165 };
166 
167 U8 sat_default_mode_page_08[] =
168 {
169    SCSI_MODE_PAGE_CACHING,     // Byte 0 - Page Code, SPF(0), PS(0)
170    SCSI_MODE_PAGE_08_LENGTH-2, // Byte 1 - Page Length
171    0x00, // Byte 2 - IC, ABPF, CAP, DISC, SIZE, WCE(1), MF, RCD
172    0x00, // Byte 3 - Demand Read Retention Priority, Write Retention Priority
173 
174    0x00, // Byte 4 - Disable Pre-Fetch Transfer Length
175    0x00, // Byte 5
176    0x00, // Byte 6 - Minimum Pre-Fetch
177    0x00, // Byte 7
178 
179    0x00, // Byte 8 - Maximum Pre-Fetch
180    0x00, // Byte 9
181    0x00, // Byte 10 - Maximum Pre-Fetch Ceiling
182    0x00, // Byte 11
183 
184    0x00, // Byte 12 - FSW, LBCSS, DRA(0), Vendor Specific, NV_DIS
185    0x00, // Byte 13 - Number of Cache Segments
186    0x00, // Byte 14 - Cache Segment Size
187    0x00, // Byte 15
188 
189    0x00, // Byte 16 - Reserved
190    0x00, // Byte 17 - Non-Cache Segment Size
191    0x00, // Byte 18
192    0x00, // PAD
193 };
194 
195 U8 sat_changeable_mode_page_08[] =
196 {
197    SCSI_MODE_PAGE_CACHING,
198    SCSI_MODE_PAGE_08_LENGTH-2,
199    SCSI_MODE_PAGE_CACHE_PAGE_WCE_BIT,
200    0x00,
201 
202    0x00,
203    0x00,
204    0x00,
205    0x00,
206 
207    0x00,
208    0x00,
209    0x00,
210    0x00,
211 
212    SCSI_MODE_PAGE_CACHE_PAGE_DRA_BIT,
213    0x00,
214    0x00,
215    0x00,
216 
217    0x00,
218    0x00,
219    0x00,
220    0x00, // PAD
221 };
222 
223 U8 sat_default_mode_page_0A[] =
224 {
225    SCSI_MODE_PAGE_CONTROL,     // Byte 0 - Page Code, SPF(0), PS(0)
226    SCSI_MODE_PAGE_0A_LENGTH-2, // Byte 1 - Page Length
227    0x00, // Byte 2 - TST(0), TMF_ONLY(0), D_SENSE(0), GLTSD(0), RLEC(0)
228    0x10, // Byte 3 - Queue Algorithm(0), QErr(0)
229 
230    0x00, // Byte 4 - TAS(0), RAC(0), UA_(0), SWP(0)
231    0x00, // Byte 5 - ATO(0), AUTOLOAD(0)
232    0x00, // Byte 6
233    0x00, // Byte 7
234 
235    0xFF, // Byte 8 - Unlimited Busy timeout
236    0xFF, // Byte 9
237    0x00, // Byte 10 - do not support self time compl time xlation
238    0x00, // Byte 11
239 };
240 
241 U8 sat_changeable_mode_page_0A[] =
242 {
243    SCSI_MODE_PAGE_CONTROL,
244    SCSI_MODE_PAGE_0A_LENGTH-2,
245    0x00,
246    0x00,
247 
248    0x00,
249    0x00,
250    0x00,
251    0x00,
252 
253    0x00,
254    0x00,
255    0x00,
256    0x00,
257 };
258 
259 U8 sat_default_mode_page_19[] =
260 {
261    SCSI_MODE_PAGE_PROTOCOL_SPECIFIC_PORT, // Byte 0 - PS, SPF, Page Code
262    SCSI_MODE_PAGE_19_LENGTH-2,  // Byte 1 - Page Length
263    SCSI_MODE_PAGE19_SAS_ID,     // Byte 2 - Rsvd, READY_LED,  ProtoID
264    0x00, // PAD
265 
266    0xFF, // Byte 4 - IT NLT MSB, 0xFF retry forever
267    0xFF, // Byte 5 - IT NLT LSB, 0xFF retry forever
268    0x00, // Byte 6 - IRT MSB, 0x0 disable init resp timer
269    0x00, // Byte 7 - IRT LSB, 0x0 disable init resp timer
270 };
271 
272 U8 sat_changeable_mode_page_19[] =
273 {
274    SCSI_MODE_PAGE_PROTOCOL_SPECIFIC_PORT,
275    SCSI_MODE_PAGE_19_LENGTH-2,
276    0x00,
277    0x00,
278 
279    0x00,
280    0x00,
281    0x00,
282    0x00,
283 };
284 
285 U8 sat_default_mode_page_1C[] =
286 {
287    SCSI_MODE_PAGE_INFORMATIONAL_EXCP_CONTROL, // Byte 0 - Page Code,
288                                               // SPF(0), PS(0)
289    SCSI_MODE_PAGE_1C_LENGTH-2,   // Byte 1 - Page Length
290    SCSI_MODE_PAGE_DEXCPT_ENABLE, // Byte 2 - Perf, EBF, EWasc,
291                                  // DExcpt(1), Test, LogErr
292    0x06, // Byte 3 -- MRIE (6 == values only available upon request)
293 
294    0x00, // Byte 4 -- Interval Timer
295    0x00, // Byte 5
296    0x00, // Byte 6
297    0x00, // Byte 7
298 
299    0x00, // Byte 8 -- Report Count
300    0x00, // Byte 9
301    0x00, // Byte 10
302    0x00, // Byte 11
303 };
304 
305 U8 sat_changeable_mode_page_1C[] =
306 {
307    SCSI_MODE_PAGE_INFORMATIONAL_EXCP_CONTROL,
308    SCSI_MODE_PAGE_1C_LENGTH-2,
309    SCSI_MODE_PAGE_DEXCPT_ENABLE,
310    0x00,
311 
312    0x00,
313    0x00,
314    0x00,
315    0x00,
316 
317    0x00,
318    0x00,
319    0x00,
320    0x00,
321 };
322 
323 U8 sat_supported_mode_pages[] =
324 {
325    SCSI_MODE_PAGE_READ_WRITE_ERROR,
326    SCSI_MODE_PAGE_DISCONNECT_RECONNECT,
327    SCSI_MODE_PAGE_CACHING,
328    SCSI_MODE_PAGE_CONTROL,
329    SCSI_MODE_PAGE_INFORMATIONAL_EXCP_CONTROL
330 };
331 
332 U8 *sat_changeable_mode_pages[] =
333 {
334    sat_changeable_mode_page_01,
335    sat_changeable_mode_page_02,
336    sat_changeable_mode_page_08,
337    sat_changeable_mode_page_0A,
338    sat_changeable_mode_page_1C
339 };
340 
341 U8 *sat_default_mode_pages[] =
342 {
343    sat_default_mode_page_01,
344    sat_default_mode_page_02,
345    sat_default_mode_page_08,
346    sat_default_mode_page_0A,
347    sat_default_mode_page_1C
348 };
349 
350 U16 sat_mode_page_sizes[] =
351 {
352    sizeof(sat_default_mode_page_01),
353    sizeof(sat_default_mode_page_02),
354    sizeof(sat_default_mode_page_08),
355    sizeof(sat_default_mode_page_0A),
356    sizeof(sat_default_mode_page_1C)
357 };
358 
359 U16 sati_mode_page_get_page_index(
360    U8  page_code
361 )
362 {
363    U16 index;
364    for (index = 0; index < SAT_SUPPORTED_MODE_PAGES_LENGTH; index++)
365    {
366       if (sat_supported_mode_pages[index] == page_code)
367          return index;
368    }
369 
370    return SATI_MODE_PAGE_UNSUPPORTED_INDEX;
371 }
372 
373 #endif // defined(ENABLE_SATI_MODE_PAGES)
374 
375