1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * This file is provided under a dual BSD/GPLv2 license. When using or
3*4882a593Smuzhiyun * redistributing this file, you may do so under either license.
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * GPL LICENSE SUMMARY
6*4882a593Smuzhiyun *
7*4882a593Smuzhiyun * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8*4882a593Smuzhiyun *
9*4882a593Smuzhiyun * This program is free software; you can redistribute it and/or modify
10*4882a593Smuzhiyun * it under the terms of version 2 of the GNU General Public License as
11*4882a593Smuzhiyun * published by the Free Software Foundation.
12*4882a593Smuzhiyun *
13*4882a593Smuzhiyun * This program is distributed in the hope that it will be useful, but
14*4882a593Smuzhiyun * WITHOUT ANY WARRANTY; without even the implied warranty of
15*4882a593Smuzhiyun * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16*4882a593Smuzhiyun * General Public License for more details.
17*4882a593Smuzhiyun *
18*4882a593Smuzhiyun * You should have received a copy of the GNU General Public License
19*4882a593Smuzhiyun * along with this program; if not, write to the Free Software
20*4882a593Smuzhiyun * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21*4882a593Smuzhiyun * The full GNU General Public License is included in this distribution
22*4882a593Smuzhiyun * in the file called LICENSE.GPL.
23*4882a593Smuzhiyun *
24*4882a593Smuzhiyun * BSD LICENSE
25*4882a593Smuzhiyun *
26*4882a593Smuzhiyun * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27*4882a593Smuzhiyun * All rights reserved.
28*4882a593Smuzhiyun *
29*4882a593Smuzhiyun * Redistribution and use in source and binary forms, with or without
30*4882a593Smuzhiyun * modification, are permitted provided that the following conditions
31*4882a593Smuzhiyun * are met:
32*4882a593Smuzhiyun *
33*4882a593Smuzhiyun * * Redistributions of source code must retain the above copyright
34*4882a593Smuzhiyun * notice, this list of conditions and the following disclaimer.
35*4882a593Smuzhiyun * * Redistributions in binary form must reproduce the above copyright
36*4882a593Smuzhiyun * notice, this list of conditions and the following disclaimer in
37*4882a593Smuzhiyun * the documentation and/or other materials provided with the
38*4882a593Smuzhiyun * distribution.
39*4882a593Smuzhiyun * * Neither the name of Intel Corporation nor the names of its
40*4882a593Smuzhiyun * contributors may be used to endorse or promote products derived
41*4882a593Smuzhiyun * from this software without specific prior written permission.
42*4882a593Smuzhiyun *
43*4882a593Smuzhiyun * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44*4882a593Smuzhiyun * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45*4882a593Smuzhiyun * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46*4882a593Smuzhiyun * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47*4882a593Smuzhiyun * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48*4882a593Smuzhiyun * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49*4882a593Smuzhiyun * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50*4882a593Smuzhiyun * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51*4882a593Smuzhiyun * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52*4882a593Smuzhiyun * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53*4882a593Smuzhiyun * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54*4882a593Smuzhiyun */
55*4882a593Smuzhiyun #ifndef _ISCI_TASK_H_
56*4882a593Smuzhiyun #define _ISCI_TASK_H_
57*4882a593Smuzhiyun
58*4882a593Smuzhiyun #include <scsi/sas_ata.h>
59*4882a593Smuzhiyun #include "host.h"
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun #define ISCI_TERMINATION_TIMEOUT_MSEC 500
62*4882a593Smuzhiyun
63*4882a593Smuzhiyun struct isci_request;
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun /**
66*4882a593Smuzhiyun * enum isci_tmf_function_codes - This enum defines the possible preparations
67*4882a593Smuzhiyun * of task management requests.
68*4882a593Smuzhiyun *
69*4882a593Smuzhiyun *
70*4882a593Smuzhiyun */
71*4882a593Smuzhiyun enum isci_tmf_function_codes {
72*4882a593Smuzhiyun
73*4882a593Smuzhiyun isci_tmf_func_none = 0,
74*4882a593Smuzhiyun isci_tmf_ssp_task_abort = TMF_ABORT_TASK,
75*4882a593Smuzhiyun isci_tmf_ssp_lun_reset = TMF_LU_RESET,
76*4882a593Smuzhiyun };
77*4882a593Smuzhiyun
78*4882a593Smuzhiyun /**
79*4882a593Smuzhiyun * struct isci_tmf - This class represents the task management object which
80*4882a593Smuzhiyun * acts as an interface to libsas for processing task management requests
81*4882a593Smuzhiyun *
82*4882a593Smuzhiyun *
83*4882a593Smuzhiyun */
84*4882a593Smuzhiyun struct isci_tmf {
85*4882a593Smuzhiyun
86*4882a593Smuzhiyun struct completion *complete;
87*4882a593Smuzhiyun enum sas_protocol proto;
88*4882a593Smuzhiyun union {
89*4882a593Smuzhiyun struct ssp_response_iu resp_iu;
90*4882a593Smuzhiyun struct dev_to_host_fis d2h_fis;
91*4882a593Smuzhiyun u8 rsp_buf[SSP_RESP_IU_MAX_SIZE];
92*4882a593Smuzhiyun } resp;
93*4882a593Smuzhiyun unsigned char lun[8];
94*4882a593Smuzhiyun u16 io_tag;
95*4882a593Smuzhiyun enum isci_tmf_function_codes tmf_code;
96*4882a593Smuzhiyun int status;
97*4882a593Smuzhiyun };
98*4882a593Smuzhiyun
isci_print_tmf(struct isci_host * ihost,struct isci_tmf * tmf)99*4882a593Smuzhiyun static inline void isci_print_tmf(struct isci_host *ihost, struct isci_tmf *tmf)
100*4882a593Smuzhiyun {
101*4882a593Smuzhiyun if (SAS_PROTOCOL_SATA == tmf->proto)
102*4882a593Smuzhiyun dev_dbg(&ihost->pdev->dev,
103*4882a593Smuzhiyun "%s: status = %x\n"
104*4882a593Smuzhiyun "tmf->resp.d2h_fis.status = %x\n"
105*4882a593Smuzhiyun "tmf->resp.d2h_fis.error = %x\n",
106*4882a593Smuzhiyun __func__,
107*4882a593Smuzhiyun tmf->status,
108*4882a593Smuzhiyun tmf->resp.d2h_fis.status,
109*4882a593Smuzhiyun tmf->resp.d2h_fis.error);
110*4882a593Smuzhiyun else
111*4882a593Smuzhiyun dev_dbg(&ihost->pdev->dev,
112*4882a593Smuzhiyun "%s: status = %x\n"
113*4882a593Smuzhiyun "tmf->resp.resp_iu.data_present = %x\n"
114*4882a593Smuzhiyun "tmf->resp.resp_iu.status = %x\n"
115*4882a593Smuzhiyun "tmf->resp.resp_iu.data_length = %x\n"
116*4882a593Smuzhiyun "tmf->resp.resp_iu.data[0] = %x\n"
117*4882a593Smuzhiyun "tmf->resp.resp_iu.data[1] = %x\n"
118*4882a593Smuzhiyun "tmf->resp.resp_iu.data[2] = %x\n"
119*4882a593Smuzhiyun "tmf->resp.resp_iu.data[3] = %x\n",
120*4882a593Smuzhiyun __func__,
121*4882a593Smuzhiyun tmf->status,
122*4882a593Smuzhiyun tmf->resp.resp_iu.datapres,
123*4882a593Smuzhiyun tmf->resp.resp_iu.status,
124*4882a593Smuzhiyun be32_to_cpu(tmf->resp.resp_iu.response_data_len),
125*4882a593Smuzhiyun tmf->resp.resp_iu.resp_data[0],
126*4882a593Smuzhiyun tmf->resp.resp_iu.resp_data[1],
127*4882a593Smuzhiyun tmf->resp.resp_iu.resp_data[2],
128*4882a593Smuzhiyun tmf->resp.resp_iu.resp_data[3]);
129*4882a593Smuzhiyun }
130*4882a593Smuzhiyun
131*4882a593Smuzhiyun
132*4882a593Smuzhiyun int isci_task_execute_task(
133*4882a593Smuzhiyun struct sas_task *task,
134*4882a593Smuzhiyun gfp_t gfp_flags);
135*4882a593Smuzhiyun
136*4882a593Smuzhiyun int isci_task_abort_task(
137*4882a593Smuzhiyun struct sas_task *task);
138*4882a593Smuzhiyun
139*4882a593Smuzhiyun int isci_task_abort_task_set(
140*4882a593Smuzhiyun struct domain_device *d_device,
141*4882a593Smuzhiyun u8 *lun);
142*4882a593Smuzhiyun
143*4882a593Smuzhiyun int isci_task_clear_aca(
144*4882a593Smuzhiyun struct domain_device *d_device,
145*4882a593Smuzhiyun u8 *lun);
146*4882a593Smuzhiyun
147*4882a593Smuzhiyun int isci_task_clear_task_set(
148*4882a593Smuzhiyun struct domain_device *d_device,
149*4882a593Smuzhiyun u8 *lun);
150*4882a593Smuzhiyun
151*4882a593Smuzhiyun int isci_task_query_task(
152*4882a593Smuzhiyun struct sas_task *task);
153*4882a593Smuzhiyun
154*4882a593Smuzhiyun int isci_task_lu_reset(
155*4882a593Smuzhiyun struct domain_device *d_device,
156*4882a593Smuzhiyun u8 *lun);
157*4882a593Smuzhiyun
158*4882a593Smuzhiyun int isci_task_clear_nexus_port(
159*4882a593Smuzhiyun struct asd_sas_port *port);
160*4882a593Smuzhiyun
161*4882a593Smuzhiyun int isci_task_clear_nexus_ha(
162*4882a593Smuzhiyun struct sas_ha_struct *ha);
163*4882a593Smuzhiyun
164*4882a593Smuzhiyun int isci_task_I_T_nexus_reset(
165*4882a593Smuzhiyun struct domain_device *d_device);
166*4882a593Smuzhiyun
167*4882a593Smuzhiyun void isci_task_request_complete(
168*4882a593Smuzhiyun struct isci_host *isci_host,
169*4882a593Smuzhiyun struct isci_request *request,
170*4882a593Smuzhiyun enum sci_task_status completion_status);
171*4882a593Smuzhiyun
172*4882a593Smuzhiyun u16 isci_task_ssp_request_get_io_tag_to_manage(
173*4882a593Smuzhiyun struct isci_request *request);
174*4882a593Smuzhiyun
175*4882a593Smuzhiyun u8 isci_task_ssp_request_get_function(
176*4882a593Smuzhiyun struct isci_request *request);
177*4882a593Smuzhiyun
178*4882a593Smuzhiyun
179*4882a593Smuzhiyun void *isci_task_ssp_request_get_response_data_address(
180*4882a593Smuzhiyun struct isci_request *request);
181*4882a593Smuzhiyun
182*4882a593Smuzhiyun u32 isci_task_ssp_request_get_response_data_length(
183*4882a593Smuzhiyun struct isci_request *request);
184*4882a593Smuzhiyun
185*4882a593Smuzhiyun int isci_queuecommand(
186*4882a593Smuzhiyun struct scsi_cmnd *scsi_cmd,
187*4882a593Smuzhiyun void (*donefunc)(struct scsi_cmnd *));
188*4882a593Smuzhiyun
189*4882a593Smuzhiyun #endif /* !defined(_SCI_TASK_H_) */
190