sati.h revision 331722
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: stable/11/sys/dev/isci/scil/sati.h 331722 2018-03-29 02:50:57Z eadler $
53 */
54#ifndef _SATI_H_
55#define _SATI_H_
56
57/**
58 * @file
59 * @brief This file contains all of the interface methods, macros, structures
60 *        that can be utilized by a user to perform SCSI-to-ATA Translation.
61 *        SATI adheres to the www.t10.org SAT specification.
62 *
63 * For specific compliance information please refer to:
64 * - sati_get_sat_compliance_version() and
65 * - sati_get_sat_compliance_version_revision()
66 *
67 * For situations where compliance is not observed, the SATI will
68 * return an error indication (most likely INVALID FIELD IN CDB sense).
69 */
70
71#include <dev/isci/scil/sati_types.h>
72#include <dev/isci/scil/sati_translator_sequence.h>
73
74/**
75 * @brief This method will be called by the core to indicate the start of a
76 *        new translation sequence.  Set up the initial sequence state.
77 *
78 * @return None
79 */
80void sati_sequence_construct(
81   SATI_TRANSLATOR_SEQUENCE_T * sequence
82);
83
84/**
85 * @brief This method will be called by the core to request the current translation
86 *        sequence be terminated.
87 *
88 * @param[in]  sequence This parameter specifies the sequence
89 *             data associated with the translation.
90 * @param[in,out] scsi_io This parameter specifies the user's SCSI IO request
91 *                object.  SATI expects that the user can access the SCSI CDB,
92 *                response, and data from this pointer.  For example, if there
93 *                is a failure in translation resulting in sense data, then
94 *                SATI will call sati_cb_set_status() and pass the scsi_io
95 *                pointer as a parameter.
96 * @param[out] ata_io This parameter specifies the location of the
97 *             ATA register FIS into which the translator can write the
98 *             resultant ATA command if translation is successful.  This
99 *             parameter is passed back to the user through the
100 *             SATI_SATA_CALLBACKS when it is necessary to write fields
101 *             in the ata_io.
102 *
103 * @return None
104 */
105void sati_sequence_terminate(
106   SATI_TRANSLATOR_SEQUENCE_T * sequence,
107   void                       * scsi_io,
108   void                       * ata_io
109);
110
111/**
112 * @brief This method translates the supplied SCSI command into a
113 *        corresponding ATA command.
114 *
115 * @param[in]  sequence This parameter specifies the sequence
116 *             data associated with the translation.
117 * @param[in]  sati_device This parameter specifies the remote device
118 *             for which the translated request is destined.
119 * @param[in,out] scsi_io This parameter specifies the user's SCSI IO request
120 *                object.  SATI expects that the user can access the SCSI CDB,
121 *                response, and data from this pointer.  For example, if there
122 *                is a failure in translation resulting in sense data, then
123 *                SATI will call sati_cb_set_status() and pass the scsi_io
124 *                pointer as a parameter.
125 * @param[out] ata_io This parameter specifies the location of the
126 *             ATA register FIS into which the translator can write the
127 *             resultant ATA command if translation is successful.  This
128 *             parameter is passed back to the user through the
129 *             SATI_SATA_CALLBACKS when it is necessary to write fields
130 *             in the ata_io.
131 *
132 * @return Indicate if the translation was successful.
133 * @retval SATI_SUCCESS
134 * @retval SATI_FAILURE_CHECK_RESPONSE_DATA
135 */
136SATI_STATUS sati_translate_command(
137   SATI_TRANSLATOR_SEQUENCE_T * sequence,
138   SATI_DEVICE_T              * sati_device,
139   void                       * scsi_io,
140   void                       * ata_io
141);
142
143/**
144 * @brief This method translates the supplied SCSI task management request
145 *        into a corresponding ATA command/control FIS.
146 *
147 * @param[in]  sequence This parameter specifies the sequence
148 *             data associated with the translation.
149 * @param[in]  sati_device This parameter specifies the remote device
150 *             for which the translated request is destined.
151 * @param[in,out] scsi_io This parameter specifies the user's SCSI IO request
152 *                object.  SATI expects that the user can access the SCSI CDB,
153 *                response, and data from this pointer.  For example, if there
154 *                is a failure in translation resulting in sense data, then
155 *                SATI will call sati_cb_set_status() and pass the scsi_io
156 *                pointer as a parameter.
157 * @param[out] ata_io This parameter specifies the location of the
158 *             ATA register FIS into which the translator can write the
159 *             resultant ATA command if translation is successful.  This
160 *             parameter is passed back to the user through the
161 *             SATI_SATA_CALLBACKS when it is necessary to write fields
162 *             in the ata_io.
163 *
164 * @return Indicate if the translation was successful.
165 * @retval SATI_SUCCESS
166 * @retval SATI_FAILURE_CHECK_RESPONSE_DATA
167 */
168SATI_STATUS sati_translate_task_management(
169   SATI_TRANSLATOR_SEQUENCE_T * sequence,
170   SATI_DEVICE_T              * sati_device,
171   void                       * scsi_task,
172   void                       * ata_io
173);
174
175/**
176 * @brief This method translates the supplied ATA response into the
177 *        corresponding SCSI command response.
178 *
179 * @param[in]  sequence This parameter specifies the sequence
180 *             data associated with the translation.
181 * @param[out] scsi_io This parameter specifies the user's SCSI IO request
182 *             object.  SATI expects that the user can access the SCSI CDB,
183 *             response, and data from this pointer.  For example, if there
184 *             is a failure in translation resulting in sense data, then
185 *             SATI will call sati_cb_set_status() and pass the scsi_io
186 *             pointer as a parameter.
187 * @param[out] ata_io This parameter specifies the location of the
188 *             ATA IO request (e.g. register FIS, PIO Setup etc.) from which
189 *             the translator can read the received ATA status and error
190 *             fields.
191 *
192 * @return Indicate if the translation was successful.
193 * @retval SATI_SUCCESS
194 * @retval SATI_FAILURE_CHECK_RESPONSE_DATA
195 */
196SATI_STATUS sati_translate_command_response(
197   SATI_TRANSLATOR_SEQUENCE_T * sequence,
198   void                       * scsi_io,
199   void                       * ata_io
200);
201
202/**
203 * @brief This method translates the supplied ATA response into the
204 *        corresponding SCSI task response.
205 *
206 * @param[in]  sequence This parameter specifies the sequence
207 *             data associated with the translation.
208 * @param[out] scsi_io This parameter specifies the user's SCSI IO request
209 *             object.  SATI expects that the user can access the SCSI CDB,
210 *             response, and data from this pointer.  For example, if there
211 *             is a failure in translation resulting in sense data, then
212 *             SATI will call sati_cb_set_status() and pass the scsi_io
213 *             pointer as a parameter.
214 * @param[out] ata_io This parameter specifies the location of the
215 *             ATA IO request (e.g. register FIS, PIO Setup etc.) from which
216 *             the translator can read the received ATA status and error
217 *             fields.
218 *
219 * @return Indicate if the translation was successful.
220 * @retval SATI_FAILURE_CHECK_RESPONSE_DATA
221 */
222SATI_STATUS sati_translate_task_response(
223   SATI_TRANSLATOR_SEQUENCE_T * sequence,
224   void                       * scsi_io,
225   void                       * ata_io
226);
227
228/**
229 * @brief This method simply returns the SAT major compliance version number
230 *        for which the implementation is compliant.
231 *
232 * @return Return the specification identifier with which this translator
233 *         is compliant.
234 */
235U32 sati_get_sat_compliance_version(
236   void
237);
238
239/**
240 * @brief This method simply returns the SAT version revision identifier
241 *        for which the implementation is compliant.
242 *
243 * @return Return the specification revision identifier with which this
244 *         translator is compliant.
245 */
246U32 sati_get_sat_compliance_version_revision(
247   void
248);
249
250/**
251* @brief This method returns the number of data bytes written
252*        by the translation sequence.
253*
254* @param[in] sequence This parameter specifies the sequence data
255*            associated with the translation.
256*
257* @return Return the U16 number_data_bytes_set in the
258*         SATI_TRANSLATOR_SEQUENCE.
259*/
260U16 sati_get_number_data_bytes_set(
261   SATI_TRANSLATOR_SEQUENCE_T * sequence
262);
263
264void sati_translate_error(
265   SATI_TRANSLATOR_SEQUENCE_T * sequence,
266   void                       * scsi_io,
267   U8                           error
268);
269
270#endif // _SATI_H_
271
272