Back to home page

OSCL-LXR

 
 

    


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 #ifndef _ISCI_TASK_H_
0056 #define _ISCI_TASK_H_
0057 
0058 #include <scsi/sas_ata.h>
0059 #include "host.h"
0060 
0061 #define ISCI_TERMINATION_TIMEOUT_MSEC 500
0062 
0063 struct isci_request;
0064 
0065 /**
0066  * enum isci_tmf_function_codes - This enum defines the possible preparations
0067  *    of task management requests.
0068  *
0069  *
0070  */
0071 enum isci_tmf_function_codes {
0072 
0073     isci_tmf_func_none      = 0,
0074     isci_tmf_ssp_task_abort = TMF_ABORT_TASK,
0075     isci_tmf_ssp_lun_reset  = TMF_LU_RESET,
0076 };
0077 
0078 /**
0079  * struct isci_tmf - This class represents the task management object which
0080  *    acts as an interface to libsas for processing task management requests
0081  *
0082  *
0083  */
0084 struct isci_tmf {
0085 
0086     struct completion *complete;
0087     enum sas_protocol proto;
0088     union {
0089         struct ssp_response_iu resp_iu;
0090         struct dev_to_host_fis d2h_fis;
0091         u8 rsp_buf[SSP_RESP_IU_MAX_SIZE];
0092     } resp;
0093     unsigned char lun[8];
0094     u16 io_tag;
0095     enum isci_tmf_function_codes tmf_code;
0096     int status;
0097 };
0098 
0099 static inline void isci_print_tmf(struct isci_host *ihost, struct isci_tmf *tmf)
0100 {
0101     if (SAS_PROTOCOL_SATA == tmf->proto)
0102         dev_dbg(&ihost->pdev->dev,
0103             "%s: status = %x\n"
0104             "tmf->resp.d2h_fis.status = %x\n"
0105             "tmf->resp.d2h_fis.error = %x\n",
0106             __func__,
0107             tmf->status,
0108             tmf->resp.d2h_fis.status,
0109             tmf->resp.d2h_fis.error);
0110     else
0111         dev_dbg(&ihost->pdev->dev,
0112             "%s: status = %x\n"
0113             "tmf->resp.resp_iu.data_present = %x\n"
0114             "tmf->resp.resp_iu.status = %x\n"
0115             "tmf->resp.resp_iu.data_length = %x\n"
0116             "tmf->resp.resp_iu.data[0] = %x\n"
0117             "tmf->resp.resp_iu.data[1] = %x\n"
0118             "tmf->resp.resp_iu.data[2] = %x\n"
0119             "tmf->resp.resp_iu.data[3] = %x\n",
0120             __func__,
0121             tmf->status,
0122             tmf->resp.resp_iu.datapres,
0123             tmf->resp.resp_iu.status,
0124             be32_to_cpu(tmf->resp.resp_iu.response_data_len),
0125             tmf->resp.resp_iu.resp_data[0],
0126             tmf->resp.resp_iu.resp_data[1],
0127             tmf->resp.resp_iu.resp_data[2],
0128             tmf->resp.resp_iu.resp_data[3]);
0129 }
0130 
0131 
0132 int isci_task_execute_task(
0133     struct sas_task *task,
0134     gfp_t gfp_flags);
0135 
0136 int isci_task_abort_task(
0137     struct sas_task *task);
0138 
0139 int isci_task_abort_task_set(
0140     struct domain_device *d_device,
0141     u8 *lun);
0142 
0143 int isci_task_clear_task_set(
0144     struct domain_device *d_device,
0145     u8 *lun);
0146 
0147 int isci_task_query_task(
0148     struct sas_task *task);
0149 
0150 int isci_task_lu_reset(
0151     struct domain_device *d_device,
0152     u8 *lun);
0153 
0154 int isci_task_clear_nexus_port(
0155     struct asd_sas_port *port);
0156 
0157 int isci_task_clear_nexus_ha(
0158     struct sas_ha_struct *ha);
0159 
0160 int isci_task_I_T_nexus_reset(
0161     struct domain_device *d_device);
0162 
0163 void isci_task_request_complete(
0164     struct isci_host *isci_host,
0165     struct isci_request *request,
0166     enum sci_task_status completion_status);
0167 
0168 u16 isci_task_ssp_request_get_io_tag_to_manage(
0169     struct isci_request *request);
0170 
0171 u8 isci_task_ssp_request_get_function(
0172     struct isci_request *request);
0173 
0174 
0175 void *isci_task_ssp_request_get_response_data_address(
0176     struct isci_request *request);
0177 
0178 u32 isci_task_ssp_request_get_response_data_length(
0179     struct isci_request *request);
0180 
0181 #endif /* !defined(_SCI_TASK_H_) */