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 #ifndef _SATI_TRANSLATOR_SEQUENCE_H_ 55 #define _SATI_TRANSLATOR_SEQUENCE_H_ 56 57 /** 58 * @file 59 * @brief This file contains all of the defintions for the SATI translator 60 * sequence. A translator sequence is simply a definition for the 61 * various sequences of commands that occur in this translator. 62 */ 63 64 #include <dev/isci/scil/sati_device.h> 65 66 /** 67 * @enum _SATI_TRANSLATOR_SEQUENCE_TYPE 68 * 69 * @brief This enumeration defines the possible sequence types for the 70 * translator. 71 */ 72 typedef enum _SATI_TRANSLATOR_SEQUENCE_TYPE 73 { 74 // SCSI Primary Command (SPC) sequences. 75 SATI_SEQUENCE_REPORT_LUNS, 76 SATI_SEQUENCE_TEST_UNIT_READY, 77 SATI_SEQUENCE_INQUIRY_STANDARD, 78 SATI_SEQUENCE_INQUIRY_SUPPORTED_PAGES, 79 SATI_SEQUENCE_INQUIRY_SERIAL_NUMBER, 80 SATI_SEQUENCE_INQUIRY_DEVICE_ID, 81 SATI_SEQUENCE_INQUIRY_ATA_INFORMATION, 82 SATI_SEQUENCE_INQUIRY_BLOCK_DEVICE, 83 SATI_SEQUENCE_INQUIRY_EXECUTE_DEVICE_DIAG, 84 SATI_SEQUENCE_MODE_SENSE_6_CACHING, 85 SATI_SEQUENCE_MODE_SENSE_6_INFORMATIONAL_EXCP_CONTROL, 86 SATI_SEQUENCE_MODE_SENSE_6_READ_WRITE_ERROR, 87 SATI_SEQUENCE_MODE_SENSE_6_DISCONNECT_RECONNECT, 88 SATI_SEQUENCE_MODE_SENSE_6_CONTROL, 89 SATI_SEQUENCE_MODE_SENSE_6_POWER_CONDITION, 90 SATI_SEQUENCE_MODE_SENSE_6_ALL_PAGES, 91 SATI_SEQUENCE_MODE_SENSE_10_CACHING, 92 SATI_SEQUENCE_MODE_SENSE_10_INFORMATIONAL_EXCP_CONTROL, 93 SATI_SEQUENCE_MODE_SENSE_10_READ_WRITE_ERROR, 94 SATI_SEQUENCE_MODE_SENSE_10_DISCONNECT_RECONNECT, 95 SATI_SEQUENCE_MODE_SENSE_10_CONTROL, 96 SATI_SEQUENCE_MODE_SENSE_10_POWER_CONDITION, 97 SATI_SEQUENCE_MODE_SENSE_10_ALL_PAGES, 98 SATI_SEQUENCE_MODE_SELECT_MODE_PAGE_CACHING, 99 SATI_SEQUENCE_MODE_SELECT_MODE_POWER_CONDITION, 100 SATI_SEQUENCE_MODE_SELECT_MODE_INFORMATION_EXCEPT_CONTROL, 101 102 //Log Sense Sequences 103 SATI_SEQUENCE_LOG_SENSE_SELF_TEST_LOG_PAGE, 104 SATI_SEQUENCE_LOG_SENSE_EXTENDED_SELF_TEST_LOG_PAGE, 105 SATI_SEQUENCE_LOG_SENSE_SUPPORTED_LOG_PAGE, 106 SATI_SEQUENCE_LOG_SENSE_INFO_EXCEPTION_LOG_PAGE, 107 108 // SCSI Block Command (SBC) sequences. 109 110 SATI_SEQUENCE_READ_6, 111 SATI_SEQUENCE_READ_10, 112 SATI_SEQUENCE_READ_12, 113 SATI_SEQUENCE_READ_16, 114 115 SATI_SEQUENCE_READ_CAPACITY_10, 116 SATI_SEQUENCE_READ_CAPACITY_16, 117 118 SATI_SEQUENCE_SYNCHRONIZE_CACHE, 119 120 SATI_SEQUENCE_VERIFY_10, 121 SATI_SEQUENCE_VERIFY_12, 122 SATI_SEQUENCE_VERIFY_16, 123 124 SATI_SEQUENCE_WRITE_6, 125 SATI_SEQUENCE_WRITE_10, 126 SATI_SEQUENCE_WRITE_12, 127 SATI_SEQUENCE_WRITE_16, 128 129 SATI_SEQUENCE_WRITE_AND_VERIFY, 130 131 SATI_SEQUENCE_START_STOP_UNIT, 132 133 SATI_SEQUENCE_REASSIGN_BLOCKS, 134 135 // SCSI Task Requests sequences 136 137 SATI_SEQUENCE_LUN_RESET, 138 SATI_SEQUENCE_ABORT_TASK_SET, 139 140 SATI_SEQUENCE_REQUEST_SENSE_SMART_RETURN_STATUS, 141 SATI_SEQUENCE_REQUEST_SENSE_CHECK_POWER_MODE, 142 143 SATI_SEQUENCE_WRITE_LONG, 144 145 SATI_SEQUENCE_UNMAP, 146 147 SATI_SEQUENCE_ATA_PASSTHROUGH_12, 148 SATI_SEQUENCE_ATA_PASSTHROUGH_16, 149 150 SATI_SEQUENCE_READ_BUFFER, 151 SATI_SEQUENCE_WRITE_BUFFER, 152 SATI_SEQUENCE_WRITE_BUFFER_MICROCODE 153 154 } SATI_TRANSLATOR_SEQUENCE_TYPE; 155 156 #define SATI_SEQUENCE_TYPE_READ_MIN SATI_SEQUENCE_READ_6 157 #define SATI_SEQUENCE_TYPE_READ_MAX SATI_SEQUENCE_READ_16 158 159 /** 160 * @name SATI_SEQUENCE_STATES 161 * 162 * These constants depict the various state values associated with a 163 * translation sequence. 164 */ 165 /*@{*/ 166 #define SATI_SEQUENCE_STATE_INITIAL 0 167 #define SATI_SEQUENCE_STATE_TRANSLATE_DATA 1 168 #define SATI_SEQUENCE_STATE_AWAIT_RESPONSE 2 169 #define SATI_SEQUENCE_STATE_FINAL 3 170 #define SATI_SEQUENCE_STATE_INCOMPLETE 4 171 #define SATI_SEQUENCE_STATE_READ_ERROR 5 172 /*@}*/ 173 174 /** 175 * @name SATI_DATA_DIRECTIONS 176 * 177 * These constants depict the various types of data directions for a 178 * translation sequence. Data can flow in/out (read/write) or no data at 179 * all. 180 */ 181 /*@{*/ 182 #define SATI_DATA_DIRECTION_NONE 0 183 #define SATI_DATA_DIRECTION_IN 1 184 #define SATI_DATA_DIRECTION_OUT 2 185 /*@}*/ 186 187 /** 188 * @struct SATI_MODE_SELECT_PROCESSING_STATE 189 * 190 * @brief This structure contains all of the current processing states 191 * for processing mode select 6 and 10 commands' parameter fields. 192 */ 193 typedef struct SATI_MODE_SELECT_PROCESSING_STATE 194 { 195 U8 * mode_pages; 196 U32 mode_page_offset; 197 U32 mode_pages_size; 198 U32 size_of_data_processed; 199 U32 total_ata_command_sent; 200 U32 ata_command_sent_for_cmp; // cmp: current mode page 201 BOOL current_mode_page_processed; 202 203 } SATI_MODE_SELECT_PROCESSING_STATE_T; 204 205 206 enum SATI_REASSIGN_BLOCKS_ATA_COMMAND_STATUS 207 { 208 SATI_REASSIGN_BLOCKS_READY_TO_SEND, 209 SATI_REASSIGN_BLOCKS_COMMAND_FAIL, 210 SATI_REASSIGN_BLOCKS_COMMAND_SUCCESS, 211 }; 212 213 /** 214 * @struct SATI_REASSIGN_BLOCKS_PROCESSING_STATE 215 * 216 * @brief This structure contains all of the current processing states 217 * for processing reassign block command's parameter fields. 218 */ 219 typedef struct SATI_REASSIGN_BLOCKS_PROCESSING_STATE 220 { 221 U32 lba_offset; 222 U32 block_lists_size; 223 U8 lba_size; 224 U32 size_of_data_processed; 225 U32 ata_command_sent_for_current_lba; 226 BOOL current_lba_processed; 227 enum SATI_REASSIGN_BLOCKS_ATA_COMMAND_STATUS ata_command_status; 228 229 }SATI_REASSIGN_BLOCKS_PROCESSING_STATE_T; 230 231 #define SATI_ATAPI_REQUEST_SENSE_CDB_LENGTH 12 232 233 /** 234 * @struct SATI_ATAPI_DATA 235 * 236 * @brief The SATI_ATAPI_DATA structure is for sati atapi IO specific data. 237 */ 238 typedef struct SATI_ATAPI_DATA 239 { 240 U8 request_sense_cdb[SATI_ATAPI_REQUEST_SENSE_CDB_LENGTH]; 241 } SATI_ATAPI_DATA_T; 242 243 244 enum SATI_UNMAP_ATA_COMMAND_STATUS 245 { 246 SATI_UNMAP_READY_TO_SEND, 247 SATI_UNMAP_COMMAND_FAIL, 248 SATI_UNMAP_COMMAND_SUCCESS, 249 }; 250 251 /** 252 * @struct SATI_UNMAP_PROCESSING_STATE 253 * 254 * @brief This structure contains all of the current processing states 255 * for processing unmap command data translation. 256 */ 257 typedef struct SATI_UNMAP_PROCESSING_STATE 258 { 259 U32 max_unmap_block_descriptors; 260 U32 current_unmap_block_descriptor_index; 261 U32 current_lba_count; 262 SATI_LBA current_lba; 263 SATI_LBA next_lba; 264 U32 max_lba_range_entries; 265 void * current_dsm_descriptor; 266 void * virtual_unmap_buffer; 267 U32 physical_unmap_buffer_low; 268 U32 physical_unmap_buffer_high; 269 void * unmap_buffer_sgl_pair; 270 } SATI_UNMAP_PROCESSING_STATE_T; 271 272 /** 273 * @struct SATI_TRANSLATOR_SEQUENCE 274 * 275 * @brief This structure contains all of the translation information 276 * associated with a particular request. 277 */ 278 typedef struct SATI_TRANSLATOR_SEQUENCE 279 { 280 /** 281 * This field contains the sequence type determined by the SATI. 282 */ 283 U8 type; 284 285 /** 286 * This field indicates the current state for the sequence. 287 */ 288 U8 state; 289 290 /** 291 * This field indicates the data direction (none, read, or write) for 292 * the translated request. 293 */ 294 U8 data_direction; 295 296 /** 297 * This field contains the SATA/ATA protocol to be utilized during 298 * the IO transfer. 299 */ 300 U8 protocol; 301 302 /** 303 * This field is utilized for sequences requiring data translation. 304 * It specifies the amount of data requested by the caller from the 305 * operation. It's necessary, because at times the user requests less 306 * data than is available. Thus, we need to avoid overrunning the 307 * buffer. 308 */ 309 U32 allocation_length; 310 311 /** 312 * This field specifies the amount of data that will actually be 313 * transferred across the wire for this ATA request. 314 */ 315 U32 ata_transfer_length; 316 317 /** 318 * This field specifies the amount of data bytes that have been 319 * set in a translation sequence. It will be incremented every time 320 * a data byte has been set by a sati translation. 321 */ 322 U16 number_data_bytes_set; 323 324 /** 325 * This field indicates whether or not the sense response has been set 326 * by the translation sequence. 327 */ 328 BOOL is_sense_response_set; 329 330 /** 331 * This field indicates whether or not the translation requires 332 * response translation. 333 */ 334 BOOL is_translate_response_required; 335 336 /** 337 * This field specifies the remote device context for which this 338 * translator sequence is destined. 339 */ 340 SATI_DEVICE_T * device; 341 342 /** 343 * This field is utilized to provide the translator with memory space 344 * required for translations that utilize multiple requests. 345 */ 346 union { 347 U32 translated_command; 348 U32 move_sector_count; 349 U32 scratch; 350 SATI_REASSIGN_BLOCKS_PROCESSING_STATE_T reassign_blocks_process_state; 351 SATI_MODE_SELECT_PROCESSING_STATE_T process_state; 352 SATI_UNMAP_PROCESSING_STATE_T unmap_process_state; 353 SATI_ATAPI_DATA_T sati_atapi_data; 354 } command_specific_data; 355 356 } SATI_TRANSLATOR_SEQUENCE_T; 357 358 359 360 #endif // _SATI_TRANSLATOR_SEQUENCE_H_ 361 362