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 _SCIC_SDS_STP_REQUEST_T_ 57 #define _SCIC_SDS_STP_REQUEST_T_ 58 59 #ifdef __cplusplus 60 extern "C" { 61 #endif // __cplusplus 62 63 #include <dev/isci/scil/intel_sata.h> 64 #include <dev/isci/scil/sci_types.h> 65 #include <dev/isci/scil/scic_sds_request.h> 66 67 /** 68 * @struct 69 * 70 * @brief This structure represents the additional information that is 71 * required to handle SATA PIO requests. 72 */ 73 typedef struct SCIC_SDS_STP_REQUEST 74 { 75 SCIC_SDS_REQUEST_T parent; 76 77 SATA_FIS_REG_D2H_T d2h_reg_fis; 78 79 union 80 { 81 U32 ncq; 82 83 U32 udma; 84 85 struct 86 { 87 /** 88 * Total transfer for the entire PIO request recorded at request construction 89 * time. 90 * 91 * @todo Should we just decrement this value for each byte of data transitted 92 * or received to elemenate the current_transfer_bytes field? 93 */ 94 U32 total_transfer_bytes; 95 96 /** 97 * Total number of bytes received/transmitted in data frames since the start 98 * of the IO request. At the end of the IO request this should equal the 99 * total_transfer_bytes. 100 */ 101 U32 current_transfer_bytes; 102 103 /** 104 * The number of bytes requested in the in the PIO setup. 105 */ 106 U32 pio_transfer_bytes; 107 108 /** 109 * PIO Setup ending status value to tell us if we need to wait for another FIS 110 * or if the transfer is complete. On the receipt of a D2H FIS this will be 111 * the status field of that FIS. 112 */ 113 U8 ending_status; 114 115 /** 116 * On receipt of a D2H FIS this will be the ending error field if the 117 * ending_status has the SATA_STATUS_ERR bit set. 118 */ 119 U8 ending_error; 120 121 /** 122 * Protocol Type. This is filled in by core during IO Request construction type. 123 */ 124 U8 sat_protocol; 125 126 /** 127 * This field keeps track of sgl pair to be retrieved from OS memory for processing. 128 */ 129 U8 sgl_pair_index; 130 131 struct 132 { 133 SCU_SGL_ELEMENT_PAIR_T * sgl_pair; 134 U8 sgl_set; 135 U32 sgl_offset; 136 } request_current; 137 } pio; 138 139 struct 140 { 141 /** 142 * The number of bytes requested in the PIO setup before CDB data frame. 143 */ 144 U32 device_preferred_cdb_length; 145 } packet; 146 } type; 147 148 } SCIC_SDS_STP_REQUEST_T; 149 150 /** 151 * @enum SCIC_SDS_STP_REQUEST_STARTED_UDMA_SUBSTATES 152 * 153 * @brief This enumeration depicts the various sub-states associated with 154 * a SATA/STP UDMA protocol operation. 155 */ 156 enum SCIC_SDS_STP_REQUEST_STARTED_UDMA_SUBSTATES 157 { 158 SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE, 159 SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE, 160 161 SCIC_SDS_STP_REQUEST_STARTED_UDMA_MAX_SUBSTATES 162 }; 163 164 /** 165 * @enum SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_SUBSTATES 166 * 167 * @brief This enumeration depicts the various sub-states associated with 168 * a SATA/STP non-data protocol operation. 169 */ 170 enum SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_SUBSTATES 171 { 172 SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE, 173 SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE, 174 SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_MAX_SUBSTATES 175 }; 176 177 /** 178 * @enum SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_SUBSTATES 179 * 180 * @brief THis enumeration depicts the various sub-states associated with a 181 * SATA/STP soft reset operation. 182 */ 183 enum SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_SUBSTATES 184 { 185 SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE, 186 SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE, 187 SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE, 188 189 SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_MAX_SUBSTATES 190 }; 191 192 extern SCIC_SDS_IO_REQUEST_STATE_HANDLER_T 193 scic_sds_stp_request_started_udma_substate_handler_table 194 [SCIC_SDS_STP_REQUEST_STARTED_UDMA_MAX_SUBSTATES]; 195 196 extern SCI_BASE_STATE_T 197 scic_sds_stp_request_started_udma_substate_table 198 [SCIC_SDS_STP_REQUEST_STARTED_UDMA_MAX_SUBSTATES]; 199 200 extern SCIC_SDS_IO_REQUEST_STATE_HANDLER_T 201 scic_sds_stp_request_started_non_data_substate_handler_table 202 [SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_MAX_SUBSTATES]; 203 204 extern SCI_BASE_STATE_T 205 scic_sds_stp_request_started_non_data_substate_table 206 [SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_MAX_SUBSTATES]; 207 208 209 extern SCIC_SDS_IO_REQUEST_STATE_HANDLER_T 210 scic_sds_stp_request_started_soft_reset_substate_handler_table 211 [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_MAX_SUBSTATES]; 212 213 extern SCI_BASE_STATE_T 214 scic_sds_stp_request_started_soft_reset_substate_table 215 [SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_MAX_SUBSTATES]; 216 217 // --------------------------------------------------------------------------- 218 219 U32 scic_sds_stp_request_get_object_size(void); 220 221 U32 scic_sds_stp_task_request_get_object_size(void); 222 223 void scu_sata_reqeust_construct_task_context( 224 SCIC_SDS_REQUEST_T * this_request, 225 SCU_TASK_CONTEXT_T * task_context 226 ); 227 228 void scic_sds_stp_non_ncq_request_construct( 229 SCIC_SDS_REQUEST_T *this_request 230 ); 231 232 SCI_STATUS scic_sds_stp_pio_request_construct( 233 SCIC_SDS_REQUEST_T * scic_io_request, 234 U8 sat_protocol, 235 BOOL copy_rx_frame 236 ); 237 238 SCI_STATUS scic_sds_stp_pio_request_construct_pass_through ( 239 SCIC_SDS_REQUEST_T * scic_io_request, 240 SCIC_STP_PASSTHRU_REQUEST_CALLBACKS_T *passthru_cb 241 ); 242 243 SCI_STATUS scic_sds_stp_udma_request_construct( 244 SCIC_SDS_REQUEST_T * this_request, 245 U32 transfer_length, 246 SCI_IO_REQUEST_DATA_DIRECTION data_direction 247 ); 248 249 SCI_STATUS scic_sds_stp_non_data_request_construct( 250 SCIC_SDS_REQUEST_T * this_request 251 ); 252 253 SCI_STATUS scic_sds_stp_soft_reset_request_construct( 254 SCIC_SDS_REQUEST_T * this_request 255 ); 256 257 SCI_STATUS scic_sds_stp_ncq_request_construct( 258 SCIC_SDS_REQUEST_T * this_request, 259 U32 transfer_length, 260 SCI_IO_REQUEST_DATA_DIRECTION data_direction 261 ); 262 263 void scu_stp_raw_request_construct_task_context( 264 SCIC_SDS_STP_REQUEST_T * this_request, 265 SCU_TASK_CONTEXT_T * task_context 266 267 ); 268 269 SCI_STATUS scic_sds_io_request_construct_sata( 270 SCIC_SDS_REQUEST_T * this_request, 271 U8 sat_protocol, 272 U32 transfer_length, 273 SCI_IO_REQUEST_DATA_DIRECTION data_direction, 274 BOOL copy_rx_frame, 275 BOOL do_translate_sgl 276 ); 277 278 #ifdef __cplusplus 279 } 280 #endif // __cplusplus 281 282 #endif // _SCIC_SDS_STP_REQUEST_T_ 283