Skip to content

Commit

Permalink
isci: make command/response iu explicit request object members
Browse files Browse the repository at this point in the history
Final elimination of the anonymous data at the end of the request
structure.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
  • Loading branch information
Dan Williams committed Jul 3, 2011
1 parent 2629826 commit b764581
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 423 deletions.
61 changes: 0 additions & 61 deletions drivers/scsi/isci/core/scic_io_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,6 @@ typedef enum {
} SCIC_TRANSPORT_PROTOCOL;


/**
* scic_io_request_get_object_size() - This method simply returns the size
* required to build an SCI based IO request object.
*
* Return the size of the SCI IO request object.
*/
u32 scic_io_request_get_object_size(void);

/**
* scic_io_request_construct() - This method is called by the SCI user to
* construct all SCI Core IO requests. Memory initialization and
Expand Down Expand Up @@ -222,32 +214,6 @@ enum sci_status scic_io_request_construct_smp(
u32 scic_request_get_controller_status(
struct scic_sds_request *io_request);



/**
* scic_io_request_get_command_iu_address() - This method will return the
* address to the command information unit.
* @scic_io_request: This parameter specifies the handle to the io request
* object to be built.
*
* The address of the SSP/SMP command information unit.
*/
void *scic_io_request_get_command_iu_address(
struct scic_sds_request *scic_io_request);

/**
* scic_io_request_get_response_iu_address() - This method will return the
* address to the response information unit. For an SSP request this buffer
* is only valid if the IO request is completed with the status
* SCI_FAILURE_IO_RESPONSE_VALID.
* @scic_io_request: This parameter specifies the handle to the io request
* object to be built.
*
* The address of the SSP/SMP response information unit.
*/
void *scic_io_request_get_response_iu_address(
struct scic_sds_request *scic_io_request);

/**
* scic_io_request_get_io_tag() - This method will return the IO tag utilized
* by the IO request.
Expand Down Expand Up @@ -279,33 +245,6 @@ void scic_stp_io_request_set_ncq_tag(
struct scic_sds_request *scic_io_request,
u16 ncq_tag);

/**
* scic_stp_io_request_get_h2d_reg_address() - This method will return the
* address of the host to device register fis region for the io request
* object.
* @scic_io_request: This parameter specifies the handle to the io request
* object from which to get the host to device register fis buffer.
*
* The address of the host to device register fis buffer in the io request
* object. This function is only valid for SATA requests.
*/
void *scic_stp_io_request_get_h2d_reg_address(
struct scic_sds_request *scic_io_request);

/**
* scic_stp_io_request_get_d2h_reg_address() - This method will return the
* address of the device to host register fis region for the io request
* object.
* @scic_io_request: This parameter specifies teh handle to the io request
* object from which to get the device to host register fis buffer.
*
* The address fo the device to host register fis ending the io request. This
* function is only valid for SATA requests.
*/
void *scic_stp_io_request_get_d2h_reg_address(
struct scic_sds_request *scic_io_request);


/**
* scic_io_request_get_number_of_bytes_transferred() - This method will return
* the number of bytes transferred from the SCU
Expand Down
178 changes: 17 additions & 161 deletions drivers/scsi/isci/core/scic_sds_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,93 +83,6 @@
#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 ssp_cmd_iu) \
+ SSP_RESP_IU_MAX_SIZE \
)

/**
* 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 ssp_cmd_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 ssp_response_iu *)(\
((char *)(scic_sds_ssp_request_get_command_buffer(memory))) \
+ sizeof(struct ssp_cmd_iu) \
))

/**
* 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 ssp_task_iu) \
+ SSP_RESP_IU_MAX_SIZE \
)

/**
* 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 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 ssp_response_iu *)(\
((char *)(scic_sds_ssp_task_request_get_command_buffer(memory))) \
+ sizeof(struct ssp_task_iu) \
))

/**
*
*
* 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();
}

/**
* This method returns the sgl element pair for the specificed sgl_pair index.
* @sci_req: This parameter specifies the IO request for which to retrieve
Expand Down Expand Up @@ -268,21 +181,8 @@ void scic_sds_request_build_sgl(struct scic_sds_request *sds_request)
}
}

/**
* This method build the remainder of the IO request object.
* @sci_req: 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 *sci_req)
static void scic_sds_ssp_io_request_assign_buffers(struct scic_sds_request *sci_req)
{
sci_req->command_buffer =
scic_sds_ssp_request_get_command_buffer(sci_req);
sci_req->response_buffer =
scic_sds_ssp_request_get_response_buffer(sci_req);

if (sci_req->was_tag_assigned_by_user == false)
sci_req->task_context_buffer = &sci_req->tc;
}
Expand All @@ -293,7 +193,7 @@ static void scic_sds_io_request_build_ssp_command_iu(struct scic_sds_request *sc
struct isci_request *ireq = sci_req->ireq;
struct sas_task *task = isci_request_access_task(ireq);

cmd_iu = sci_req->command_buffer;
cmd_iu = &sci_req->ssp.cmd;

memcpy(cmd_iu->LUN, task->ssp_task.LUN, 8);
cmd_iu->add_cdb_len = 0;
Expand All @@ -315,7 +215,7 @@ static void scic_sds_task_request_build_ssp_task_iu(struct scic_sds_request *sci
struct sas_task *task = isci_request_access_task(ireq);
struct isci_tmf *isci_tmf = isci_request_access_tmf(ireq);

task_iu = sci_req->command_buffer;
task_iu = &sci_req->ssp.tmf;

memset(task_iu, 0, sizeof(struct ssp_task_iu));

Expand Down Expand Up @@ -411,7 +311,7 @@ static void scu_ssp_reqeust_construct_task_context(
* 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);
Expand All @@ -421,7 +321,7 @@ static void scu_ssp_reqeust_construct_task_context(
* 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);
Expand Down Expand Up @@ -464,22 +364,8 @@ static void scu_ssp_io_request_construct_task_context(
scic_sds_request_build_sgl(sci_req);
}


/**
* This method will fill in the remainder of the io request object for SSP Task
* requests.
* @sci_req:
*
*/
static void scic_sds_ssp_task_request_assign_buffers(
struct scic_sds_request *sci_req)
static void scic_sds_ssp_task_request_assign_buffers(struct scic_sds_request *sci_req)
{
/* Assign all of the buffer pointers */
sci_req->command_buffer =
scic_sds_ssp_task_request_get_command_buffer(sci_req);
sci_req->response_buffer =
scic_sds_ssp_task_request_get_response_buffer(sci_req);

if (sci_req->was_tag_assigned_by_user == false)
sci_req->task_context_buffer = &sci_req->tc;
}
Expand Down Expand Up @@ -589,19 +475,6 @@ scic_io_request_construct_sata(struct scic_sds_request *sci_req,
return status;
}

