xref: /freebsd/sys/dev/isci/scil/sati_device.h (revision 7750ad47a9a7dbc83f87158464170c8640723293)
1 /*-
2  * This file is provided under a dual BSD/GPLv2 license.  When using or
3  * redistributing this file, you may do so under either license.
4  *
5  * GPL LICENSE SUMMARY
6  *
7  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of version 2 of the GNU General Public License as
11  * published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21  * The full GNU General Public License is included in this distribution
22  * in the file called LICENSE.GPL.
23  *
24  * BSD LICENSE
25  *
26  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27  * All rights reserved.
28  *
29  * Redistribution and use in source and binary forms, with or without
30  * modification, are permitted provided that the following conditions
31  * are met:
32  *
33  *   * Redistributions of source code must retain the above copyright
34  *     notice, this list of conditions and the following disclaimer.
35  *   * Redistributions in binary form must reproduce the above copyright
36  *     notice, this list of conditions and the following disclaimer in
37  *     the documentation and/or other materials provided with the
38  *     distribution.
39  *
40  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51  *
52  * $FreeBSD$
53  */
54 #ifndef _SATI_DEVICE_H_
55 #define _SATI_DEVICE_H_
56 
57 /**
58  * @file
59  * @brief This file contains all of the defintions for the SATI remote
60  *        device object.  Some translations require information to be
61  *        remembered on a per device basis.  This information is stored
62  *        in the object defined in this file.
63  */
64 
65 #include <dev/isci/scil/sati_types.h>
66 #include <dev/isci/scil/intel_ata.h>
67 
68 /**
69  * @enum _SATI_DEVICE_STATE
70  *
71  * @brief This enumeration depicts the various states possible for the a
72  *        translation remote device object.
73  */
74 typedef enum _SATI_DEVICE_STATE
75 {
76    SATI_DEVICE_STATE_OPERATIONAL,
77    SATI_DEVICE_STATE_STOPPED,
78    SATI_DEVICE_STATE_STANDBY,
79    SATI_DEVICE_STATE_IDLE,
80    SATI_DEVICE_STATE_DEVICE_FAULT_OCCURRED,
81    SATI_DEVICE_STATE_FORMAT_UNIT_IN_PROGRESS,
82    SATI_DEVICE_STATE_SELF_TEST_IN_PROGRESS,
83    SATI_DEVICE_STATE_SEQUENCE_INCOMPLETE,
84    SATI_DEVICE_STATE_UNIT_ATTENTION_CONDITION
85 
86 } SATI_DEVICE_STATE;
87 
88 /**
89  * @name SATI_DEVICE_CAPABILITIES
90  *
91  * These constants define the various capabilities that a remote device may
92  * support for which there is an impact on translation.
93  */
94 /*@{*/
95 #define SATI_DEVICE_CAP_UDMA_ENABLE          0x00000001
96 #define SATI_DEVICE_CAP_NCQ_REQUESTED_ENABLE 0x00000002
97 #define SATI_DEVICE_CAP_NCQ_SUPPORTED_ENABLE 0x00000004
98 #define SATI_DEVICE_CAP_48BIT_ENABLE         0x00000008
99 #define SATI_DEVICE_CAP_DMA_FUA_ENABLE       0x00000010
100 #define SATI_DEVICE_CAP_SMART_SUPPORT        0x00000020
101 #define SATI_DEVICE_CAP_REMOVABLE_MEDIA      0x00000040
102 #define SATI_DEVICE_CAP_SMART_ENABLE         0x00000080
103 #define SATI_DEVICE_CAP_WRITE_UNCORRECTABLE_ENABLE           0x00000100
104 #define SATI_DEVICE_CAP_MULTIPLE_SECTORS_PER_PHYSCIAL_SECTOR 0x00000200
105 #define SATI_DEVICE_CAP_SMART_SELF_TEST_SUPPORT              0x00000400
106 #define SATI_DEVICE_CAP_SSD                                  0x00000800
107 #define SATI_DEVICE_CAP_DSM_TRIM_SUPPORT                     0x00001000
108 #define SATI_DEVICE_CAP_DETERMINISTIC_READ_AFTER_TRIM        0x00002000
109 #define SATI_DEVICE_CAP_READ_ZERO_AFTER_TRIM                 0x00004000
110 #define SATI_DEVICE_CAP_STANDBY_ENABLE                       0x00008000
111 #define SATI_DEVICE_CAP_IGNORE_FUA                           0x00010000
112 
113 
114 /*@}*/
115 
116 /**
117  * @struct SATI_DEVICE
118  *
119  * @brief The SATI_DEVICE structure define the state of the remote device
120  *        with respect to translation.
121  */
122 typedef struct SATI_DEVICE
123 {
124    /**
125     * This field simply dictates the state of the SATI device.
126     */
127    SATI_DEVICE_STATE state;
128 
129    /**
130     * This field indicates features supported by the remote device that
131     * impact translation execution.
132     */
133    U16 capabilities;
134 
135    /**
136     * This field indicates the depth of the native command queue supported
137     * by the device.
138     */
139    U8 ncq_depth;
140 
141    /**
142     * This field stores the additional sense code for a unit attention
143     * condition.
144     */
145    U8 unit_attention_asc;
146 
147    /**
148     * This field indicates the additional sense code qualifier for a unit
149     * attention condition.
150     */
151    U8 unit_attention_ascq;
152 
153    /**
154     * This field indicates the ATA standby timer value set throught the
155     * ATA IDLE and ATA Standby commands
156     */
157    U8 ata_standby_timer;
158 
159    /**
160     * This field indicates the maximum number of data set management
161     * descriptor entries the device supports in blocks.
162     */
163    U16 max_lba_range_entry_blocks;
164 
165    /**
166     * The field is the reported logical block size for the device
167     */
168    U32 logical_block_size;
169 
170    /**
171     * This field is the maximum number of blocks per Download Microcode command
172     * for this device.
173     */
174    U16 max_blocks_per_microcode_command;
175 
176    /**
177    * This field is the minimum number of blocks per Download Microcode command
178    * for this device.
179    */
180    U16 min_blocks_per_microcode_command;
181 
182    /**
183     * This field indicates the type of constructed sense data if enabled descriptor
184     * sense data will be constructed
185     */
186    U8 descriptor_sense_enable;
187 
188 } SATI_DEVICE_T;
189 
190 void sati_device_construct(
191    SATI_DEVICE_T * device,
192    BOOL            is_ncq_enabled,
193    U8              max_ncq_depth,
194    BOOL            ignore_fua
195 );
196 
197 void sati_device_update_capabilities(
198    SATI_DEVICE_T              * device,
199    ATA_IDENTIFY_DEVICE_DATA_T * identify
200 );
201 
202 #endif // _SATI_TRANSLATOR_SEQUENCE_H_
203 
204