xref: /freebsd/sys/dev/isci/scil/sati.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1f11c7f63SJim Harris /*-
2*718cf2ccSPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3*718cf2ccSPedro F. Giffuni  *
4f11c7f63SJim Harris  * This file is provided under a dual BSD/GPLv2 license.  When using or
5f11c7f63SJim Harris  * redistributing this file, you may do so under either license.
6f11c7f63SJim Harris  *
7f11c7f63SJim Harris  * GPL LICENSE SUMMARY
8f11c7f63SJim Harris  *
9f11c7f63SJim Harris  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
10f11c7f63SJim Harris  *
11f11c7f63SJim Harris  * This program is free software; you can redistribute it and/or modify
12f11c7f63SJim Harris  * it under the terms of version 2 of the GNU General Public License as
13f11c7f63SJim Harris  * published by the Free Software Foundation.
14f11c7f63SJim Harris  *
15f11c7f63SJim Harris  * This program is distributed in the hope that it will be useful, but
16f11c7f63SJim Harris  * WITHOUT ANY WARRANTY; without even the implied warranty of
17f11c7f63SJim Harris  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18f11c7f63SJim Harris  * General Public License for more details.
19f11c7f63SJim Harris  *
20f11c7f63SJim Harris  * You should have received a copy of the GNU General Public License
21f11c7f63SJim Harris  * along with this program; if not, write to the Free Software
22f11c7f63SJim Harris  * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
23f11c7f63SJim Harris  * The full GNU General Public License is included in this distribution
24f11c7f63SJim Harris  * in the file called LICENSE.GPL.
25f11c7f63SJim Harris  *
26f11c7f63SJim Harris  * BSD LICENSE
27f11c7f63SJim Harris  *
28f11c7f63SJim Harris  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
29f11c7f63SJim Harris  * All rights reserved.
30f11c7f63SJim Harris  *
31f11c7f63SJim Harris  * Redistribution and use in source and binary forms, with or without
32f11c7f63SJim Harris  * modification, are permitted provided that the following conditions
33f11c7f63SJim Harris  * are met:
34f11c7f63SJim Harris  *
35f11c7f63SJim Harris  *   * Redistributions of source code must retain the above copyright
36f11c7f63SJim Harris  *     notice, this list of conditions and the following disclaimer.
37f11c7f63SJim Harris  *   * Redistributions in binary form must reproduce the above copyright
38f11c7f63SJim Harris  *     notice, this list of conditions and the following disclaimer in
39f11c7f63SJim Harris  *     the documentation and/or other materials provided with the
40f11c7f63SJim Harris  *     distribution.
41f11c7f63SJim Harris  *
42f11c7f63SJim Harris  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43f11c7f63SJim Harris  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44f11c7f63SJim Harris  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45f11c7f63SJim Harris  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
46f11c7f63SJim Harris  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47f11c7f63SJim Harris  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48f11c7f63SJim Harris  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49f11c7f63SJim Harris  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50f11c7f63SJim Harris  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51f11c7f63SJim Harris  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52f11c7f63SJim Harris  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53f11c7f63SJim Harris  */
54f11c7f63SJim Harris #ifndef _SATI_H_
55f11c7f63SJim Harris #define _SATI_H_
56f11c7f63SJim Harris 
57f11c7f63SJim Harris /**
58f11c7f63SJim Harris  * @file
59f11c7f63SJim Harris  * @brief This file contains all of the interface methods, macros, structures
60f11c7f63SJim Harris  *        that can be utilized by a user to perform SCSI-to-ATA Translation.
61f11c7f63SJim Harris  *        SATI adheres to the www.t10.org SAT specification.
62f11c7f63SJim Harris  *
63f11c7f63SJim Harris  * For specific compliance information please refer to:
64f11c7f63SJim Harris  * - sati_get_sat_compliance_version() and
65f11c7f63SJim Harris  * - sati_get_sat_compliance_version_revision()
66f11c7f63SJim Harris  *
67f11c7f63SJim Harris  * For situations where compliance is not observed, the SATI will
68f11c7f63SJim Harris  * return an error indication (most likely INVALID FIELD IN CDB sense).
69f11c7f63SJim Harris  */
70f11c7f63SJim Harris 
71f11c7f63SJim Harris #include <dev/isci/scil/sati_types.h>
72f11c7f63SJim Harris #include <dev/isci/scil/sati_translator_sequence.h>
73f11c7f63SJim Harris 
74f11c7f63SJim Harris /**
75f11c7f63SJim Harris  * @brief This method will be called by the core to indicate the start of a
76f11c7f63SJim Harris  *        new translation sequence.  Set up the initial sequence state.
77f11c7f63SJim Harris  *
78f11c7f63SJim Harris  * @return None
79f11c7f63SJim Harris  */
80f11c7f63SJim Harris void sati_sequence_construct(
81f11c7f63SJim Harris    SATI_TRANSLATOR_SEQUENCE_T * sequence
82f11c7f63SJim Harris );
83f11c7f63SJim Harris 
84f11c7f63SJim Harris /**
85f11c7f63SJim Harris  * @brief This method will be called by the core to request the current translation
86f11c7f63SJim Harris  *        sequence be terminated.
87f11c7f63SJim Harris  *
88f11c7f63SJim Harris  * @param[in]  sequence This parameter specifies the sequence
89f11c7f63SJim Harris  *             data associated with the translation.
90f11c7f63SJim Harris  * @param[in,out] scsi_io This parameter specifies the user's SCSI IO request
91f11c7f63SJim Harris  *                object.  SATI expects that the user can access the SCSI CDB,
92f11c7f63SJim Harris  *                response, and data from this pointer.  For example, if there
93f11c7f63SJim Harris  *                is a failure in translation resulting in sense data, then
94f11c7f63SJim Harris  *                SATI will call sati_cb_set_status() and pass the scsi_io
95f11c7f63SJim Harris  *                pointer as a parameter.
96f11c7f63SJim Harris  * @param[out] ata_io This parameter specifies the location of the
97f11c7f63SJim Harris  *             ATA register FIS into which the translator can write the
98f11c7f63SJim Harris  *             resultant ATA command if translation is successful.  This
99f11c7f63SJim Harris  *             parameter is passed back to the user through the
100f11c7f63SJim Harris  *             SATI_SATA_CALLBACKS when it is necessary to write fields
101f11c7f63SJim Harris  *             in the ata_io.
102f11c7f63SJim Harris  *
103f11c7f63SJim Harris  * @return None
104f11c7f63SJim Harris  */
105f11c7f63SJim Harris void sati_sequence_terminate(
106f11c7f63SJim Harris    SATI_TRANSLATOR_SEQUENCE_T * sequence,
107f11c7f63SJim Harris    void                       * scsi_io,
108f11c7f63SJim Harris    void                       * ata_io
109f11c7f63SJim Harris );
110f11c7f63SJim Harris 
111f11c7f63SJim Harris /**
112f11c7f63SJim Harris  * @brief This method translates the supplied SCSI command into a
113f11c7f63SJim Harris  *        corresponding ATA command.
114f11c7f63SJim Harris  *
115f11c7f63SJim Harris  * @param[in]  sequence This parameter specifies the sequence
116f11c7f63SJim Harris  *             data associated with the translation.
117f11c7f63SJim Harris  * @param[in]  sati_device This parameter specifies the remote device
118f11c7f63SJim Harris  *             for which the translated request is destined.
119f11c7f63SJim Harris  * @param[in,out] scsi_io This parameter specifies the user's SCSI IO request
120f11c7f63SJim Harris  *                object.  SATI expects that the user can access the SCSI CDB,
121f11c7f63SJim Harris  *                response, and data from this pointer.  For example, if there
122f11c7f63SJim Harris  *                is a failure in translation resulting in sense data, then
123f11c7f63SJim Harris  *                SATI will call sati_cb_set_status() and pass the scsi_io
124f11c7f63SJim Harris  *                pointer as a parameter.
125f11c7f63SJim Harris  * @param[out] ata_io This parameter specifies the location of the
126f11c7f63SJim Harris  *             ATA register FIS into which the translator can write the
127f11c7f63SJim Harris  *             resultant ATA command if translation is successful.  This
128f11c7f63SJim Harris  *             parameter is passed back to the user through the
129f11c7f63SJim Harris  *             SATI_SATA_CALLBACKS when it is necessary to write fields
130f11c7f63SJim Harris  *             in the ata_io.
131f11c7f63SJim Harris  *
132f11c7f63SJim Harris  * @return Indicate if the translation was successful.
133f11c7f63SJim Harris  * @retval SATI_SUCCESS
134f11c7f63SJim Harris  * @retval SATI_FAILURE_CHECK_RESPONSE_DATA
135f11c7f63SJim Harris  */
136f11c7f63SJim Harris SATI_STATUS sati_translate_command(
137f11c7f63SJim Harris    SATI_TRANSLATOR_SEQUENCE_T * sequence,
138f11c7f63SJim Harris    SATI_DEVICE_T              * sati_device,
139f11c7f63SJim Harris    void                       * scsi_io,
140f11c7f63SJim Harris    void                       * ata_io
141f11c7f63SJim Harris );
142f11c7f63SJim Harris 
143f11c7f63SJim Harris /**
144f11c7f63SJim Harris  * @brief This method translates the supplied SCSI task management request
145f11c7f63SJim Harris  *        into a corresponding ATA command/control FIS.
146f11c7f63SJim Harris  *
147f11c7f63SJim Harris  * @param[in]  sequence This parameter specifies the sequence
148f11c7f63SJim Harris  *             data associated with the translation.
149f11c7f63SJim Harris  * @param[in]  sati_device This parameter specifies the remote device
150f11c7f63SJim Harris  *             for which the translated request is destined.
151f11c7f63SJim Harris  * @param[in,out] scsi_io This parameter specifies the user's SCSI IO request
152f11c7f63SJim Harris  *                object.  SATI expects that the user can access the SCSI CDB,
153f11c7f63SJim Harris  *                response, and data from this pointer.  For example, if there
154f11c7f63SJim Harris  *                is a failure in translation resulting in sense data, then
155f11c7f63SJim Harris  *                SATI will call sati_cb_set_status() and pass the scsi_io
156f11c7f63SJim Harris  *                pointer as a parameter.
157f11c7f63SJim Harris  * @param[out] ata_io This parameter specifies the location of the
158f11c7f63SJim Harris  *             ATA register FIS into which the translator can write the
159f11c7f63SJim Harris  *             resultant ATA command if translation is successful.  This
160f11c7f63SJim Harris  *             parameter is passed back to the user through the
161f11c7f63SJim Harris  *             SATI_SATA_CALLBACKS when it is necessary to write fields
162f11c7f63SJim Harris  *             in the ata_io.
163f11c7f63SJim Harris  *
164f11c7f63SJim Harris  * @return Indicate if the translation was successful.
165f11c7f63SJim Harris  * @retval SATI_SUCCESS
166f11c7f63SJim Harris  * @retval SATI_FAILURE_CHECK_RESPONSE_DATA
167f11c7f63SJim Harris  */
168f11c7f63SJim Harris SATI_STATUS sati_translate_task_management(
169f11c7f63SJim Harris    SATI_TRANSLATOR_SEQUENCE_T * sequence,
170f11c7f63SJim Harris    SATI_DEVICE_T              * sati_device,
171f11c7f63SJim Harris    void                       * scsi_task,
172f11c7f63SJim Harris    void                       * ata_io
173f11c7f63SJim Harris );
174f11c7f63SJim Harris 
175f11c7f63SJim Harris /**
176f11c7f63SJim Harris  * @brief This method translates the supplied ATA response into the
177f11c7f63SJim Harris  *        corresponding SCSI command response.
178f11c7f63SJim Harris  *
179f11c7f63SJim Harris  * @param[in]  sequence This parameter specifies the sequence
180f11c7f63SJim Harris  *             data associated with the translation.
181f11c7f63SJim Harris  * @param[out] scsi_io This parameter specifies the user's SCSI IO request
182f11c7f63SJim Harris  *             object.  SATI expects that the user can access the SCSI CDB,
183f11c7f63SJim Harris  *             response, and data from this pointer.  For example, if there
184f11c7f63SJim Harris  *             is a failure in translation resulting in sense data, then
185f11c7f63SJim Harris  *             SATI will call sati_cb_set_status() and pass the scsi_io
186f11c7f63SJim Harris  *             pointer as a parameter.
187f11c7f63SJim Harris  * @param[out] ata_io This parameter specifies the location of the
188f11c7f63SJim Harris  *             ATA IO request (e.g. register FIS, PIO Setup etc.) from which
189f11c7f63SJim Harris  *             the translator can read the received ATA status and error
190f11c7f63SJim Harris  *             fields.
191f11c7f63SJim Harris  *
192f11c7f63SJim Harris  * @return Indicate if the translation was successful.
193f11c7f63SJim Harris  * @retval SATI_SUCCESS
194f11c7f63SJim Harris  * @retval SATI_FAILURE_CHECK_RESPONSE_DATA
195f11c7f63SJim Harris  */
196f11c7f63SJim Harris SATI_STATUS sati_translate_command_response(
197f11c7f63SJim Harris    SATI_TRANSLATOR_SEQUENCE_T * sequence,
198f11c7f63SJim Harris    void                       * scsi_io,
199f11c7f63SJim Harris    void                       * ata_io
200f11c7f63SJim Harris );
201f11c7f63SJim Harris 
202f11c7f63SJim Harris /**
203f11c7f63SJim Harris  * @brief This method translates the supplied ATA response into the
204f11c7f63SJim Harris  *        corresponding SCSI task response.
205f11c7f63SJim Harris  *
206f11c7f63SJim Harris  * @param[in]  sequence This parameter specifies the sequence
207f11c7f63SJim Harris  *             data associated with the translation.
208f11c7f63SJim Harris  * @param[out] scsi_io This parameter specifies the user's SCSI IO request
209f11c7f63SJim Harris  *             object.  SATI expects that the user can access the SCSI CDB,
210f11c7f63SJim Harris  *             response, and data from this pointer.  For example, if there
211f11c7f63SJim Harris  *             is a failure in translation resulting in sense data, then
212f11c7f63SJim Harris  *             SATI will call sati_cb_set_status() and pass the scsi_io
213f11c7f63SJim Harris  *             pointer as a parameter.
214f11c7f63SJim Harris  * @param[out] ata_io This parameter specifies the location of the
215f11c7f63SJim Harris  *             ATA IO request (e.g. register FIS, PIO Setup etc.) from which
216f11c7f63SJim Harris  *             the translator can read the received ATA status and error
217f11c7f63SJim Harris  *             fields.
218f11c7f63SJim Harris  *
219f11c7f63SJim Harris  * @return Indicate if the translation was successful.
220f11c7f63SJim Harris  * @retval SATI_FAILURE_CHECK_RESPONSE_DATA
221f11c7f63SJim Harris  */
222f11c7f63SJim Harris SATI_STATUS sati_translate_task_response(
223f11c7f63SJim Harris    SATI_TRANSLATOR_SEQUENCE_T * sequence,
224f11c7f63SJim Harris    void                       * scsi_io,
225f11c7f63SJim Harris    void                       * ata_io
226f11c7f63SJim Harris );
227f11c7f63SJim Harris 
228f11c7f63SJim Harris /**
229f11c7f63SJim Harris  * @brief This method simply returns the SAT major compliance version number
230f11c7f63SJim Harris  *        for which the implementation is compliant.
231f11c7f63SJim Harris  *
232f11c7f63SJim Harris  * @return Return the specification identifier with which this translator
233f11c7f63SJim Harris  *         is compliant.
234f11c7f63SJim Harris  */
235f11c7f63SJim Harris U32 sati_get_sat_compliance_version(
236f11c7f63SJim Harris    void
237f11c7f63SJim Harris );
238f11c7f63SJim Harris 
239f11c7f63SJim Harris /**
240f11c7f63SJim Harris  * @brief This method simply returns the SAT version revision identifier
241f11c7f63SJim Harris  *        for which the implementation is compliant.
242f11c7f63SJim Harris  *
243f11c7f63SJim Harris  * @return Return the specification revision identifier with which this
244f11c7f63SJim Harris  *         translator is compliant.
245f11c7f63SJim Harris  */
246f11c7f63SJim Harris U32 sati_get_sat_compliance_version_revision(
247f11c7f63SJim Harris    void
248f11c7f63SJim Harris );
249f11c7f63SJim Harris 
250f11c7f63SJim Harris /**
251f11c7f63SJim Harris * @brief This method returns the number of data bytes written
252f11c7f63SJim Harris *        by the translation sequence.
253f11c7f63SJim Harris *
254f11c7f63SJim Harris * @param[in] sequence This parameter specifies the sequence data
255f11c7f63SJim Harris *            associated with the translation.
256f11c7f63SJim Harris *
257f11c7f63SJim Harris * @return Return the U16 number_data_bytes_set in the
258f11c7f63SJim Harris *         SATI_TRANSLATOR_SEQUENCE.
259f11c7f63SJim Harris */
260f11c7f63SJim Harris U16 sati_get_number_data_bytes_set(
261f11c7f63SJim Harris    SATI_TRANSLATOR_SEQUENCE_T * sequence
262f11c7f63SJim Harris );
263f11c7f63SJim Harris 
264f11c7f63SJim Harris void sati_translate_error(
265f11c7f63SJim Harris    SATI_TRANSLATOR_SEQUENCE_T * sequence,
266f11c7f63SJim Harris    void                       * scsi_io,
267f11c7f63SJim Harris    U8                           error
268f11c7f63SJim Harris );
269f11c7f63SJim Harris 
270f11c7f63SJim Harris #endif // _SATI_H_
271f11c7f63SJim Harris 
272