xref: /freebsd/sys/dev/isci/scil/sati_device.h (revision 36712a94975f5bd0d26c85377283b49a2369c82f)
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  * $FreeBSD$
55  */
56 #ifndef _SATI_DEVICE_H_
57 #define _SATI_DEVICE_H_
58 
59 /**
60  * @file
61  * @brief This file contains all of the defintions for the SATI remote
62  *        device object.  Some translations require information to be
63  *        remembered on a per device basis.  This information is stored
64  *        in the object defined in this file.
65  */
66 
67 #include <dev/isci/scil/sati_types.h>
68 #include <dev/isci/scil/intel_ata.h>
69 
70 /**
71  * @enum _SATI_DEVICE_STATE
72  *
73  * @brief This enumeration depicts the various states possible for the a
74  *        translation remote device object.
75  */
76 typedef enum _SATI_DEVICE_STATE
77 {
78    SATI_DEVICE_STATE_OPERATIONAL,
79    SATI_DEVICE_STATE_STOPPED,
80    SATI_DEVICE_STATE_STANDBY,
81    SATI_DEVICE_STATE_IDLE,
82    SATI_DEVICE_STATE_DEVICE_FAULT_OCCURRED,
83    SATI_DEVICE_STATE_FORMAT_UNIT_IN_PROGRESS,
84    SATI_DEVICE_STATE_SELF_TEST_IN_PROGRESS,
85    SATI_DEVICE_STATE_SEQUENCE_INCOMPLETE,
86    SATI_DEVICE_STATE_UNIT_ATTENTION_CONDITION
87 
88 } SATI_DEVICE_STATE;
89 
90 /**
91  * @name SATI_DEVICE_CAPABILITIES
92  *
93  * These constants define the various capabilities that a remote device may
94  * support for which there is an impact on translation.
95  */
96 /*@{*/
97 #define SATI_DEVICE_CAP_UDMA_ENABLE          0x00000001
98 #define SATI_DEVICE_CAP_NCQ_REQUESTED_ENABLE 0x00000002
99 #define SATI_DEVICE_CAP_NCQ_SUPPORTED_ENABLE 0x00000004
100 #define SATI_DEVICE_CAP_48BIT_ENABLE         0x00000008
101 #define SATI_DEVICE_CAP_DMA_FUA_ENABLE       0x00000010
102 #define SATI_DEVICE_CAP_SMART_SUPPORT        0x00000020
103 #define SATI_DEVICE_CAP_REMOVABLE_MEDIA      0x00000040
104 #define SATI_DEVICE_CAP_SMART_ENABLE         0x00000080
105 #define SATI_DEVICE_CAP_WRITE_UNCORRECTABLE_ENABLE           0x00000100
106 #define SATI_DEVICE_CAP_MULTIPLE_SECTORS_PER_PHYSCIAL_SECTOR 0x00000200
107 #define SATI_DEVICE_CAP_SMART_SELF_TEST_SUPPORT              0x00000400
108 #define SATI_DEVICE_CAP_SSD                                  0x00000800
109 #define SATI_DEVICE_CAP_DSM_TRIM_SUPPORT                     0x00001000
110 #define SATI_DEVICE_CAP_DETERMINISTIC_READ_AFTER_TRIM        0x00002000
111 #define SATI_DEVICE_CAP_READ_ZERO_AFTER_TRIM                 0x00004000
112 #define SATI_DEVICE_CAP_STANDBY_ENABLE                       0x00008000
113 #define SATI_DEVICE_CAP_IGNORE_FUA                           0x00010000
114 
115 
116 /*@}*/
117 
118 /**
119  * @struct SATI_DEVICE
120  *
121  * @brief The SATI_DEVICE structure define the state of the remote device
122  *        with respect to translation.
123  */
124 typedef struct SATI_DEVICE
125 {
126    /**
127     * This field simply dictates the state of the SATI device.
128     */
129    SATI_DEVICE_STATE state;
130 
131    /**
132     * This field indicates features supported by the remote device that
133     * impact translation execution.
134     */
135    U16 capabilities;
136 
137    /**
138     * This field indicates the depth of the native command queue supported
139     * by the device.
140     */
141    U8 ncq_depth;
142 
143    /**
144     * This field stores the additional sense code for a unit attention
145     * condition.
146     */
147    U8 unit_attention_asc;
148 
149    /**
150     * This field indicates the additional sense code qualifier for a unit
151     * attention condition.
152     */
153    U8 unit_attention_ascq;
154 
155    /**
156     * This field indicates the ATA standby timer value set through the
157     * ATA IDLE and ATA Standby commands
158     */
159    U8 ata_standby_timer;
160 
161    /**
162     * This field indicates the maximum number of data set management
163     * descriptor entries the device supports in blocks.
164     */
165    U16 max_lba_range_entry_blocks;
166 
167    /**
168     * The field is the reported logical block size for the device
169     */
170    U32 logical_block_size;
171 
172    /**
173     * This field is the maximum number of blocks per Download Microcode command
174     * for this device.
175     */
176    U16 max_blocks_per_microcode_command;
177 
178    /**
179    * This field is the minimum number of blocks per Download Microcode command
180    * for this device.
181    */
182    U16 min_blocks_per_microcode_command;
183 
184    /**
185     * This field indicates the type of constructed sense data if enabled descriptor
186     * sense data will be constructed
187     */
188    U8 descriptor_sense_enable;
189 
190 } SATI_DEVICE_T;
191 
192 void sati_device_construct(
193    SATI_DEVICE_T * device,
194    BOOL            is_ncq_enabled,
195    U8              max_ncq_depth,
196    BOOL            ignore_fua
197 );
198 
199 void sati_device_update_capabilities(
200    SATI_DEVICE_T              * device,
201    ATA_IDENTIFY_DEVICE_DATA_T * identify
202 );
203 
204 #endif // _SATI_TRANSLATOR_SEQUENCE_H_
205 
206