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