* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
-#include "intel_sas.h"
-#include "intel_sata.h"
-#include "intel_sat.h"
+#include <scsi/sas.h>
#include "scic_controller.h"
#include "scic_io_request.h"
-#include "scic_remote_device.h"
#include "scic_sds_controller.h"
#include "scu_registers.h"
#include "scic_sds_port.h"
-#include "scic_sds_remote_device.h"
+#include "remote_device.h"
#include "scic_sds_request.h"
#include "scic_sds_smp_request.h"
#include "scic_sds_stp_request.h"
#include "scu_constants.h"
#include "scu_task_context.h"
-#if !defined(DISABLE_ATAPI)
-#include "scic_sds_stp_packet_request.h"
-#endif
-
/*
* ****************************************************************************
* * SCIC SDS IO REQUEST CONSTANTS
#define SCIC_SDS_IO_REQUEST_MINIMUM_TIMER_COUNT (0)
#define SCIC_SDS_IO_REQUEST_MAXIMUM_TIMER_COUNT (0)
-/*
- * ****************************************************************************
- * * SCIC SDS IO REQUEST MACROS
- * **************************************************************************** */
-
-/**
- * scic_ssp_io_request_get_object_size() -
- *
- * This macro returns the sizeof memory required to store the an SSP IO
- * request. This does not include the size of the SGL or SCU Task Context
- * memory.
- */
-#define scic_ssp_io_request_get_object_size() \
- (\
- sizeof(struct sci_ssp_command_iu) \
- + sizeof(struct sci_ssp_response_iu) \
- )
-
-/**
- * scic_sds_ssp_request_get_command_buffer() -
- *
- * This macro returns the address of the ssp command buffer in the io request
- * memory
- */
-#define scic_sds_ssp_request_get_command_buffer(memory) \
- ((struct sci_ssp_command_iu *)(\
- ((char *)(memory)) + sizeof(struct scic_sds_request) \
- ))
-
-/**
- * scic_sds_ssp_request_get_response_buffer() -
- *
- * This macro returns the address of the ssp response buffer in the io request
- * memory
- */
-#define scic_sds_ssp_request_get_response_buffer(memory) \
- ((struct sci_ssp_response_iu *)(\
- ((char *)(scic_sds_ssp_request_get_command_buffer(memory))) \
- + sizeof(struct sci_ssp_command_iu) \
- ))
-
-/**
- * scic_sds_ssp_request_get_task_context_buffer() -
- *
- * This macro returns the address of the task context buffer in the io request
- * memory
- */
-#define scic_sds_ssp_request_get_task_context_buffer(memory) \
- ((struct scu_task_context *)(\
- ((char *)(scic_sds_ssp_request_get_response_buffer(memory))) \
- + sizeof(struct sci_ssp_response_iu) \
- ))
-
-/**
- * scic_sds_ssp_request_get_sgl_element_buffer() -
- *
- * This macro returns the address of the sgl elment pairs in the io request
- * memory buffer
- */
-#define scic_sds_ssp_request_get_sgl_element_buffer(memory) \
- ((struct scu_sgl_element_pair *)(\
- ((char *)(scic_sds_ssp_request_get_task_context_buffer(memory))) \
- + sizeof(struct scu_task_context) \
- ))
-
-
-/**
- * scic_ssp_task_request_get_object_size() -
- *
- * This macro returns the sizeof of memory required to store an SSP Task
- * request. This does not include the size of the SCU Task Context memory.
- */
-#define scic_ssp_task_request_get_object_size() \
- (\
- sizeof(struct sci_ssp_task_iu) \
- + sizeof(struct sci_ssp_response_iu) \
- )
-
-/**
- * scic_sds_ssp_task_request_get_command_buffer() -
- *
- * This macro returns the address of the ssp command buffer in the task request
- * memory. Yes its the same as the above macro except for the name.
- */
-#define scic_sds_ssp_task_request_get_command_buffer(memory) \
- ((struct sci_ssp_task_iu *)(\
- ((char *)(memory)) + sizeof(struct scic_sds_request) \
- ))
-
-/**
- * scic_sds_ssp_task_request_get_response_buffer() -
- *
- * This macro returns the address of the ssp response buffer in the task
- * request memory.
- */
-#define scic_sds_ssp_task_request_get_response_buffer(memory) \
- ((struct sci_ssp_response_iu *)(\
- ((char *)(scic_sds_ssp_task_request_get_command_buffer(memory))) \
- + sizeof(struct sci_ssp_task_iu) \
- ))
-
-/**
- * scic_sds_ssp_task_request_get_task_context_buffer() -
- *
- * This macro returs the task context buffer for the SSP task request.
- */
-#define scic_sds_ssp_task_request_get_task_context_buffer(memory) \
- ((struct scu_task_context *)(\
- ((char *)(scic_sds_ssp_task_request_get_response_buffer(memory))) \
- + sizeof(struct sci_ssp_response_iu) \
- ))
-
-
-
-/*
- * ****************************************************************************
- * * SCIC SDS IO REQUEST PRIVATE METHODS
- * **************************************************************************** */
-
-/**
- *
- *
- * This method returns the size required to store an SSP IO request object. u32
- */
-static u32 scic_sds_ssp_request_get_object_size(void)
-{
- return sizeof(struct scic_sds_request)
- + scic_ssp_io_request_get_object_size()
- + sizeof(struct scu_task_context)
- + SMP_CACHE_BYTES
- + sizeof(struct scu_sgl_element_pair) * SCU_MAX_SGL_ELEMENT_PAIRS;
-}
-
/**
* This method returns the sgl element pair for the specificed sgl_pair index.
- * @this_request: This parameter specifies the IO request for which to retrieve
+ * @sci_req: This parameter specifies the IO request for which to retrieve
* the Scatter-Gather List element pair.
* @sgl_pair_index: This parameter specifies the index into the SGL element
* pair to be retrieved.
* This method returns a pointer to an struct scu_sgl_element_pair.
*/
static struct scu_sgl_element_pair *scic_sds_request_get_sgl_element_pair(
- struct scic_sds_request *this_request,
+ struct scic_sds_request *sci_req,
u32 sgl_pair_index
) {
struct scu_task_context *task_context;
- task_context = (struct scu_task_context *)this_request->task_context_buffer;
+ task_context = (struct scu_task_context *)sci_req->task_context_buffer;
if (sgl_pair_index == 0) {
return &task_context->sgl_pair_ab;
return &task_context->sgl_pair_cd;
}
- return &this_request->sgl_element_pair_buffer[sgl_pair_index - 2];
+ return &sci_req->sg_table[sgl_pair_index - 2];
}
/**
* This function will build the SGL list for an IO request.
- * @this_request: This parameter specifies the IO request for which to build
+ * @sci_req: This parameter specifies the IO request for which to build
* the Scatter-Gather List.
*
*/
void scic_sds_request_build_sgl(struct scic_sds_request *sds_request)
{
- struct isci_request *isci_request =
- (struct isci_request *)sci_object_get_association(sds_request);
+ struct isci_request *isci_request = sci_req_to_ireq(sds_request);
struct isci_host *isci_host = isci_request->isci_host;
struct sas_task *task = isci_request_access_task(isci_request);
struct scatterlist *sg = NULL;
}
}
-/**
- * This method build the remainder of the IO request object.
- * @this_request: This parameter specifies the request object being constructed.
- *
- * The scic_sds_general_request_construct() must be called before this call is
- * valid. none
- */
-static void scic_sds_ssp_io_request_assign_buffers(
- struct scic_sds_request *this_request)
+static void scic_sds_ssp_io_request_assign_buffers(struct scic_sds_request *sci_req)
{
- this_request->command_buffer =
- scic_sds_ssp_request_get_command_buffer(this_request);
- this_request->response_buffer =
- scic_sds_ssp_request_get_response_buffer(this_request);
- this_request->sgl_element_pair_buffer =
- scic_sds_ssp_request_get_sgl_element_buffer(this_request);
- this_request->sgl_element_pair_buffer =
- PTR_ALIGN(this_request->sgl_element_pair_buffer,
- sizeof(struct scu_sgl_element_pair));
-
- if (this_request->was_tag_assigned_by_user == false) {
- this_request->task_context_buffer =
- scic_sds_ssp_request_get_task_context_buffer(this_request);
- this_request->task_context_buffer =
- PTR_ALIGN(this_request->task_context_buffer,
- SMP_CACHE_BYTES);
- }
+ if (sci_req->was_tag_assigned_by_user == false)
+ sci_req->task_context_buffer = &sci_req->tc;
}
-/**
- * This method constructs the SSP Command IU data for this io request object.
- * @this_request: This parameter specifies the request object for which the SSP
- * command information unit is being built.
- *
- */
-static void scic_sds_io_request_build_ssp_command_iu(
- struct scic_sds_request *sds_request)
+static void scic_sds_io_request_build_ssp_command_iu(struct scic_sds_request *sci_req)
{
- struct sci_ssp_command_iu *command_frame;
- u32 cdb_length;
- u32 *cdb_buffer;
- struct isci_request *isci_request =
- (struct isci_request *)sci_object_get_association(sds_request);
-
- command_frame =
- (struct sci_ssp_command_iu *)sds_request->command_buffer;
-
- command_frame->lun_upper = 0;
- command_frame->lun_lower =
- isci_request_ssp_io_request_get_lun(isci_request);
-
- ((u32 *)command_frame)[2] = 0;
-
- cdb_length = isci_request_ssp_io_request_get_cdb_length(isci_request);
- cdb_buffer = (u32 *)isci_request_ssp_io_request_get_cdb_address(
- isci_request);
-
- if (cdb_length > 16) {
- command_frame->additional_cdb_length = cdb_length - 16;
- }
-
- /* / @todo Is it ok to leave junk at the end of the cdb buffer? */
- scic_word_copy_with_swap(
- (u32 *)(&command_frame->cdb),
- (u32 *)(cdb_buffer),
- (cdb_length + 3) / sizeof(u32)
- );
-
- command_frame->enable_first_burst = 0;
- command_frame->task_priority =
- isci_request_ssp_io_request_get_command_priority(isci_request);
- command_frame->task_attribute =
- isci_request_ssp_io_request_get_task_attribute(isci_request);
+ struct ssp_cmd_iu *cmd_iu;
+ struct isci_request *ireq = sci_req_to_ireq(sci_req);
+ struct sas_task *task = isci_request_access_task(ireq);
+
+ cmd_iu = &sci_req->ssp.cmd;
+
+ memcpy(cmd_iu->LUN, task->ssp_task.LUN, 8);
+ cmd_iu->add_cdb_len = 0;
+ cmd_iu->_r_a = 0;
+ cmd_iu->_r_b = 0;
+ cmd_iu->en_fburst = 0; /* unsupported */
+ cmd_iu->task_prio = task->ssp_task.task_prio;
+ cmd_iu->task_attr = task->ssp_task.task_attr;
+ cmd_iu->_r_c = 0;
+
+ sci_swab32_cpy(&cmd_iu->cdb, task->ssp_task.cdb,
+ sizeof(task->ssp_task.cdb) / sizeof(u32));
}
-
-/**
- * This method constructs the SSP Task IU data for this io request object.
- * @this_request:
- *
- */
-static void scic_sds_task_request_build_ssp_task_iu(
- struct scic_sds_request *sds_request)
+static void scic_sds_task_request_build_ssp_task_iu(struct scic_sds_request *sci_req)
{
- struct sci_ssp_task_iu *command_frame;
- struct isci_request *isci_request =
- (struct isci_request *)sci_object_get_association(sds_request);
+ struct ssp_task_iu *task_iu;
+ struct isci_request *ireq = sci_req_to_ireq(sci_req);
+ struct sas_task *task = isci_request_access_task(ireq);
+ struct isci_tmf *isci_tmf = isci_request_access_tmf(ireq);
- command_frame =
- (struct sci_ssp_task_iu *)sds_request->command_buffer;
+ task_iu = &sci_req->ssp.tmf;
- command_frame->lun_upper = 0;
- command_frame->lun_lower = isci_request_ssp_io_request_get_lun(
- isci_request);
+ memset(task_iu, 0, sizeof(struct ssp_task_iu));
- ((u32 *)command_frame)[2] = 0;
+ memcpy(task_iu->LUN, task->ssp_task.LUN, 8);
- command_frame->task_function =
- isci_task_ssp_request_get_function(isci_request);
- command_frame->task_tag =
- isci_task_ssp_request_get_io_tag_to_manage(
- isci_request);
+ task_iu->task_func = isci_tmf->tmf_code;
+ task_iu->task_tag =
+ (ireq->ttype == tmf_task) ?
+ isci_tmf->io_tag :
+ SCI_CONTROLLER_INVALID_IO_TAG;
}
-
/**
* This method is will fill in the SCU Task Context for any type of SSP request.
- * @this_request:
+ * @sci_req:
* @task_context:
*
*/
task_context->abort = 0;
task_context->priority = 0;
task_context->initiator_request = 1;
- task_context->connection_rate =
- scic_remote_device_get_connection_rate(target_device);
+ task_context->connection_rate = target_device->connection_rate;
task_context->protocol_engine_index =
scic_sds_controller_get_protocol_engine_group(controller);
task_context->logical_port_index =
task_context->address_modifier = 0;
- /* task_context->type.ssp.tag = this_request->io_tag; */
+ /* task_context->type.ssp.tag = sci_req->io_tag; */
task_context->task_phase = 0x01;
if (sds_request->was_tag_assigned_by_user) {
* SCU Task Context
*/
dma_addr = scic_io_request_get_dma_addr(sds_request,
- sds_request->command_buffer);
+ &sds_request->ssp.cmd);
task_context->command_iu_upper = upper_32_bits(dma_addr);
task_context->command_iu_lower = lower_32_bits(dma_addr);
* SCU Task Context
*/
dma_addr = scic_io_request_get_dma_addr(sds_request,
- sds_request->response_buffer);
+ &sds_request->ssp.rsp);
task_context->response_iu_upper = upper_32_bits(dma_addr);
task_context->response_iu_lower = lower_32_bits(dma_addr);
/**
* This method is will fill in the SCU Task Context for a SSP IO request.
- * @this_request:
+ * @sci_req:
*
*/
static void scu_ssp_io_request_construct_task_context(
scu_ssp_reqeust_construct_task_context(sci_req, task_context);
- task_context->ssp_command_iu_length = sizeof(struct sci_ssp_command_iu) / sizeof(u32);
- task_context->type.ssp.frame_type = SCI_SAS_COMMAND_FRAME;
+ task_context->ssp_command_iu_length =
+ sizeof(struct ssp_cmd_iu) / sizeof(u32);
+ task_context->type.ssp.frame_type = SSP_COMMAND;
switch (dir) {
case DMA_FROM_DEVICE:
scic_sds_request_build_sgl(sci_req);
}
-
-/**
- * This method will fill in the remainder of the io request object for SSP Task
- * requests.
- * @this_request:
- *
- */
-static void scic_sds_ssp_task_request_assign_buffers(
- struct scic_sds_request *this_request)
+static void scic_sds_ssp_task_request_assign_buffers(struct scic_sds_request *sci_req)
{
- /* Assign all of the buffer pointers */
- this_request->command_buffer =
- scic_sds_ssp_task_request_get_command_buffer(this_request);
- this_request->response_buffer =
- scic_sds_ssp_task_request_get_response_buffer(this_request);
- this_request->sgl_element_pair_buffer = NULL;
-
- if (this_request->was_tag_assigned_by_user == false) {
- this_request->task_context_buffer =
- scic_sds_ssp_task_request_get_task_context_buffer(this_request);
- this_request->task_context_buffer =
- PTR_ALIGN(this_request->task_context_buffer, SMP_CACHE_BYTES);
- }
+ if (sci_req->was_tag_assigned_by_user == false)
+ sci_req->task_context_buffer = &sci_req->tc;
}
/**
* (i.e. non-raw frame) is being utilized to perform task management. -#
* control_frame == 1. This ensures that the proper endianess is set so
* that the bytes are transmitted in the right order for a task frame.
- * @this_request: This parameter specifies the task request object being
+ * @sci_req: This parameter specifies the task request object being
* constructed.
*
*/
static void scu_ssp_task_request_construct_task_context(
- struct scic_sds_request *this_request)
+ struct scic_sds_request *sci_req)
{
struct scu_task_context *task_context;
- task_context = scic_sds_request_get_task_context(this_request);
+ task_context = scic_sds_request_get_task_context(sci_req);
- scu_ssp_reqeust_construct_task_context(this_request, task_context);
+ scu_ssp_reqeust_construct_task_context(sci_req, task_context);
task_context->control_frame = 1;
task_context->priority = SCU_TASK_PRIORITY_HIGH;
task_context->task_type = SCU_TASK_TYPE_RAW_FRAME;
task_context->transfer_length_bytes = 0;
- task_context->type.ssp.frame_type = SCI_SAS_TASK_FRAME;
- task_context->ssp_command_iu_length = sizeof(struct sci_ssp_task_iu) / sizeof(u32);
+ task_context->type.ssp.frame_type = SSP_TASK;
+ task_context->ssp_command_iu_length =
+ sizeof(struct ssp_task_iu) / sizeof(u32);
}
/**
* This method constructs the SSP Command IU data for this ssp passthrough
* comand request object.
- * @this_request: This parameter specifies the request object for which the SSP
+ * @sci_req: This parameter specifies the request object for which the SSP
* command information unit is being built.
*
* enum sci_status, returns invalid parameter is cdb > 16
/**
* This method constructs the SATA request object.
- * @this_request:
+ * @sci_req:
* @sat_protocol:
* @transfer_length:
* @data_direction:
*
* enum sci_status
*/
-static enum sci_status scic_io_request_construct_sata(struct scic_sds_request *sci_req,
- u8 proto, u32 len,
- enum dma_data_direction dir,
- bool copy)
+static enum sci_status
+scic_io_request_construct_sata(struct scic_sds_request *sci_req,
+ u32 len,
+ enum dma_data_direction dir,
+ bool copy)
{
enum sci_status status = SCI_SUCCESS;
+ struct isci_request *ireq = sci_req_to_ireq(sci_req);
+ struct sas_task *task = isci_request_access_task(ireq);
+
+ /* check for management protocols */
+ if (ireq->ttype == tmf_task) {
+ struct isci_tmf *tmf = isci_request_access_tmf(ireq);
+
+ if (tmf->tmf_code == isci_tmf_sata_srst_high ||
+ tmf->tmf_code == isci_tmf_sata_srst_low)
+ return scic_sds_stp_soft_reset_request_construct(sci_req);
+ else {
+ dev_err(scic_to_dev(sci_req->owning_controller),
+ "%s: Request 0x%p received un-handled SAT "
+ "management protocol 0x%x.\n",
+ __func__, sci_req, tmf->tmf_code);
+
+ return SCI_FAILURE;
+ }
+ }
- switch (proto) {
- case SAT_PROTOCOL_PIO_DATA_IN:
- case SAT_PROTOCOL_PIO_DATA_OUT:
- status = scic_sds_stp_pio_request_construct(sci_req, proto, copy);
- break;
-
- case SAT_PROTOCOL_UDMA_DATA_IN:
- case SAT_PROTOCOL_UDMA_DATA_OUT:
- status = scic_sds_stp_udma_request_construct(sci_req, len, dir);
- break;
-
- case SAT_PROTOCOL_ATA_HARD_RESET:
- case SAT_PROTOCOL_SOFT_RESET:
- status = scic_sds_stp_soft_reset_request_construct(sci_req);
- break;
-
- case SAT_PROTOCOL_NON_DATA:
- status = scic_sds_stp_non_data_request_construct(sci_req);
- break;
-
- case SAT_PROTOCOL_FPDMA:
- status = scic_sds_stp_ncq_request_construct(sci_req, len, dir);
- break;
-
-#if !defined(DISABLE_ATAPI)
- case SAT_PROTOCOL_PACKET_NON_DATA:
- case SAT_PROTOCOL_PACKET_DMA_DATA_IN:
- case SAT_PROTOCOL_PACKET_DMA_DATA_OUT:
- case SAT_PROTOCOL_PACKET_PIO_DATA_IN:
- case SAT_PROTOCOL_PACKET_PIO_DATA_OUT:
- status = scic_sds_stp_packet_request_construct(sci_req);
- break;
-#endif
-
- case SAT_PROTOCOL_DMA_QUEUED:
- case SAT_PROTOCOL_DMA:
- case SAT_PROTOCOL_DEVICE_DIAGNOSTIC:
- case SAT_PROTOCOL_DEVICE_RESET:
- case SAT_PROTOCOL_RETURN_RESPONSE_INFO:
- default:
+ if (!sas_protocol_ata(task->task_proto)) {
dev_err(scic_to_dev(sci_req->owning_controller),
- "%s: SCIC IO Request 0x%p received un-handled "
- "SAT Protocl %d.\n",
- __func__, sci_req, proto);
+ "%s: Non-ATA protocol in SATA path: 0x%x\n",
+ __func__,
+ task->task_proto);
+ return SCI_FAILURE;
- status = SCI_FAILURE;
- break;
}
- return status;
-}
+ /* non data */
+ if (task->data_dir == DMA_NONE)
+ return scic_sds_stp_non_data_request_construct(sci_req);
-u32 scic_io_request_get_object_size(void)
-{
- u32 ssp_request_size;
- u32 stp_request_size;
- u32 smp_request_size;
+ /* NCQ */
+ if (task->ata_task.use_ncq)
+ return scic_sds_stp_ncq_request_construct(sci_req, len, dir);
- ssp_request_size = scic_sds_ssp_request_get_object_size();
- stp_request_size = scic_sds_stp_request_get_object_size();
- smp_request_size = scic_sds_smp_request_get_object_size();
+ /* DMA */
+ if (task->ata_task.dma_xfer)
+ return scic_sds_stp_udma_request_construct(sci_req, len, dir);
+ else /* PIO */
+ return scic_sds_stp_pio_request_construct(sci_req, copy);
- return max(ssp_request_size, max(stp_request_size, smp_request_size));
+ return status;
}
enum sci_status scic_io_request_construct_basic_ssp(
struct scic_sds_request *sci_req)
{
- struct isci_request *isci_request =
- (struct isci_request *)sci_object_get_association(sci_req);
+ struct isci_request *ireq = sci_req_to_ireq(sci_req);
+ struct sas_task *task = isci_request_access_task(ireq);
sci_req->protocol = SCIC_SSP_PROTOCOL;
- scu_ssp_io_request_construct_task_context(
- sci_req,
- isci_request_io_request_get_data_direction(isci_request),
- isci_request_io_request_get_transfer_length(isci_request));
+ scu_ssp_io_request_construct_task_context(sci_req,
+ task->data_dir,
+ task->total_xfer_len);
scic_sds_io_request_build_ssp_command_iu(sci_req);
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_CONSTRUCTED);
+ sci_base_state_machine_change_state(
+ &sci_req->state_machine,
+ SCI_BASE_REQUEST_STATE_CONSTRUCTED);
return SCI_SUCCESS;
}
{
enum sci_status status;
struct scic_sds_stp_request *stp_req;
- u8 proto;
- u32 len;
- enum dma_data_direction dir;
bool copy = false;
- struct isci_request *isci_request =
- (struct isci_request *)sci_object_get_association(sci_req);
+ struct isci_request *isci_request = sci_req_to_ireq(sci_req);
struct sas_task *task = isci_request_access_task(isci_request);
- stp_req = container_of(sci_req, typeof(*stp_req), parent);
-
+ stp_req = &sci_req->stp.req;
sci_req->protocol = SCIC_STP_PROTOCOL;
- len = isci_request_io_request_get_transfer_length(isci_request);
- dir = isci_request_io_request_get_data_direction(isci_request);
- proto = isci_sata_get_sat_protocol(isci_request);
copy = (task->data_dir == DMA_NONE) ? false : true;
- status = scic_io_request_construct_sata(sci_req, proto, len, dir, copy);
+ status = scic_io_request_construct_sata(sci_req,
+ task->total_xfer_len,
+ task->data_dir,
+ copy);
if (status == SCI_SUCCESS)
sci_base_state_machine_change_state(&sci_req->state_machine,
}
-enum sci_status scic_task_request_construct_sata(
- struct scic_sds_request *sci_req)
+enum sci_status scic_task_request_construct_sata(struct scic_sds_request *sci_req)
{
- enum sci_status status;
- u8 sat_protocol;
- struct isci_request *isci_request =
- (struct isci_request *)sci_object_get_association(sci_req);
+ enum sci_status status = SCI_SUCCESS;
+ struct isci_request *ireq = sci_req_to_ireq(sci_req);
- sat_protocol = isci_sata_get_sat_protocol(isci_request);
+ /* check for management protocols */
+ if (ireq->ttype == tmf_task) {
+ struct isci_tmf *tmf = isci_request_access_tmf(ireq);
- switch (sat_protocol) {
- case SAT_PROTOCOL_ATA_HARD_RESET:
- case SAT_PROTOCOL_SOFT_RESET:
- status = scic_sds_stp_soft_reset_request_construct(sci_req);
- break;
-
- default:
- dev_err(scic_to_dev(sci_req->owning_controller),
- "%s: SCIC IO Request 0x%p received un-handled SAT "
- "Protocl %d.\n",
- __func__,
- sci_req,
- sat_protocol);
+ if (tmf->tmf_code == isci_tmf_sata_srst_high ||
+ tmf->tmf_code == isci_tmf_sata_srst_low) {
+ status = scic_sds_stp_soft_reset_request_construct(sci_req);
+ } else {
+ dev_err(scic_to_dev(sci_req->owning_controller),
+ "%s: Request 0x%p received un-handled SAT "
+ "Protocol 0x%x.\n",
+ __func__, sci_req, tmf->tmf_code);
- status = SCI_FAILURE;
- break;
+ return SCI_FAILURE;
+ }
}
if (status == SCI_SUCCESS)
- sci_base_state_machine_change_state(&sci_req->state_machine,
- SCI_BASE_REQUEST_STATE_CONSTRUCTED);
+ sci_base_state_machine_change_state(
+ &sci_req->state_machine,
+ SCI_BASE_REQUEST_STATE_CONSTRUCTED);
return status;
}
return sci_req->scu_status;
}
-
-void *scic_io_request_get_command_iu_address(
- struct scic_sds_request *sci_req)
-{
- return sci_req->command_buffer;
-}
-
-
-void *scic_io_request_get_response_iu_address(
- struct scic_sds_request *sci_req)
-{
- return sci_req->response_buffer;
-}
-
-
#define SCU_TASK_CONTEXT_SRAM 0x200000
u32 scic_io_request_get_number_of_bytes_transferred(
struct scic_sds_request *scic_sds_request)
{
+ struct scic_sds_controller *scic = scic_sds_request->owning_controller;
u32 ret_val = 0;
- if (readl(&scic_sds_request->owning_controller->smu_registers->address_modifier) == 0) {
+ if (readl(&scic->smu_registers->address_modifier) == 0) {
+ void __iomem *scu_reg_base = scic->scu_registers;
/*
* get the bytes of data from the Address == BAR1 + 20002Ch + (256*TCi) where
* BAR1 is the scu_registers
* 0x20002C = 0x200000 + 0x2c
* = start of task context SRAM + offset of (type.ssp.data_offset)
* TCi is the io_tag of struct scic_sds_request */
- ret_val = readl((u8 *)scic_sds_request->owning_controller->scu_registers +
- (SCU_TASK_CONTEXT_SRAM + SCI_FIELD_OFFSET(struct scu_task_context, type.ssp.data_offset)) +
- ((sizeof(struct scu_task_context)) * scic_sds_io_tag_get_index(scic_sds_request->io_tag))
- );
+ ret_val = readl(scu_reg_base +
+ (SCU_TASK_CONTEXT_SRAM + offsetof(struct scu_task_context, type.ssp.data_offset)) +
+ ((sizeof(struct scu_task_context)) * scic_sds_io_tag_get_index(scic_sds_request->io_tag)));
}
return ret_val;
* * SCIC SDS Interface Implementation
* **************************************************************************** */
-/**
- *
- * @this_request: The SCIC_SDS_IO_REQUEST_T object for which the start
- * operation is to be executed.
- *
- * This method invokes the base state start request handler for the
- * SCIC_SDS_IO_REQUEST_T object. enum sci_status
- */
enum sci_status
scic_sds_request_start(struct scic_sds_request *request)
{
- if (request->device_sequence ==
+ if (request->device_sequence !=
scic_sds_remote_device_get_sequence(request->target_device))
- return request->state_handlers->start_handler(request);
- return SCI_FAILURE;
-}
-
-/**
- *
- * @this_request: The SCIC_SDS_IO_REQUEST_T object for which the start
- * operation is to be executed.
- *
- * This method invokes the base state terminate request handber for the
- * SCIC_SDS_IO_REQUEST_T object. enum sci_status
- */
-enum sci_status
-scic_sds_io_request_terminate(struct scic_sds_request *request)
-{
- return request->state_handlers->abort_handler(request);
-}
-
-/**
- *
- * @this_request: The SCIC_SDS_IO_REQUEST_T object for which the start
- * operation is to be executed.
- *
- * This method invokes the base state request completion handler for the
- * SCIC_SDS_IO_REQUEST_T object. enum sci_status
- */
-enum sci_status
-scic_sds_io_request_complete(struct scic_sds_request *request)
-{
- return request->state_handlers->complete_handler(request);
-}
-
-/**
- *
- * @this_request: The SCIC_SDS_IO_REQUEST_T object for which the start
- * operation is to be executed.
- * @event_code: The event code returned by the hardware for the task reqeust.
- *
- * This method invokes the core state handler for the SCIC_SDS_IO_REQUEST_T
- * object. enum sci_status
- */
-enum sci_status scic_sds_io_request_event_handler(
- struct scic_sds_request *this_request,
- u32 event_code)
-{
- return this_request->state_handlers->event_handler(this_request, event_code);
-}
-
-/**
- *
- * @this_request: The SCIC_SDS_IO_REQUEST_T object for which the start
- * operation is to be executed.
- * @frame_index: The frame index returned by the hardware for the reqeust
- * object.
- *
- * This method invokes the core state frame handler for the
- * SCIC_SDS_IO_REQUEST_T object. enum sci_status
- */
-enum sci_status scic_sds_io_request_frame_handler(
- struct scic_sds_request *this_request,
- u32 frame_index)
-{
- return this_request->state_handlers->frame_handler(this_request, frame_index);
-}
-
-/**
- *
- * @this_request: The SCIC_SDS_IO_REQUEST_T object for which the task start
- * operation is to be executed.
- *
- * This method invokes the core state task complete handler for the
- * SCIC_SDS_IO_REQUEST_T object. enum sci_status
- */
-
-/*
- * ****************************************************************************
- * * SCIC SDS PROTECTED METHODS
- * **************************************************************************** */
-
-/**
- * This method copies response data for requests returning response data
- * instead of sense data.
- * @this_request: This parameter specifies the request object for which to copy
- * the response data.
- *
- */
-void scic_sds_io_request_copy_response(struct scic_sds_request *sds_request)
-{
- void *response_buffer;
- u32 user_response_length;
- u32 core_response_length;
- struct sci_ssp_response_iu *ssp_response;
- struct isci_request *isci_request =
- (struct isci_request *)sci_object_get_association(sds_request);
-
- ssp_response =
- (struct sci_ssp_response_iu *)sds_request->response_buffer;
+ return SCI_FAILURE;
- response_buffer =
- isci_task_ssp_request_get_response_data_address(
- isci_request);
-
- user_response_length =
- isci_task_ssp_request_get_response_data_length(
- isci_request);
-
- core_response_length = sci_ssp_get_response_data_length(
- ssp_response->response_data_length);
-
- user_response_length = min(user_response_length, core_response_length);
-
- memcpy(response_buffer, ssp_response->data, user_response_length);
-}
-
-/*
- * *****************************************************************************
- * * DEFAULT STATE HANDLERS
- * ***************************************************************************** */
+ if (request->state_handlers->start_handler)
+ return request->state_handlers->start_handler(request);
-/*
- * This method is the default action to take when an SCIC_SDS_IO_REQUEST_T
- * object receives a scic_sds_request_start() request. The default action is
- * to log a warning and return a failure status. enum sci_status
- * SCI_FAILURE_INVALID_STATE
- */
-enum sci_status scic_sds_request_default_start_handler(
- struct scic_sds_request *request)
-{
dev_warn(scic_to_dev(request->owning_controller),
"%s: SCIC IO Request requested to start while in wrong "
"state %d\n",
return SCI_FAILURE_INVALID_STATE;
}
-static enum sci_status scic_sds_request_default_abort_handler(
- struct scic_sds_request *request)
+enum sci_status
+scic_sds_io_request_terminate(struct scic_sds_request *request)
{
+ if (request->state_handlers->abort_handler)
+ return request->state_handlers->abort_handler(request);
+
dev_warn(scic_to_dev(request->owning_controller),
"%s: SCIC IO Request requested to abort while in wrong "
"state %d\n",
return SCI_FAILURE_INVALID_STATE;
}
-/*
- * This method is the default action to take when an SCIC_SDS_IO_REQUEST_T
- * object receives a scic_sds_request_complete() request. The default action
- * is to log a warning and return a failure status. enum sci_status
- * SCI_FAILURE_INVALID_STATE
- */
-enum sci_status scic_sds_request_default_complete_handler(
- struct scic_sds_request *request)
+enum sci_status
+scic_sds_io_request_complete(struct scic_sds_request *request)
{
+ if (request->state_handlers->complete_handler)
+ return request->state_handlers->complete_handler(request);
+
dev_warn(scic_to_dev(request->owning_controller),
"%s: SCIC IO Request requested to complete while in wrong "
"state %d\n",
return SCI_FAILURE_INVALID_STATE;
}
-/*
- * This method is the default action to take when an SCIC_SDS_IO_REQUEST_T
- * object receives a scic_sds_request_complete() request. The default action
- * is to log a warning and return a failure status. enum sci_status
- * SCI_FAILURE_INVALID_STATE
- */
-enum sci_status scic_sds_request_default_destruct_handler(
- struct scic_sds_request *request)
+enum sci_status scic_sds_io_request_event_handler(
+ struct scic_sds_request *request,
+ u32 event_code)
{
+ if (request->state_handlers->event_handler)
+ return request->state_handlers->event_handler(request, event_code);
+
dev_warn(scic_to_dev(request->owning_controller),
- "%s: SCIC IO Request requested to destroy while in wrong "
- "state %d\n",
+ "%s: SCIC IO Request given event code notification %x while "
+ "in wrong state %d\n",
__func__,
+ event_code,
sci_base_state_machine_get_state(&request->state_machine));
return SCI_FAILURE_INVALID_STATE;
}
-/**
- * This method is the default action to take when an SCIC_SDS_IO_REQUEST_T
- * object receives a scic_sds_task_request_complete() request. The default
- * action is to log a warning and return a failure status. enum sci_status
- * SCI_FAILURE_INVALID_STATE
- */
-enum sci_status scic_sds_request_default_tc_completion_handler(
- struct scic_sds_request *request,
- u32 completion_code)
+enum sci_status
+scic_sds_io_request_tc_completion(struct scic_sds_request *request, u32 completion_code)
{
+ if (request->state_machine.current_state_id == SCI_BASE_REQUEST_STATE_STARTED &&
+ request->has_started_substate_machine == false)
+ return scic_sds_request_started_state_tc_completion_handler(request, completion_code);
+ else if (request->state_handlers->tc_completion_handler)
+ return request->state_handlers->tc_completion_handler(request, completion_code);
+
dev_warn(scic_to_dev(request->owning_controller),
"%s: SCIC IO Request given task completion notification %x "
"while in wrong state %d\n",
}
-/*
- * This method is the default action to take when an SCIC_SDS_IO_REQUEST_T
- * object receives a scic_sds_request_event_handler() request. The default
- * action is to log a warning and return a failure status. enum sci_status
- * SCI_FAILURE_INVALID_STATE
+
+/**
+ *
+ * @sci_req: The SCIC_SDS_IO_REQUEST_T object for which the start
+ * operation is to be executed.
+ * @frame_index: The frame index returned by the hardware for the reqeust
+ * object.
+ *
+ * This method invokes the core state frame handler for the
+ * SCIC_SDS_IO_REQUEST_T object. enum sci_status
*/
-enum sci_status scic_sds_request_default_event_handler(
+enum sci_status scic_sds_io_request_frame_handler(
struct scic_sds_request *request,
- u32 event_code)
+ u32 frame_index)
{
+ if (request->state_handlers->frame_handler)
+ return request->state_handlers->frame_handler(request, frame_index);
+
dev_warn(scic_to_dev(request->owning_controller),
- "%s: SCIC IO Request given event code notification %x while "
- "in wrong state %d\n",
+ "%s: SCIC IO Request given unexpected frame %x while in "
+ "state %d\n",
__func__,
- event_code,
+ frame_index,
sci_base_state_machine_get_state(&request->state_machine));
+ scic_sds_controller_release_frame(request->owning_controller, frame_index);
return SCI_FAILURE_INVALID_STATE;
}
/*
- * This method is the default action to take when an SCIC_SDS_IO_REQUEST_T
- * object receives a scic_sds_request_event_handler() request. The default
- * action is to log a warning and return a failure status. enum sci_status
- * SCI_FAILURE_INVALID_STATE
+ * This function copies response data for requests returning response data
+ * instead of sense data.
+ * @sci_req: This parameter specifies the request object for which to copy
+ * the response data.
*/
-enum sci_status scic_sds_request_default_frame_handler(
- struct scic_sds_request *request,
- u32 frame_index)
+void scic_sds_io_request_copy_response(struct scic_sds_request *sci_req)
{
- dev_warn(scic_to_dev(request->owning_controller),
- "%s: SCIC IO Request given unexpected frame %x while in "
- "state %d\n",
- __func__,
- frame_index,
- sci_base_state_machine_get_state(&request->state_machine));
+ void *resp_buf;
+ u32 len;
+ struct ssp_response_iu *ssp_response;
+ struct isci_request *ireq = sci_req_to_ireq(sci_req);
+ struct isci_tmf *isci_tmf = isci_request_access_tmf(ireq);
- scic_sds_controller_release_frame(
- request->owning_controller, frame_index);
+ ssp_response = &sci_req->ssp.rsp;
- return SCI_FAILURE_INVALID_STATE;
+ resp_buf = &isci_tmf->resp.resp_iu;
+
+ len = min_t(u32,
+ SSP_RESP_IU_MAX_SIZE,
+ be32_to_cpu(ssp_response->response_data_len));
+
+ memcpy(resp_buf, ssp_response->resp_data, len);
}
/*
return SCI_SUCCESS;
}
-/**
+/*
* scic_sds_request_started_state_tc_completion_handler() - This method process
* TC (task context) completions for normal IO request (i.e. Task/Abort
* Completions of type 0). This method will update the
* SCIC_SDS_IO_REQUEST_T::status field.
- * @this_request: This parameter specifies the request for which a completion
+ * @sci_req: This parameter specifies the request for which a completion
* occurred.
* @completion_code: This parameter specifies the completion code received from
* the SCU.
*
*/
-enum sci_status scic_sds_request_started_state_tc_completion_handler(
- struct scic_sds_request *this_request,
- u32 completion_code)
+enum sci_status
+scic_sds_request_started_state_tc_completion_handler(
+ struct scic_sds_request *sci_req,
+ u32 completion_code)
{
- u8 data_present;
- struct sci_ssp_response_iu *response_buffer;
+ u8 datapres;
+ struct ssp_response_iu *resp_iu;
- /**
- * @todo Any SDMA return code of other than 0 is bad
+ /*
+ * TODO: Any SDMA return code of other than 0 is bad
* decode 0x003C0000 to determine SDMA status
*/
switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD):
- scic_sds_request_set_status(
- this_request, SCU_TASK_DONE_GOOD, SCI_SUCCESS
- );
+ scic_sds_request_set_status(sci_req,
+ SCU_TASK_DONE_GOOD,
+ SCI_SUCCESS);
break;
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_EARLY_RESP):
{
/*
- * There are times when the SCU hardware will return an early response
- * because the io request specified more data than is returned by the
- * target device (mode pages, inquiry data, etc.). We must check the
- * response stats to see if this is truly a failed request or a good
- * request that just got completed early. */
- struct sci_ssp_response_iu *response = (struct sci_ssp_response_iu *)
- this_request->response_buffer;
- scic_word_copy_with_swap(
- this_request->response_buffer,
- this_request->response_buffer,
- sizeof(struct sci_ssp_response_iu) / sizeof(u32)
- );
+ * There are times when the SCU hardware will return an early
+ * response because the io request specified more data than is
+ * returned by the target device (mode pages, inquiry data,
+ * etc.). We must check the response stats to see if this is
+ * truly a failed request or a good request that just got
+ * completed early.
+ */
+ struct ssp_response_iu *resp = &sci_req->ssp.rsp;
+ ssize_t word_cnt = SSP_RESP_IU_MAX_SIZE / sizeof(u32);
+
+ sci_swab32_cpy(&sci_req->ssp.rsp,
+ &sci_req->ssp.rsp,
+ word_cnt);
- if (response->status == 0) {
+ if (resp->status == 0) {
scic_sds_request_set_status(
- this_request, SCU_TASK_DONE_GOOD, SCI_SUCCESS_IO_DONE_EARLY
- );
+ sci_req,
+ SCU_TASK_DONE_GOOD,
+ SCI_SUCCESS_IO_DONE_EARLY);
} else {
scic_sds_request_set_status(
- this_request,
+ sci_req,
SCU_TASK_DONE_CHECK_RESPONSE,
- SCI_FAILURE_IO_RESPONSE_VALID
- );
+ SCI_FAILURE_IO_RESPONSE_VALID);
}
}
break;
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_CHECK_RESPONSE):
- scic_word_copy_with_swap(
- this_request->response_buffer,
- this_request->response_buffer,
- sizeof(struct sci_ssp_response_iu) / sizeof(u32)
- );
+ {
+ ssize_t word_cnt = SSP_RESP_IU_MAX_SIZE / sizeof(u32);
- scic_sds_request_set_status(
- this_request,
- SCU_TASK_DONE_CHECK_RESPONSE,
- SCI_FAILURE_IO_RESPONSE_VALID
- );
+ sci_swab32_cpy(&sci_req->ssp.rsp,
+ &sci_req->ssp.rsp,
+ word_cnt);
+
+ scic_sds_request_set_status(sci_req,
+ SCU_TASK_DONE_CHECK_RESPONSE,
+ SCI_FAILURE_IO_RESPONSE_VALID);
break;
+ }
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_RESP_LEN_ERR):
/*
- * / @todo With TASK_DONE_RESP_LEN_ERR is the response frame guaranteed
- * / to be received before this completion status is posted? */
- response_buffer =
- (struct sci_ssp_response_iu *)this_request->response_buffer;
- data_present =
- response_buffer->data_present & SCI_SSP_RESPONSE_IU_DATA_PRESENT_MASK;
-
- if ((data_present == 0x01) || (data_present == 0x02)) {
+ * / @todo With TASK_DONE_RESP_LEN_ERR is the response frame
+ * guaranteed to be received before this completion status is
+ * posted?
+ */
+ resp_iu = &sci_req->ssp.rsp;
+ datapres = resp_iu->datapres;
+
+ if ((datapres == 0x01) || (datapres == 0x02)) {
scic_sds_request_set_status(
- this_request,
+ sci_req,
SCU_TASK_DONE_CHECK_RESPONSE,
- SCI_FAILURE_IO_RESPONSE_VALID
- );
- } else {
+ SCI_FAILURE_IO_RESPONSE_VALID);
+ } else
scic_sds_request_set_status(
- this_request, SCU_TASK_DONE_GOOD, SCI_SUCCESS
- );
- }
+ sci_req, SCU_TASK_DONE_GOOD, SCI_SUCCESS);
break;
/* only stp device gets suspended. */
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_SDBFIS):
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_REG_ERR):
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SDB_ERR):
- if (this_request->protocol == SCIC_STP_PROTOCOL) {
+ if (sci_req->protocol == SCIC_STP_PROTOCOL) {
scic_sds_request_set_status(
- this_request,
- SCU_GET_COMPLETION_TL_STATUS(completion_code) >> SCU_COMPLETION_TL_STATUS_SHIFT,
- SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED
- );
+ sci_req,
+ SCU_GET_COMPLETION_TL_STATUS(completion_code) >>
+ SCU_COMPLETION_TL_STATUS_SHIFT,
+ SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED);
} else {
scic_sds_request_set_status(
- this_request,
- SCU_GET_COMPLETION_TL_STATUS(completion_code) >> SCU_COMPLETION_TL_STATUS_SHIFT,
- SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR
- );
+ sci_req,
+ SCU_GET_COMPLETION_TL_STATUS(completion_code) >>
+ SCU_COMPLETION_TL_STATUS_SHIFT,
+ SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
}
break;
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_PROTOCOL_NOT_SUPPORTED):
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_CONNECTION_RATE_NOT_SUPPORTED):
scic_sds_request_set_status(
- this_request,
- SCU_GET_COMPLETION_TL_STATUS(completion_code) >> SCU_COMPLETION_TL_STATUS_SHIFT,
- SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED
- );
+ sci_req,
+ SCU_GET_COMPLETION_TL_STATUS(completion_code) >>
+ SCU_COMPLETION_TL_STATUS_SHIFT,
+ SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED);
break;
/* neither ssp nor stp gets suspended. */
case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_RNCNV_OUTBOUND):
default:
scic_sds_request_set_status(
- this_request,
- SCU_GET_COMPLETION_TL_STATUS(completion_code) >> SCU_COMPLETION_TL_STATUS_SHIFT,
- SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR
- );
+ sci_req,
+ SCU_GET_COMPLETION_TL_STATUS(completion_code) >>
+ SCU_COMPLETION_TL_STATUS_SHIFT,
+ SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
break;
}
- /**
- * @todo This is probably wrong for ACK/NAK timeout conditions
+ /*
+ * TODO: This is probably wrong for ACK/NAK timeout conditions
*/
- /* In all cases we will treat this as the completion of the IO request. */
- sci_base_state_machine_change_state(&this_request->state_machine,
- SCI_BASE_REQUEST_STATE_COMPLETED);
+ /* In all cases we will treat this as the completion of the IO req. */
+ sci_base_state_machine_change_state(
+ &sci_req->state_machine,
+ SCI_BASE_REQUEST_STATE_COMPLETED);
return SCI_SUCCESS;
}
* at completion time. If the frame type is not a response buffer an error is
* logged. enum sci_status SCI_SUCCESS SCI_FAILURE_INVALID_PARAMETER_VALUE
*/
-static enum sci_status scic_sds_request_started_state_frame_handler(
- struct scic_sds_request *this_request,
- u32 frame_index)
+static enum sci_status
+scic_sds_request_started_state_frame_handler(struct scic_sds_request *sci_req,
+ u32 frame_index)
{
enum sci_status status;
- struct sci_ssp_frame_header *frame_header;
+ u32 *frame_header;
+ struct ssp_frame_hdr ssp_hdr;
+ ssize_t word_cnt;
- /* / @todo If this is a response frame we must record that we received it */
status = scic_sds_unsolicited_frame_control_get_header(
- &(scic_sds_request_get_controller(this_request)->uf_control),
+ &(scic_sds_request_get_controller(sci_req)->uf_control),
frame_index,
- (void **)&frame_header
- );
+ (void **)&frame_header);
- if (frame_header->frame_type == SCI_SAS_RESPONSE_FRAME) {
- struct sci_ssp_response_iu *response_buffer;
+ word_cnt = sizeof(struct ssp_frame_hdr) / sizeof(u32);
+ sci_swab32_cpy(&ssp_hdr, frame_header, word_cnt);
+
+ if (ssp_hdr.frame_type == SSP_RESPONSE) {
+ struct ssp_response_iu *resp_iu;
+ ssize_t word_cnt = SSP_RESP_IU_MAX_SIZE / sizeof(u32);
status = scic_sds_unsolicited_frame_control_get_buffer(
- &(scic_sds_request_get_controller(this_request)->uf_control),
+ &(scic_sds_request_get_controller(sci_req)->uf_control),
frame_index,
- (void **)&response_buffer
- );
+ (void **)&resp_iu);
- scic_word_copy_with_swap(
- this_request->response_buffer,
- (u32 *)response_buffer,
- sizeof(struct sci_ssp_response_iu)
- );
+ sci_swab32_cpy(&sci_req->ssp.rsp,
+ resp_iu, word_cnt);
- response_buffer = (struct sci_ssp_response_iu *)this_request->response_buffer;
+ resp_iu = &sci_req->ssp.rsp;
- if ((response_buffer->data_present == 0x01) ||
- (response_buffer->data_present == 0x02)) {
+ if ((resp_iu->datapres == 0x01) ||
+ (resp_iu->datapres == 0x02)) {
scic_sds_request_set_status(
- this_request,
+ sci_req,
SCU_TASK_DONE_CHECK_RESPONSE,
- SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR
- );
+ SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR);
} else
scic_sds_request_set_status(
- this_request, SCU_TASK_DONE_GOOD, SCI_SUCCESS
- );
- } else
+ sci_req, SCU_TASK_DONE_GOOD, SCI_SUCCESS);
+ } else {
/* This was not a response frame why did it get forwarded? */
- dev_err(scic_to_dev(this_request->owning_controller),
+ dev_err(scic_to_dev(sci_req->owning_controller),
"%s: SCIC IO Request 0x%p received unexpected "
"frame %d type 0x%02x\n",
__func__,
- this_request,
+ sci_req,
frame_index,
- frame_header->frame_type);
+ ssp_hdr.frame_type);
+ }
/*
* In any case we are done with this frame buffer return it to the
- * controller */
+ * controller
+ */
scic_sds_controller_release_frame(
- this_request->owning_controller, frame_index
- );
+ sci_req->owning_controller, frame_index);
return SCI_SUCCESS;
}
* transitions to the completed state. enum sci_status SCI_SUCCESS
*/
static enum sci_status scic_sds_request_aborting_state_tc_completion_handler(
- struct scic_sds_request *this_request,
+ struct scic_sds_request *sci_req,
u32 completion_code)
{
switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) {
case (SCU_TASK_DONE_GOOD << SCU_COMPLETION_TL_STATUS_SHIFT):
case (SCU_TASK_DONE_TASK_ABORT << SCU_COMPLETION_TL_STATUS_SHIFT):
scic_sds_request_set_status(
- this_request, SCU_TASK_DONE_TASK_ABORT, SCI_FAILURE_IO_TERMINATED
+ sci_req, SCU_TASK_DONE_TASK_ABORT, SCI_FAILURE_IO_TERMINATED
);
- sci_base_state_machine_change_state(&this_request->state_machine,
+ sci_base_state_machine_change_state(&sci_req->state_machine,
SCI_BASE_REQUEST_STATE_COMPLETED);
break;
* completion. enum sci_status SCI_SUCCESS
*/
static enum sci_status scic_sds_request_aborting_state_frame_handler(
- struct scic_sds_request *this_request,
+ struct scic_sds_request *sci_req,
u32 frame_index)
{
/* TODO: Is it even possible to get an unsolicited frame in the aborting state? */
scic_sds_controller_release_frame(
- this_request->owning_controller, frame_index);
+ sci_req->owning_controller, frame_index);
return SCI_SUCCESS;
}
static const struct scic_sds_io_request_state_handler scic_sds_request_state_handler_table[] = {
[SCI_BASE_REQUEST_STATE_INITIAL] = {
- .start_handler = scic_sds_request_default_start_handler,
- .abort_handler = scic_sds_request_default_abort_handler,
- .complete_handler = scic_sds_request_default_complete_handler,
- .destruct_handler = scic_sds_request_default_destruct_handler,
- .tc_completion_handler = scic_sds_request_default_tc_completion_handler,
- .event_handler = scic_sds_request_default_event_handler,
- .frame_handler = scic_sds_request_default_frame_handler,
},
[SCI_BASE_REQUEST_STATE_CONSTRUCTED] = {
.start_handler = scic_sds_request_constructed_state_start_handler,
.abort_handler = scic_sds_request_constructed_state_abort_handler,
- .complete_handler = scic_sds_request_default_complete_handler,
- .destruct_handler = scic_sds_request_default_destruct_handler,
- .tc_completion_handler = scic_sds_request_default_tc_completion_handler,
- .event_handler = scic_sds_request_default_event_handler,
- .frame_handler = scic_sds_request_default_frame_handler,
},
[SCI_BASE_REQUEST_STATE_STARTED] = {
- .start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_request_started_state_abort_handler,
- .complete_handler = scic_sds_request_default_complete_handler,
- .destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_request_started_state_tc_completion_handler,
- .event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_request_started_state_frame_handler,
},
[SCI_BASE_REQUEST_STATE_COMPLETED] = {
- .start_handler = scic_sds_request_default_start_handler,
- .abort_handler = scic_sds_request_default_abort_handler,
.complete_handler = scic_sds_request_completed_state_complete_handler,
- .destruct_handler = scic_sds_request_default_destruct_handler,
- .tc_completion_handler = scic_sds_request_default_tc_completion_handler,
- .event_handler = scic_sds_request_default_event_handler,
- .frame_handler = scic_sds_request_default_frame_handler,
},
[SCI_BASE_REQUEST_STATE_ABORTING] = {
- .start_handler = scic_sds_request_default_start_handler,
.abort_handler = scic_sds_request_aborting_state_abort_handler,
- .complete_handler = scic_sds_request_default_complete_handler,
- .destruct_handler = scic_sds_request_default_destruct_handler,
.tc_completion_handler = scic_sds_request_aborting_state_tc_completion_handler,
- .event_handler = scic_sds_request_default_event_handler,
.frame_handler = scic_sds_request_aborting_state_frame_handler,
},
[SCI_BASE_REQUEST_STATE_FINAL] = {
- .start_handler = scic_sds_request_default_start_handler,
- .abort_handler = scic_sds_request_default_abort_handler,
- .complete_handler = scic_sds_request_default_complete_handler,
- .destruct_handler = scic_sds_request_default_destruct_handler,
- .tc_completion_handler = scic_sds_request_default_tc_completion_handler,
- .event_handler = scic_sds_request_default_event_handler,
- .frame_handler = scic_sds_request_default_frame_handler,
},
};
* base request is constructed. Entry into the initial state sets all handlers
* for the io request object to their default handlers. none
*/
-static void scic_sds_request_initial_state_enter(
- struct sci_base_object *object)
+static void scic_sds_request_initial_state_enter(void *object)
{
- struct scic_sds_request *this_request = (struct scic_sds_request *)object;
+ struct scic_sds_request *sci_req = object;
SET_STATE_HANDLER(
- this_request,
+ sci_req,
scic_sds_request_state_handler_table,
SCI_BASE_REQUEST_STATE_INITIAL
);
* SCI_BASE_REQUEST_STATE_CONSTRUCTED state. The method sets the state handlers
* for the the constructed state. none
*/
-static void scic_sds_request_constructed_state_enter(
- struct sci_base_object *object)
+static void scic_sds_request_constructed_state_enter(void *object)
{
- struct scic_sds_request *this_request = (struct scic_sds_request *)object;
+ struct scic_sds_request *sci_req = object;
SET_STATE_HANDLER(
- this_request,
+ sci_req,
scic_sds_request_state_handler_table,
SCI_BASE_REQUEST_STATE_CONSTRUCTED
);
/**
* scic_sds_request_started_state_enter() -
* @object: This parameter specifies the base object for which the state
- * transition is occuring. This is cast into a SCIC_SDS_IO_REQUEST object.
+ * transition is occurring. This is cast into a SCIC_SDS_IO_REQUEST object.
*
* This method implements the actions taken when entering the
* SCI_BASE_REQUEST_STATE_STARTED state. If the io request object type is a
* SCSI Task request we must enter the started substate machine. none
*/
-static void scic_sds_request_started_state_enter(
- struct sci_base_object *object)
+static void scic_sds_request_started_state_enter(void *object)
{
- struct scic_sds_request *this_request = (struct scic_sds_request *)object;
+ struct scic_sds_request *sci_req = object;
SET_STATE_HANDLER(
- this_request,
+ sci_req,
scic_sds_request_state_handler_table,
SCI_BASE_REQUEST_STATE_STARTED
);
/*
* Most of the request state machines have a started substate machine so
* start its execution on the entry to the started state. */
- if (this_request->has_started_substate_machine == true)
- sci_base_state_machine_start(&this_request->started_substate_machine);
+ if (sci_req->has_started_substate_machine == true)
+ sci_base_state_machine_start(&sci_req->started_substate_machine);
}
/**
* scic_sds_request_started_state_exit() -
* @object: This parameter specifies the base object for which the state
- * transition is occuring. This object is cast into a SCIC_SDS_IO_REQUEST
+ * transition is occurring. This object is cast into a SCIC_SDS_IO_REQUEST
* object.
*
* This method implements the actions taken when exiting the
* SCI_BASE_REQUEST_STATE_STARTED state. For task requests the action will be
* to stop the started substate machine. none
*/
-static void scic_sds_request_started_state_exit(
- struct sci_base_object *object)
+static void scic_sds_request_started_state_exit(void *object)
{
- struct scic_sds_request *this_request = (struct scic_sds_request *)object;
+ struct scic_sds_request *sci_req = object;
- if (this_request->has_started_substate_machine == true)
- sci_base_state_machine_stop(&this_request->started_substate_machine);
+ if (sci_req->has_started_substate_machine == true)
+ sci_base_state_machine_stop(&sci_req->started_substate_machine);
}
/**
* scic_sds_request_completed_state_enter() -
* @object: This parameter specifies the base object for which the state
- * transition is occuring. This object is cast into a SCIC_SDS_IO_REQUEST
+ * transition is occurring. This object is cast into a SCIC_SDS_IO_REQUEST
* object.
*
* This method implements the actions taken when entering the
* completion status and convert it to an enum sci_status to return in the
* completion callback function. none
*/
-static void scic_sds_request_completed_state_enter(
- struct sci_base_object *object)
+static void scic_sds_request_completed_state_enter(void *object)
{
- struct scic_sds_request *sci_req = (struct scic_sds_request *)object;
+ struct scic_sds_request *sci_req = object;
struct scic_sds_controller *scic =
scic_sds_request_get_controller(sci_req);
- struct isci_host *ihost = sci_object_get_association(scic);
- struct isci_request *ireq = sci_object_get_association(sci_req);
-
+ struct isci_host *ihost = scic_to_ihost(scic);
+ struct isci_request *ireq = sci_req_to_ireq(sci_req);
SET_STATE_HANDLER(sci_req,
scic_sds_request_state_handler_table,
/**
* scic_sds_request_aborting_state_enter() -
* @object: This parameter specifies the base object for which the state
- * transition is occuring. This object is cast into a SCIC_SDS_IO_REQUEST
+ * transition is occurring. This object is cast into a SCIC_SDS_IO_REQUEST
* object.
*
* This method implements the actions taken when entering the
* SCI_BASE_REQUEST_STATE_ABORTING state. none
*/
-static void scic_sds_request_aborting_state_enter(
- struct sci_base_object *object)
+static void scic_sds_request_aborting_state_enter(void *object)
{
- struct scic_sds_request *this_request = (struct scic_sds_request *)object;
+ struct scic_sds_request *sci_req = object;
/* Setting the abort bit in the Task Context is required by the silicon. */
- this_request->task_context_buffer->abort = 1;
+ sci_req->task_context_buffer->abort = 1;
SET_STATE_HANDLER(
- this_request,
+ sci_req,
scic_sds_request_state_handler_table,
SCI_BASE_REQUEST_STATE_ABORTING
);
/**
* scic_sds_request_final_state_enter() -
* @object: This parameter specifies the base object for which the state
- * transition is occuring. This is cast into a SCIC_SDS_IO_REQUEST object.
+ * transition is occurring. This is cast into a SCIC_SDS_IO_REQUEST object.
*
* This method implements the actions taken when entering the
* SCI_BASE_REQUEST_STATE_FINAL state. The only action required is to put the
* state handlers in place. none
*/
-static void scic_sds_request_final_state_enter(
- struct sci_base_object *object)
+static void scic_sds_request_final_state_enter(void *object)
{
- struct scic_sds_request *this_request = (struct scic_sds_request *)object;
+ struct scic_sds_request *sci_req = object;
SET_STATE_HANDLER(
- this_request,
+ sci_req,
scic_sds_request_state_handler_table,
SCI_BASE_REQUEST_STATE_FINAL
);
static void scic_sds_general_request_construct(struct scic_sds_controller *scic,
struct scic_sds_remote_device *sci_dev,
- u16 io_tag,
- void *user_io_request_object,
- struct scic_sds_request *sci_req)
+ u16 io_tag, struct scic_sds_request *sci_req)
{
- sci_req->parent.private = NULL;
- sci_base_state_machine_construct(&sci_req->state_machine, &sci_req->parent,
+ sci_base_state_machine_construct(&sci_req->state_machine, sci_req,
scic_sds_request_state_table, SCI_BASE_REQUEST_STATE_INITIAL);
sci_base_state_machine_start(&sci_req->state_machine);
sci_req->io_tag = io_tag;
- sci_req->user_request = user_io_request_object;
sci_req->owning_controller = scic;
sci_req->target_device = sci_dev;
sci_req->has_started_substate_machine = false;
}
}
-enum sci_status scic_io_request_construct(struct scic_sds_controller *scic,
- struct scic_sds_remote_device *sci_dev,
- u16 io_tag,
- void *user_io_request_object,
- struct scic_sds_request *sci_req,
- struct scic_sds_request **new_scic_io_request_handle)
+enum sci_status
+scic_io_request_construct(struct scic_sds_controller *scic,
+ struct scic_sds_remote_device *sci_dev,
+ u16 io_tag, struct scic_sds_request *sci_req)
{
+ struct domain_device *dev = sci_dev_to_domain(sci_dev);
enum sci_status status = SCI_SUCCESS;
- struct smp_discover_response_protocols device_protocol;
/* Build the common part of the request */
- scic_sds_general_request_construct(scic, sci_dev, io_tag,
- user_io_request_object, sci_req);
+ scic_sds_general_request_construct(scic, sci_dev, io_tag, sci_req);
- if (sci_dev->rnc->remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX)
+ if (sci_dev->rnc.remote_node_index ==
+ SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX)
return SCI_FAILURE_INVALID_REMOTE_DEVICE;
- scic_remote_device_get_protocols(sci_dev, &device_protocol);
-
- if (device_protocol.u.bits.attached_ssp_target) {
+ if (dev->dev_type == SAS_END_DEV)
scic_sds_ssp_io_request_assign_buffers(sci_req);
- } else if (device_protocol.u.bits.attached_stp_target) {
+ else if ((dev->dev_type == SATA_DEV) ||
+ (dev->tproto & SAS_PROTOCOL_STP)) {
scic_sds_stp_request_assign_buffers(sci_req);
- memset(sci_req->command_buffer, 0, sizeof(struct sata_fis_reg_h2d));
- } else if (device_protocol.u.bits.attached_smp_target) {
+ memset(&sci_req->stp.cmd, 0, sizeof(sci_req->stp.cmd));
+ } else if (dev_is_expander(dev)) {
scic_sds_smp_request_assign_buffers(sci_req);
- memset(sci_req->command_buffer, 0, sizeof(struct smp_request));
- } else {
+ memset(&sci_req->smp.cmd, 0, sizeof(sci_req->smp.cmd));
+ } else
status = SCI_FAILURE_UNSUPPORTED_PROTOCOL;
- }
if (status == SCI_SUCCESS) {
memset(sci_req->task_context_buffer, 0,
- SCI_FIELD_OFFSET(struct scu_task_context, sgl_pair_ab));
- *new_scic_io_request_handle = sci_req;
+ offsetof(struct scu_task_context, sgl_pair_ab));
}
return status;
enum sci_status scic_task_request_construct(struct scic_sds_controller *scic,
struct scic_sds_remote_device *sci_dev,
- u16 io_tag,
- void *user_io_request_object,
- struct scic_sds_request *sci_req,
- struct scic_sds_request **new_sci_req)
+ u16 io_tag, struct scic_sds_request *sci_req)
{
+ struct domain_device *dev = sci_dev_to_domain(sci_dev);
enum sci_status status = SCI_SUCCESS;
- struct smp_discover_response_protocols device_protocol;
/* Build the common part of the request */
- scic_sds_general_request_construct(scic, sci_dev, io_tag,
- user_io_request_object,
- sci_req);
+ scic_sds_general_request_construct(scic, sci_dev, io_tag, sci_req);
- scic_remote_device_get_protocols(sci_dev, &device_protocol);
-
- if (device_protocol.u.bits.attached_ssp_target) {
+ if (dev->dev_type == SAS_END_DEV) {
scic_sds_ssp_task_request_assign_buffers(sci_req);
sci_req->has_started_substate_machine = true;
/* Construct the started sub-state machine. */
sci_base_state_machine_construct(
&sci_req->started_substate_machine,
- &sci_req->parent,
+ sci_req,
scic_sds_io_request_started_task_mgmt_substate_table,
SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION
);
- } else if (device_protocol.u.bits.attached_stp_target) {
+ } else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP))
scic_sds_stp_request_assign_buffers(sci_req);
- } else {
+ else
status = SCI_FAILURE_UNSUPPORTED_PROTOCOL;
- }
if (status == SCI_SUCCESS) {
sci_req->is_task_management_request = true;
memset(sci_req->task_context_buffer, 0, sizeof(struct scu_task_context));
- *new_sci_req = sci_req;
}
return status;