u32 scic_io_request_get_object_size(void)
{
u32 ssp_request_size;
u32 stp_request_size;
u32 smp_request_size;

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();

return max(ssp_request_size, max(stp_request_size, smp_request_size));
}

enum sci_status scic_io_request_construct_basic_ssp(
struct scic_sds_request *sci_req)
{
Expand Down Expand Up @@ -712,21 +585,6 @@ u32 scic_request_get_controller_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)
Expand Down Expand Up @@ -885,7 +743,7 @@ void scic_sds_io_request_copy_response(struct scic_sds_request *sci_req)
struct isci_request *ireq = sci_req->ireq;
struct isci_tmf *isci_tmf = isci_request_access_tmf(ireq);

ssp_response = sci_req->response_buffer;
ssp_response = &sci_req->ssp.rsp;

resp_buf = &isci_tmf->resp.resp_iu;

Expand Down Expand Up @@ -1053,11 +911,11 @@ scic_sds_request_started_state_tc_completion_handler(
* truly a failed request or a good request that just got
* completed early.
*/
struct ssp_response_iu *resp = sci_req->response_buffer;
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->response_buffer,
sci_req->response_buffer,
sci_swab32_cpy(&sci_req->ssp.rsp,
&sci_req->ssp.rsp,
word_cnt);

if (resp->status == 0) {
Expand All @@ -1078,8 +936,8 @@ scic_sds_request_started_state_tc_completion_handler(
{
ssize_t word_cnt = SSP_RESP_IU_MAX_SIZE / sizeof(u32);

sci_swab32_cpy(sci_req->response_buffer,
sci_req->response_buffer,
sci_swab32_cpy(&sci_req->ssp.rsp,
&sci_req->ssp.rsp,
word_cnt);

scic_sds_request_set_status(sci_req,
Expand All @@ -1094,7 +952,7 @@ scic_sds_request_started_state_tc_completion_handler(
* guaranteed to be received before this completion status is
* posted?
*/
resp_iu = sci_req->response_buffer;
resp_iu = &sci_req->ssp.rsp;
datapres = resp_iu->datapres;

if ((datapres == 0x01) || (datapres == 0x02)) {
Expand Down Expand Up @@ -1222,10 +1080,10 @@ scic_sds_request_started_state_frame_handler(struct scic_sds_request *sci_req,
frame_index,
(void **)&resp_iu);

sci_swab32_cpy(sci_req->response_buffer,
sci_swab32_cpy(&sci_req->ssp.rsp,
resp_iu, word_cnt);

resp_iu = sci_req->response_buffer;
resp_iu = &sci_req->ssp.rsp;

if ((resp_iu->datapres == 0x01) ||
(resp_iu->datapres == 0x02)) {
Expand Down Expand Up @@ -1627,12 +1485,10 @@ scic_io_request_construct(struct scic_sds_controller *scic,
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 host_to_dev_fis));
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_req));
memset(&sci_req->smp.cmd, 0, sizeof(sci_req->smp.cmd));
} else
status = SCI_FAILURE_UNSUPPORTED_PROTOCOL;

Expand Down
Loading

0 comments on commit b764581

Please sign in to comment.