Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 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 | * * Neither the name of Intel Corporation nor the names of its |
| 40 | * contributors may be used to endorse or promote products derived |
| 41 | * from this software without specific prior written permission. |
| 42 | * |
| 43 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 44 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 45 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 46 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 47 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 48 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 49 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 50 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 51 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 52 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 53 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 54 | */ |
| 55 | |
| 56 | #ifndef _SCIC_SDS_STP_REQUEST_T_ |
| 57 | #define _SCIC_SDS_STP_REQUEST_T_ |
| 58 | |
Dan Williams | 82d2992 | 2011-02-08 17:53:10 -0800 | [diff] [blame] | 59 | #include <linux/dma-mapping.h> |
Dave Jiang | e76d618 | 2011-05-04 15:02:03 -0700 | [diff] [blame] | 60 | #include <scsi/sas.h> |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 61 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 62 | struct scic_sds_stp_request { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 63 | union { |
| 64 | u32 ncq; |
| 65 | |
| 66 | u32 udma; |
| 67 | |
Dan Williams | 35173d5 | 2011-03-26 16:43:01 -0700 | [diff] [blame] | 68 | struct scic_sds_stp_pio_request { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 69 | /** |
| 70 | * Total transfer for the entire PIO request recorded at request constuction |
| 71 | * time. |
| 72 | * |
| 73 | * @todo Should we just decrement this value for each byte of data transitted |
| 74 | * or received to elemenate the current_transfer_bytes field? |
| 75 | */ |
| 76 | u32 total_transfer_bytes; |
| 77 | |
| 78 | /** |
| 79 | * Total number of bytes received/transmitted in data frames since the start |
| 80 | * of the IO request. At the end of the IO request this should equal the |
| 81 | * total_transfer_bytes. |
| 82 | */ |
| 83 | u32 current_transfer_bytes; |
| 84 | |
| 85 | /** |
| 86 | * The number of bytes requested in the in the PIO setup. |
| 87 | */ |
| 88 | u32 pio_transfer_bytes; |
| 89 | |
| 90 | /** |
| 91 | * PIO Setup ending status value to tell us if we need to wait for another FIS |
| 92 | * or if the transfer is complete. On the receipt of a D2H FIS this will be |
| 93 | * the status field of that FIS. |
| 94 | */ |
| 95 | u8 ending_status; |
| 96 | |
| 97 | /** |
| 98 | * On receipt of a D2H FIS this will be the ending error field if the |
| 99 | * ending_status has the SATA_STATUS_ERR bit set. |
| 100 | */ |
| 101 | u8 ending_error; |
| 102 | |
Dave Jiang | 103a00c | 2011-02-23 15:57:24 -0800 | [diff] [blame] | 103 | struct scic_sds_request_pio_sgl { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 104 | struct scu_sgl_element_pair *sgl_pair; |
| 105 | u8 sgl_set; |
| 106 | u32 sgl_offset; |
| 107 | } request_current; |
| 108 | } pio; |
| 109 | |
| 110 | struct { |
| 111 | /** |
| 112 | * The number of bytes requested in the PIO setup before CDB data frame. |
| 113 | */ |
| 114 | u32 device_preferred_cdb_length; |
| 115 | } packet; |
| 116 | } type; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 117 | }; |
| 118 | |
| 119 | /** |
Dave Jiang | de728b7 | 2011-03-26 17:14:07 -0700 | [diff] [blame] | 120 | * enum scic_sds_stp_request_started_udma_substates - This enumeration depicts |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 121 | * the various sub-states associated with a SATA/STP UDMA protocol operation. |
| 122 | * |
| 123 | * |
| 124 | */ |
Dave Jiang | de728b7 | 2011-03-26 17:14:07 -0700 | [diff] [blame] | 125 | enum scic_sds_stp_request_started_udma_substates { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 126 | SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_TC_COMPLETION_SUBSTATE, |
| 127 | SCIC_SDS_STP_REQUEST_STARTED_UDMA_AWAIT_D2H_REG_FIS_SUBSTATE, |
| 128 | }; |
| 129 | |
| 130 | /** |
Dave Jiang | de728b7 | 2011-03-26 17:14:07 -0700 | [diff] [blame] | 131 | * enum scic_sds_stp_request_started_non_data_substates - This enumeration |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 132 | * depicts the various sub-states associated with a SATA/STP non-data |
| 133 | * protocol operation. |
| 134 | * |
| 135 | * |
| 136 | */ |
Dave Jiang | de728b7 | 2011-03-26 17:14:07 -0700 | [diff] [blame] | 137 | enum scic_sds_stp_request_started_non_data_substates { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 138 | SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_H2D_COMPLETION_SUBSTATE, |
| 139 | SCIC_SDS_STP_REQUEST_STARTED_NON_DATA_AWAIT_D2H_SUBSTATE, |
| 140 | }; |
| 141 | |
| 142 | /** |
Dave Jiang | de728b7 | 2011-03-26 17:14:07 -0700 | [diff] [blame] | 143 | * enum scic_sds_stp_request_started_soft_reset_substates - THis enumeration |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 144 | * depicts the various sub-states associated with a SATA/STP soft reset |
| 145 | * operation. |
| 146 | * |
| 147 | * |
| 148 | */ |
Dave Jiang | de728b7 | 2011-03-26 17:14:07 -0700 | [diff] [blame] | 149 | enum scic_sds_stp_request_started_soft_reset_substates { |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 150 | SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_ASSERTED_COMPLETION_SUBSTATE, |
| 151 | SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_H2D_DIAGNOSTIC_COMPLETION_SUBSTATE, |
| 152 | SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE, |
| 153 | }; |
| 154 | |
Dan Williams | f1f52e7 | 2011-05-10 02:28:45 -0700 | [diff] [blame^] | 155 | /* This is the enumeration of the SATA PIO DATA IN started substate machine. */ |
| 156 | enum _scic_sds_stp_request_started_pio_substates { |
| 157 | /** |
| 158 | * While in this state the IO request object is waiting for the TC completion |
| 159 | * notification for the H2D Register FIS |
| 160 | */ |
| 161 | SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE, |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 162 | |
Dan Williams | f1f52e7 | 2011-05-10 02:28:45 -0700 | [diff] [blame^] | 163 | /** |
| 164 | * While in this state the IO request object is waiting for either a PIO Setup |
| 165 | * FIS or a D2H register FIS. The type of frame received is based on the |
| 166 | * result of the prior frame and line conditions. |
| 167 | */ |
| 168 | SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE, |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 169 | |
Dan Williams | f1f52e7 | 2011-05-10 02:28:45 -0700 | [diff] [blame^] | 170 | /** |
| 171 | * While in this state the IO request object is waiting for a DATA frame from |
| 172 | * the device. |
| 173 | */ |
| 174 | SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE, |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 175 | |
Dan Williams | f1f52e7 | 2011-05-10 02:28:45 -0700 | [diff] [blame^] | 176 | /** |
| 177 | * While in this state the IO request object is waiting to transmit the next data |
| 178 | * frame to the device. |
| 179 | */ |
| 180 | SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE, |
| 181 | }; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 182 | |
Dan Williams | f1f52e7 | 2011-05-10 02:28:45 -0700 | [diff] [blame^] | 183 | struct scic_sds_request; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 184 | |
Dan Williams | f1f52e7 | 2011-05-10 02:28:45 -0700 | [diff] [blame^] | 185 | enum sci_status scic_sds_stp_pio_request_construct(struct scic_sds_request *sci_req, |
| 186 | bool copy_rx_frame); |
| 187 | enum sci_status scic_sds_stp_udma_request_construct(struct scic_sds_request *sci_req, |
| 188 | u32 transfer_length, |
| 189 | enum dma_data_direction dir); |
| 190 | enum sci_status scic_sds_stp_non_data_request_construct(struct scic_sds_request *sci_req); |
| 191 | enum sci_status scic_sds_stp_soft_reset_request_construct(struct scic_sds_request *sci_req); |
| 192 | enum sci_status scic_sds_stp_ncq_request_construct(struct scic_sds_request *sci_req, |
| 193 | u32 transfer_length, |
| 194 | enum dma_data_direction dir); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 195 | #endif /* _SCIC_SDS_STP_REQUEST_T_ */ |