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