^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * This file is provided under a dual BSD/GPLv2 license. When using or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * redistributing this file, you may do so under either license.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * GPL LICENSE SUMMARY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * This program is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * it under the terms of version 2 of the GNU General Public License as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * published by the Free Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * This program is distributed in the hope that it will be useful, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * You should have received a copy of the GNU General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * along with this program; if not, write to the Free Software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * The full GNU General Public License is included in this distribution
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * in the file called LICENSE.GPL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * BSD LICENSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * modification, are permitted provided that the following conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * are met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * * Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * notice, this list of conditions and the following disclaimer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * * Redistributions in binary form must reproduce the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * notice, this list of conditions and the following disclaimer in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * the documentation and/or other materials provided with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * distribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * * Neither the name of Intel Corporation nor the names of its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * contributors may be used to endorse or promote products derived
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * from this software without specific prior written permission.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #ifndef _ISCI_REQUEST_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define _ISCI_REQUEST_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #include "isci.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #include "host.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #include "scu_task_context.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * isci_stp_request - extra request infrastructure to handle pio/atapi protocol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * @pio_len - number of bytes requested at PIO setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * @status - pio setup ending status value to tell us if we need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * to wait for another fis or if the transfer is complete. Upon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * receipt of a d2h fis this will be the status field of that fis.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * @sgl - track pio transfer progress as we iterate through the sgl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct isci_stp_request {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) u32 pio_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) u8 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct isci_stp_pio_sgl {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) int index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) u8 set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) u32 offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) } sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) struct isci_request {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #define IREQ_COMPLETE_IN_TARGET 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #define IREQ_TERMINATED 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #define IREQ_TMF 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #define IREQ_ACTIVE 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #define IREQ_PENDING_ABORT 4 /* Set == device was not suspended yet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) #define IREQ_TC_ABORT_POSTED 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #define IREQ_ABORT_PATH_ACTIVE 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #define IREQ_NO_AUTO_FREE_TAG 7 /* Set when being explicitly managed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) /* XXX kill ttype and ttype_ptr, allocate full sas_task */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) union ttype_ptr_union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) struct sas_task *io_task_ptr; /* When ttype==io_task */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct isci_tmf *tmf_task_ptr; /* When ttype==tmf_task */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) } ttype_ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) struct isci_host *isci_host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) dma_addr_t request_daddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) dma_addr_t zero_scatter_daddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) unsigned int num_sg_entries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) /* Note: "io_request_completion" is completed in two different ways
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * depending on whether this is a TMF or regular request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * - TMF requests are completed in the thread that started them;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * - regular requests are completed in the request completion callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * This difference in operation allows the aborter of a TMF request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * to be sure that once the TMF request completes, the I/O that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * TMF was aborting is guaranteed to have completed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * XXX kill io_request_completion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct completion *io_request_completion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct sci_base_state_machine sm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) struct isci_host *owning_controller;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) struct isci_remote_device *target_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) u16 io_tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) enum sas_protocol protocol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) u32 scu_status; /* hardware result */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) u32 sci_status; /* upper layer disposition */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) u32 post_context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) struct scu_task_context *tc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) /* could be larger with sg chaining */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #define SCU_SGL_SIZE ((SCI_MAX_SCATTER_GATHER_ELEMENTS + 1) / 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) /* This field is a pointer to the stored rx frame data. It is used in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) * STP internal requests and SMP response frames. If this field is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * non-NULL the saved frame must be released on IO request completion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) u32 saved_rx_frame_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) struct ssp_cmd_iu cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) struct ssp_task_iu tmf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) struct ssp_response_iu rsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) u8 rsp_buf[SSP_RESP_IU_MAX_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) } ssp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) struct isci_stp_request req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) struct host_to_dev_fis cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) struct dev_to_host_fis rsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) } stp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) static inline struct isci_request *to_ireq(struct isci_stp_request *stp_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) struct isci_request *ireq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) ireq = container_of(stp_req, typeof(*ireq), stp.req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) return ireq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) * enum sci_base_request_states - request state machine states
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) * @SCI_REQ_INIT: Simply the initial state for the base request state machine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * @SCI_REQ_CONSTRUCTED: This state indicates that the request has been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * constructed. This state is entered from the INITIAL state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * @SCI_REQ_STARTED: This state indicates that the request has been started.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) * This state is entered from the CONSTRUCTED state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) * @SCI_REQ_STP_UDMA_WAIT_TC_COMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) * @SCI_REQ_STP_UDMA_WAIT_D2H:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) * @SCI_REQ_STP_NON_DATA_WAIT_H2D:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) * @SCI_REQ_STP_NON_DATA_WAIT_D2H:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) * @SCI_REQ_STP_PIO_WAIT_H2D: While in this state the IO request object is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * waiting for the TC completion notification for the H2D Register FIS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * @SCI_REQ_STP_PIO_WAIT_FRAME: While in this state the IO request object is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) * waiting for either a PIO Setup FIS or a D2H register FIS. The type of frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * received is based on the result of the prior frame and line conditions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * @SCI_REQ_STP_PIO_DATA_IN: While in this state the IO request object is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * waiting for a DATA frame from the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) * @SCI_REQ_STP_PIO_DATA_OUT: While in this state the IO request object is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) * waiting to transmit the next data frame to the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) * @SCI_REQ_ATAPI_WAIT_H2D: While in this state the IO request object is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * waiting for the TC completion notification for the H2D Register FIS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) * @SCI_REQ_ATAPI_WAIT_PIO_SETUP: While in this state the IO request object is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * waiting for either a PIO Setup.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) * @SCI_REQ_ATAPI_WAIT_D2H: The non-data IO transit to this state in this state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) * after receiving TC completion. While in this state IO request object is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) * waiting for D2H status frame as UF.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) * @SCI_REQ_ATAPI_WAIT_TC_COMP: When transmitting raw frames hardware reports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) * task context completion after every frame submission, so in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) * non-accelerated case we need to expect the completion for the "cdb" frame.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) * @SCI_REQ_TASK_WAIT_TC_COMP: The AWAIT_TC_COMPLETION sub-state indicates that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) * the started raw task management request is waiting for the transmission of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) * the initial frame (i.e. command, task, etc.).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) * @SCI_REQ_TASK_WAIT_TC_RESP: This sub-state indicates that the started task
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) * management request is waiting for the reception of an unsolicited frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) * (i.e. response IU).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) * @SCI_REQ_SMP_WAIT_RESP: This sub-state indicates that the started task
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * management request is waiting for the reception of an unsolicited frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * (i.e. response IU).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) * @SCI_REQ_SMP_WAIT_TC_COMP: The AWAIT_TC_COMPLETION sub-state indicates that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) * the started SMP request is waiting for the transmission of the initial frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) * (i.e. command, task, etc.).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) * @SCI_REQ_COMPLETED: This state indicates that the request has completed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) * This state is entered from the STARTED state. This state is entered from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) * ABORTING state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) * @SCI_REQ_ABORTING: This state indicates that the request is in the process
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) * of being terminated/aborted. This state is entered from the CONSTRUCTED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) * state. This state is entered from the STARTED state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) * @SCI_REQ_FINAL: Simply the final state for the base request state machine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) #define REQUEST_STATES {\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) C(REQ_INIT),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) C(REQ_CONSTRUCTED),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) C(REQ_STARTED),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) C(REQ_STP_UDMA_WAIT_TC_COMP),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) C(REQ_STP_UDMA_WAIT_D2H),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) C(REQ_STP_NON_DATA_WAIT_H2D),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) C(REQ_STP_NON_DATA_WAIT_D2H),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) C(REQ_STP_PIO_WAIT_H2D),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) C(REQ_STP_PIO_WAIT_FRAME),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) C(REQ_STP_PIO_DATA_IN),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) C(REQ_STP_PIO_DATA_OUT),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) C(REQ_ATAPI_WAIT_H2D),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) C(REQ_ATAPI_WAIT_PIO_SETUP),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) C(REQ_ATAPI_WAIT_D2H),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) C(REQ_ATAPI_WAIT_TC_COMP),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) C(REQ_TASK_WAIT_TC_COMP),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) C(REQ_TASK_WAIT_TC_RESP),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) C(REQ_SMP_WAIT_RESP),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) C(REQ_SMP_WAIT_TC_COMP),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) C(REQ_COMPLETED),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) C(REQ_ABORTING),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) C(REQ_FINAL),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) #undef C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) #define C(a) SCI_##a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) enum sci_base_request_states REQUEST_STATES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) #undef C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) const char *req_state_name(enum sci_base_request_states state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) enum sci_status sci_request_start(struct isci_request *ireq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) enum sci_status sci_io_request_terminate(struct isci_request *ireq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) enum sci_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) sci_io_request_event_handler(struct isci_request *ireq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) u32 event_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) enum sci_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) sci_io_request_frame_handler(struct isci_request *ireq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) u32 frame_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) enum sci_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) sci_task_request_terminate(struct isci_request *ireq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) extern enum sci_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) sci_request_complete(struct isci_request *ireq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) extern enum sci_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) sci_io_request_tc_completion(struct isci_request *ireq, u32 code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) /* XXX open code in caller */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) static inline dma_addr_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) sci_io_request_get_dma_addr(struct isci_request *ireq, void *virt_addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) char *requested_addr = (char *)virt_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) char *base_addr = (char *)ireq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) BUG_ON(requested_addr < base_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) BUG_ON((requested_addr - base_addr) >= sizeof(*ireq));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) return ireq->request_daddr + (requested_addr - base_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) #define isci_request_access_task(req) ((req)->ttype_ptr.io_task_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) #define isci_request_access_tmf(req) ((req)->ttype_ptr.tmf_task_ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) struct isci_request *isci_tmf_request_from_tag(struct isci_host *ihost,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) struct isci_tmf *isci_tmf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) u16 tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) int isci_request_execute(struct isci_host *ihost, struct isci_remote_device *idev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) struct sas_task *task, u16 tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) enum sci_status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) sci_task_request_construct(struct isci_host *ihost,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) struct isci_remote_device *idev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) u16 io_tag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) struct isci_request *ireq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) enum sci_status sci_task_request_construct_ssp(struct isci_request *ireq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) void sci_smp_request_copy_response(struct isci_request *ireq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) static inline int isci_task_is_ncq_recovery(struct sas_task *task)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) return (sas_protocol_ata(task->task_proto) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) task->ata_task.fis.command == ATA_CMD_READ_LOG_EXT &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) task->ata_task.fis.lbal == ATA_LOG_SATA_NCQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) #endif /* !defined(_ISCI_REQUEST_H_) */