![]() |
|
|||
0001 /* 0002 * This file is provided under a dual BSD/GPLv2 license. When using or 0003 * redistributing this file, you may do so under either license. 0004 * 0005 * GPL LICENSE SUMMARY 0006 * 0007 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 0008 * 0009 * This program is free software; you can redistribute it and/or modify 0010 * it under the terms of version 2 of the GNU General Public License as 0011 * published by the Free Software Foundation. 0012 * 0013 * This program is distributed in the hope that it will be useful, but 0014 * WITHOUT ANY WARRANTY; without even the implied warranty of 0015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 * General Public License for more details. 0017 * 0018 * You should have received a copy of the GNU General Public License 0019 * along with this program; if not, write to the Free Software 0020 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 0021 * The full GNU General Public License is included in this distribution 0022 * in the file called LICENSE.GPL. 0023 * 0024 * BSD LICENSE 0025 * 0026 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 0027 * All rights reserved. 0028 * 0029 * Redistribution and use in source and binary forms, with or without 0030 * modification, are permitted provided that the following conditions 0031 * are met: 0032 * 0033 * * Redistributions of source code must retain the above copyright 0034 * notice, this list of conditions and the following disclaimer. 0035 * * Redistributions in binary form must reproduce the above copyright 0036 * notice, this list of conditions and the following disclaimer in 0037 * the documentation and/or other materials provided with the 0038 * distribution. 0039 * * Neither the name of Intel Corporation nor the names of its 0040 * contributors may be used to endorse or promote products derived 0041 * from this software without specific prior written permission. 0042 * 0043 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 0044 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 0045 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 0046 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 0047 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 0048 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 0049 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0050 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0051 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0052 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0053 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0054 */ 0055 0056 #ifndef _ISCI_REQUEST_H_ 0057 #define _ISCI_REQUEST_H_ 0058 0059 #include "isci.h" 0060 #include "host.h" 0061 #include "scu_task_context.h" 0062 0063 /** 0064 * isci_stp_request - extra request infrastructure to handle pio/atapi protocol 0065 * @pio_len - number of bytes requested at PIO setup 0066 * @status - pio setup ending status value to tell us if we need 0067 * to wait for another fis or if the transfer is complete. Upon 0068 * receipt of a d2h fis this will be the status field of that fis. 0069 * @sgl - track pio transfer progress as we iterate through the sgl 0070 */ 0071 struct isci_stp_request { 0072 u32 pio_len; 0073 u8 status; 0074 0075 struct isci_stp_pio_sgl { 0076 int index; 0077 u8 set; 0078 u32 offset; 0079 } sgl; 0080 }; 0081 0082 struct isci_request { 0083 #define IREQ_COMPLETE_IN_TARGET 0 0084 #define IREQ_TERMINATED 1 0085 #define IREQ_TMF 2 0086 #define IREQ_ACTIVE 3 0087 #define IREQ_PENDING_ABORT 4 /* Set == device was not suspended yet */ 0088 #define IREQ_TC_ABORT_POSTED 5 0089 #define IREQ_ABORT_PATH_ACTIVE 6 0090 #define IREQ_NO_AUTO_FREE_TAG 7 /* Set when being explicitly managed */ 0091 unsigned long flags; 0092 /* XXX kill ttype and ttype_ptr, allocate full sas_task */ 0093 union ttype_ptr_union { 0094 struct sas_task *io_task_ptr; /* When ttype==io_task */ 0095 struct isci_tmf *tmf_task_ptr; /* When ttype==tmf_task */ 0096 } ttype_ptr; 0097 struct isci_host *isci_host; 0098 dma_addr_t request_daddr; 0099 dma_addr_t zero_scatter_daddr; 0100 unsigned int num_sg_entries; 0101 /* Note: "io_request_completion" is completed in two different ways 0102 * depending on whether this is a TMF or regular request. 0103 * - TMF requests are completed in the thread that started them; 0104 * - regular requests are completed in the request completion callback 0105 * function. 0106 * This difference in operation allows the aborter of a TMF request 0107 * to be sure that once the TMF request completes, the I/O that the 0108 * TMF was aborting is guaranteed to have completed. 0109 * 0110 * XXX kill io_request_completion 0111 */ 0112 struct completion *io_request_completion; 0113 struct sci_base_state_machine sm; 0114 struct isci_host *owning_controller; 0115 struct isci_remote_device *target_device; 0116 u16 io_tag; 0117 enum sas_protocol protocol; 0118 u32 scu_status; /* hardware result */ 0119 u32 sci_status; /* upper layer disposition */ 0120 u32 post_context; 0121 struct scu_task_context *tc; 0122 /* could be larger with sg chaining */ 0123 #define SCU_SGL_SIZE ((SCI_MAX_SCATTER_GATHER_ELEMENTS + 1) / 2) 0124 struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32))); 0125 /* This field is a pointer to the stored rx frame data. It is used in 0126 * STP internal requests and SMP response frames. If this field is 0127 * non-NULL the saved frame must be released on IO request completion. 0128 */ 0129 u32 saved_rx_frame_index; 0130 0131 union { 0132 struct { 0133 union { 0134 struct ssp_cmd_iu cmd; 0135 struct ssp_task_iu tmf; 0136 }; 0137 union { 0138 struct ssp_response_iu rsp; 0139 u8 rsp_buf[SSP_RESP_IU_MAX_SIZE]; 0140 }; 0141 } ssp; 0142 struct { 0143 struct isci_stp_request req; 0144 struct host_to_dev_fis cmd; 0145 struct dev_to_host_fis rsp; 0146 } stp; 0147 }; 0148 }; 0149 0150 static inline struct isci_request *to_ireq(struct isci_stp_request *stp_req) 0151 { 0152 struct isci_request *ireq; 0153 0154 ireq = container_of(stp_req, typeof(*ireq), stp.req); 0155 return ireq; 0156 } 0157 0158 /** 0159 * enum sci_base_request_states - request state machine states 0160 * 0161 * @SCI_REQ_INIT: Simply the initial state for the base request state machine. 0162 * 0163 * @SCI_REQ_CONSTRUCTED: This state indicates that the request has been 0164 * constructed. This state is entered from the INITIAL state. 0165 * 0166 * @SCI_REQ_STARTED: This state indicates that the request has been started. 0167 * This state is entered from the CONSTRUCTED state. 0168 * 0169 * @SCI_REQ_STP_UDMA_WAIT_TC_COMP: 0170 * @SCI_REQ_STP_UDMA_WAIT_D2H: 0171 * @SCI_REQ_STP_NON_DATA_WAIT_H2D: 0172 * @SCI_REQ_STP_NON_DATA_WAIT_D2H: 0173 * 0174 * @SCI_REQ_STP_PIO_WAIT_H2D: While in this state the IO request object is 0175 * waiting for the TC completion notification for the H2D Register FIS 0176 * 0177 * @SCI_REQ_STP_PIO_WAIT_FRAME: While in this state the IO request object is 0178 * waiting for either a PIO Setup FIS or a D2H register FIS. The type of frame 0179 * received is based on the result of the prior frame and line conditions. 0180 * 0181 * @SCI_REQ_STP_PIO_DATA_IN: While in this state the IO request object is 0182 * waiting for a DATA frame from the device. 0183 * 0184 * @SCI_REQ_STP_PIO_DATA_OUT: While in this state the IO request object is 0185 * waiting to transmit the next data frame to the device. 0186 * 0187 * @SCI_REQ_ATAPI_WAIT_H2D: While in this state the IO request object is 0188 * waiting for the TC completion notification for the H2D Register FIS 0189 * 0190 * @SCI_REQ_ATAPI_WAIT_PIO_SETUP: While in this state the IO request object is 0191 * waiting for either a PIO Setup. 0192 * 0193 * @SCI_REQ_ATAPI_WAIT_D2H: The non-data IO transit to this state in this state 0194 * after receiving TC completion. While in this state IO request object is 0195 * waiting for D2H status frame as UF. 0196 * 0197 * @SCI_REQ_ATAPI_WAIT_TC_COMP: When transmitting raw frames hardware reports 0198 * task context completion after every frame submission, so in the 0199 * non-accelerated case we need to expect the completion for the "cdb" frame. 0200 * 0201 * @SCI_REQ_TASK_WAIT_TC_COMP: The AWAIT_TC_COMPLETION sub-state indicates that 0202 * the started raw task management request is waiting for the transmission of 0203 * the initial frame (i.e. command, task, etc.). 0204 * 0205 * @SCI_REQ_TASK_WAIT_TC_RESP: This sub-state indicates that the started task 0206 * management request is waiting for the reception of an unsolicited frame 0207 * (i.e. response IU). 0208 * 0209 * @SCI_REQ_SMP_WAIT_RESP: This sub-state indicates that the started task 0210 * management request is waiting for the reception of an unsolicited frame 0211 * (i.e. response IU). 0212 * 0213 * @SCI_REQ_SMP_WAIT_TC_COMP: The AWAIT_TC_COMPLETION sub-state indicates that 0214 * the started SMP request is waiting for the transmission of the initial frame 0215 * (i.e. command, task, etc.). 0216 * 0217 * @SCI_REQ_COMPLETED: This state indicates that the request has completed. 0218 * This state is entered from the STARTED state. This state is entered from the 0219 * ABORTING state. 0220 * 0221 * @SCI_REQ_ABORTING: This state indicates that the request is in the process 0222 * of being terminated/aborted. This state is entered from the CONSTRUCTED 0223 * state. This state is entered from the STARTED state. 0224 * 0225 * @SCI_REQ_FINAL: Simply the final state for the base request state machine. 0226 */ 0227 #define REQUEST_STATES {\ 0228 C(REQ_INIT),\ 0229 C(REQ_CONSTRUCTED),\ 0230 C(REQ_STARTED),\ 0231 C(REQ_STP_UDMA_WAIT_TC_COMP),\ 0232 C(REQ_STP_UDMA_WAIT_D2H),\ 0233 C(REQ_STP_NON_DATA_WAIT_H2D),\ 0234 C(REQ_STP_NON_DATA_WAIT_D2H),\ 0235 C(REQ_STP_PIO_WAIT_H2D),\ 0236 C(REQ_STP_PIO_WAIT_FRAME),\ 0237 C(REQ_STP_PIO_DATA_IN),\ 0238 C(REQ_STP_PIO_DATA_OUT),\ 0239 C(REQ_ATAPI_WAIT_H2D),\ 0240 C(REQ_ATAPI_WAIT_PIO_SETUP),\ 0241 C(REQ_ATAPI_WAIT_D2H),\ 0242 C(REQ_ATAPI_WAIT_TC_COMP),\ 0243 C(REQ_TASK_WAIT_TC_COMP),\ 0244 C(REQ_TASK_WAIT_TC_RESP),\ 0245 C(REQ_SMP_WAIT_RESP),\ 0246 C(REQ_SMP_WAIT_TC_COMP),\ 0247 C(REQ_COMPLETED),\ 0248 C(REQ_ABORTING),\ 0249 C(REQ_FINAL),\ 0250 } 0251 #undef C 0252 #define C(a) SCI_##a 0253 enum sci_base_request_states REQUEST_STATES; 0254 #undef C 0255 const char *req_state_name(enum sci_base_request_states state); 0256 0257 enum sci_status sci_request_start(struct isci_request *ireq); 0258 enum sci_status sci_io_request_terminate(struct isci_request *ireq); 0259 enum sci_status 0260 sci_io_request_event_handler(struct isci_request *ireq, 0261 u32 event_code); 0262 enum sci_status 0263 sci_io_request_frame_handler(struct isci_request *ireq, 0264 u32 frame_index); 0265 enum sci_status 0266 sci_task_request_terminate(struct isci_request *ireq); 0267 extern enum sci_status 0268 sci_request_complete(struct isci_request *ireq); 0269 extern enum sci_status 0270 sci_io_request_tc_completion(struct isci_request *ireq, u32 code); 0271 0272 /* XXX open code in caller */ 0273 static inline dma_addr_t 0274 sci_io_request_get_dma_addr(struct isci_request *ireq, void *virt_addr) 0275 { 0276 0277 char *requested_addr = (char *)virt_addr; 0278 char *base_addr = (char *)ireq; 0279 0280 BUG_ON(requested_addr < base_addr); 0281 BUG_ON((requested_addr - base_addr) >= sizeof(*ireq)); 0282 0283 return ireq->request_daddr + (requested_addr - base_addr); 0284 } 0285 0286 #define isci_request_access_task(req) ((req)->ttype_ptr.io_task_ptr) 0287 0288 #define isci_request_access_tmf(req) ((req)->ttype_ptr.tmf_task_ptr) 0289 0290 struct isci_request *isci_tmf_request_from_tag(struct isci_host *ihost, 0291 struct isci_tmf *isci_tmf, 0292 u16 tag); 0293 int isci_request_execute(struct isci_host *ihost, struct isci_remote_device *idev, 0294 struct sas_task *task, struct isci_request *ireq); 0295 struct isci_request *isci_io_request_from_tag(struct isci_host *ihost, 0296 struct sas_task *task, 0297 u16 tag); 0298 enum sci_status 0299 sci_task_request_construct(struct isci_host *ihost, 0300 struct isci_remote_device *idev, 0301 u16 io_tag, 0302 struct isci_request *ireq); 0303 enum sci_status sci_task_request_construct_ssp(struct isci_request *ireq); 0304 void sci_smp_request_copy_response(struct isci_request *ireq); 0305 0306 static inline int isci_task_is_ncq_recovery(struct sas_task *task) 0307 { 0308 return (sas_protocol_ata(task->task_proto) && 0309 task->ata_task.fis.command == ATA_CMD_READ_LOG_EXT && 0310 task->ata_task.fis.lbal == ATA_LOG_SATA_NCQ); 0311 0312 } 0313 #endif /* !defined(_ISCI_REQUEST_H_) */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |