Skip to content

Commit

Permalink
isci: Fixup SSP command IU and task IU
Browse files Browse the repository at this point in the history
Fixup of SSP command IU and SSP task IU to something that looks like Linux

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
  • Loading branch information
Dave Jiang authored and Dan Williams committed Jul 3, 2011
1 parent ed0e248 commit 0cfa890
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 285 deletions.
47 changes: 0 additions & 47 deletions drivers/scsi/isci/core/intel_sas.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,53 +160,6 @@ enum sci_sas_frame_type {
SCI_SAS_TASK_FRAME = 0x16
};

/**
* struct sci_ssp_command_iu - This structure depicts the contents of the SSP
* COMMAND INFORMATION UNIT. For specific information on each of these
* individual fields please reference the SAS specification SSP transport
* layer section.
*
*
*/
struct sci_ssp_command_iu {
u32 lun_upper;
u32 lun_lower;

u32 additional_cdb_length:6;
u32 reserved0:2;
u32 reserved1:8;
u32 enable_first_burst:1;
u32 task_priority:4;
u32 task_attribute:3;
u32 reserved2:8;

u32 cdb[4];

};

/**
* struct sci_ssp_task_iu - This structure depicts the contents of the SSP TASK
* INFORMATION UNIT. For specific information on each of these individual
* fields please reference the SAS specification SSP transport layer section.
*
*
*/
struct sci_ssp_task_iu {
u32 lun_upper;
u32 lun_lower;

u32 reserved0:8;
u32 task_function:8;
u32 reserved1:8;
u32 reserved2:8;

u32 reserved3:16;
u32 task_tag:16;

u32 reserved4[3];

};

#define SSP_RESPONSE_IU_MAX_DATA 64

#define SCI_SSP_RESPONSE_IU_DATA_PRESENT_MASK (0x03)
Expand Down
108 changes: 40 additions & 68 deletions drivers/scsi/isci/core/scic_sds_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
*/

#include <scsi/sas.h>
#include "sas.h"
#include "intel_sas.h"
#include "scic_controller.h"
#include "scic_io_request.h"
Expand Down Expand Up @@ -98,7 +99,7 @@
*/
#define scic_ssp_io_request_get_object_size() \
(\
sizeof(struct sci_ssp_command_iu) \
sizeof(struct ssp_cmd_iu) \
+ sizeof(struct sci_ssp_response_iu) \
)

Expand All @@ -109,7 +110,7 @@
* memory
*/
#define scic_sds_ssp_request_get_command_buffer(memory) \
((struct sci_ssp_command_iu *)(\
((struct ssp_cmd_iu *)(\
((char *)(memory)) + sizeof(struct scic_sds_request) \
))

Expand All @@ -122,7 +123,7 @@
#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) \
+ sizeof(struct ssp_cmd_iu) \
))

/**
Expand Down Expand Up @@ -158,7 +159,7 @@
*/
#define scic_ssp_task_request_get_object_size() \
(\
sizeof(struct sci_ssp_task_iu) \
sizeof(struct ssp_task_iu) \
+ sizeof(struct sci_ssp_response_iu) \
)

Expand All @@ -169,7 +170,7 @@
* 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 *)(\
((struct ssp_task_iu *)(\
((char *)(memory)) + sizeof(struct scic_sds_request) \
))

Expand All @@ -182,7 +183,7 @@
#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) \
+ sizeof(struct ssp_task_iu) \
))

/**
Expand Down Expand Up @@ -344,80 +345,49 @@ static void scic_sds_ssp_io_request_assign_buffers(
}
}

/**
* This method constructs the SSP Command IU data for this io request object.
* @sci_req: 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 = sds_request->ireq;

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;
struct ssp_cmd_iu *cmd_iu;
struct isci_request *ireq = sci_req->ireq;
struct sas_task *task = isci_request_access_task(ireq);

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);
cmd_iu = sci_req->command_buffer;

if (cdb_length > 16) {
command_frame->additional_cdb_length = cdb_length - 16;
}
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;

/* / @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);
(u32 *)(&cmd_iu->cdb),
(u32 *)task->ssp_task.cdb,
sizeof(task->ssp_task.cdb) / sizeof(u32));
}


/**
* This method constructs the SSP Task IU data for this io request object.
* @sci_req:
*
*/
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 = sds_request->ireq;
struct ssp_task_iu *task_iu;
struct isci_request *ireq = sci_req->ireq;
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->command_buffer;

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.
* @sci_req:
Expand Down Expand Up @@ -533,7 +503,8 @@ 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->ssp_command_iu_length =
sizeof(struct ssp_cmd_iu) / sizeof(u32);
task_context->type.ssp.frame_type = SCI_SAS_COMMAND_FRAME;

switch (dir) {
Expand Down Expand Up @@ -605,7 +576,8 @@ static void scu_ssp_task_request_construct_task_context(
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->ssp_command_iu_length =
sizeof(struct ssp_task_iu) / sizeof(u32);
}


Expand Down
121 changes: 0 additions & 121 deletions drivers/scsi/isci/request.c
Original file line number Diff line number Diff line change
Expand Up @@ -1241,124 +1241,3 @@ enum dma_data_direction isci_request_io_request_get_data_direction(

return task->data_dir;
}

/**
* isci_request_sge_get_address_field() - This function is called by the sci
* core to retrieve the address field contents for a given sge.
* @request: This parameter is the isci_request object.
* @sge_address: This parameter is the sge.
*
* physical address in the specified sge.
*/


/**
* isci_request_sge_get_length_field() - This function is called by the sci
* core to retrieve the length field contents for a given sge.
* @request: This parameter is the isci_request object.
* @sge_address: This parameter is the sge.
*
* length field value in the specified sge.
*/


/**
* isci_request_ssp_io_request_get_cdb_address() - This function is called by
* the sci core to retrieve the cdb address for a given request.
* @request: This parameter is the isci_request object.
*
* cdb address for specified request.
*/
void *isci_request_ssp_io_request_get_cdb_address(
struct isci_request *request)
{
struct sas_task *task = isci_request_access_task(request);

dev_dbg(&request->isci_host->pdev->dev,
"%s: request->task->ssp_task.cdb = %p\n",
__func__,
task->ssp_task.cdb);
return task->ssp_task.cdb;
}


/**
* isci_request_ssp_io_request_get_cdb_length() - This function is called by
* the sci core to retrieve the cdb length for a given request.
* @request: This parameter is the isci_request object.
*
* cdb length for specified request.
*/
u32 isci_request_ssp_io_request_get_cdb_length(
struct isci_request *request)
{
return 16;
}


/**
* isci_request_ssp_io_request_get_lun() - This function is called by the sci
* core to retrieve the lun for a given request.
* @request: This parameter is the isci_request object.
*
* lun for specified request.
*/
u32 isci_request_ssp_io_request_get_lun(
struct isci_request *request)
{
struct sas_task *task = isci_request_access_task(request);

#ifdef DEBUG
int i;

for (i = 0; i < 8; i++)
dev_dbg(&request->isci_host->pdev->dev,
"%s: task->ssp_task.LUN[%d] = %x\n",
__func__, i, task->ssp_task.LUN[i]);

#endif

return task->ssp_task.LUN[0];
}


/**
* isci_request_ssp_io_request_get_task_attribute() - This function is called
* by the sci core to retrieve the task attribute for a given request.
* @request: This parameter is the isci_request object.
*
* task attribute for specified request.
*/
u32 isci_request_ssp_io_request_get_task_attribute(
struct isci_request *request)
{
struct sas_task *task = isci_request_access_task(request);

dev_dbg(&request->isci_host->pdev->dev,
"%s: request->task->ssp_task.task_attr = %x\n",
__func__,
task->ssp_task.task_attr);

return task->ssp_task.task_attr;
}


/**
* isci_request_ssp_io_request_get_command_priority() - This function is called
* by the sci core to retrieve the command priority for a given request.
* @request: This parameter is the isci_request object.
*
* command priority for specified request.
*/
u32 isci_request_ssp_io_request_get_command_priority(
struct isci_request *request)
{
struct sas_task *task = isci_request_access_task(request);

dev_dbg(&request->isci_host->pdev->dev,
"%s: request->task->ssp_task.task_prio = %x\n",
__func__,
task->ssp_task.task_prio);

return task->ssp_task.task_prio;
}
Loading

0 comments on commit 0cfa890

Please sign in to comment.