Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 38972
b: refs/heads/master
c: b1df99d
h: refs/heads/master
v: v3
  • Loading branch information
Sumant Patro authored and James Bottomley committed Oct 4, 2006
1 parent 3a23692 commit ec20974
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 26 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e3bbff9f3cf91c84c76cfdd5e80041ad1b487192
refs/heads/master: b1df99d9434edf3fc26f9e36ee6a443e3611e829
72 changes: 47 additions & 25 deletions trunk/drivers/scsi/megaraid/megaraid_sas.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,46 @@ megasas_make_sgl64(struct megasas_instance *instance, struct scsi_cmnd *scp,
return sge_count;
}

/**
* megasas_get_frame_count - Computes the number of frames
* @sge_count : number of sg elements
*
* Returns the number of frames required for numnber of sge's (sge_count)
*/

u32 megasas_get_frame_count(u8 sge_count)
{
int num_cnt;
int sge_bytes;
u32 sge_sz;
u32 frame_count=0;

sge_sz = (IS_DMA64) ? sizeof(struct megasas_sge64) :
sizeof(struct megasas_sge32);

/*
* Main frame can contain 2 SGEs for 64-bit SGLs and
* 3 SGEs for 32-bit SGLs
*/
if (IS_DMA64)
num_cnt = sge_count - 2;
else
num_cnt = sge_count - 3;

if(num_cnt>0){
sge_bytes = sge_sz * num_cnt;

frame_count = (sge_bytes / MEGAMFI_FRAME_SIZE) +
((sge_bytes % MEGAMFI_FRAME_SIZE) ? 1 : 0) ;
}
/* Main frame */
frame_count +=1;

if (frame_count > 7)
frame_count = 8;
return frame_count;
}

/**
* megasas_build_dcdb - Prepares a direct cdb (DCDB) command
* @instance: Adapter soft state
Expand All @@ -508,8 +548,6 @@ static int
megasas_build_dcdb(struct megasas_instance *instance, struct scsi_cmnd *scp,
struct megasas_cmd *cmd)
{
u32 sge_sz;
int sge_bytes;
u32 is_logical;
u32 device_id;
u16 flags = 0;
Expand Down Expand Up @@ -544,9 +582,6 @@ megasas_build_dcdb(struct megasas_instance *instance, struct scsi_cmnd *scp,
/*
* Construct SGL
*/
sge_sz = (IS_DMA64) ? sizeof(struct megasas_sge64) :
sizeof(struct megasas_sge32);

if (IS_DMA64) {
pthru->flags |= MFI_FRAME_SGL64;
pthru->sge_count = megasas_make_sgl64(instance, scp,
Expand All @@ -562,17 +597,11 @@ megasas_build_dcdb(struct megasas_instance *instance, struct scsi_cmnd *scp,
pthru->sense_buf_phys_addr_hi = 0;
pthru->sense_buf_phys_addr_lo = cmd->sense_phys_addr;

sge_bytes = sge_sz * pthru->sge_count;

/*
* Compute the total number of frames this command consumes. FW uses
* this number to pull sufficient number of frames from host memory.
*/
cmd->frame_count = (sge_bytes / MEGAMFI_FRAME_SIZE) +
((sge_bytes % MEGAMFI_FRAME_SIZE) ? 1 : 0) + 1;

if (cmd->frame_count > 7)
cmd->frame_count = 8;
cmd->frame_count = megasas_get_frame_count(pthru->sge_count);

return cmd->frame_count;
}
Expand All @@ -589,8 +618,6 @@ static int
megasas_build_ldio(struct megasas_instance *instance, struct scsi_cmnd *scp,
struct megasas_cmd *cmd)
{
u32 sge_sz;
int sge_bytes;
u32 device_id;
u8 sc = scp->cmnd[0];
u16 flags = 0;
Expand All @@ -605,7 +632,7 @@ megasas_build_ldio(struct megasas_instance *instance, struct scsi_cmnd *scp,
flags = MFI_FRAME_DIR_READ;

/*
* Preare the Logical IO frame: 2nd bit is zero for all read cmds
* Prepare the Logical IO frame: 2nd bit is zero for all read cmds
*/
ldio->cmd = (sc & 0x02) ? MFI_CMD_LD_WRITE : MFI_CMD_LD_READ;
ldio->cmd_status = 0x0;
Expand Down Expand Up @@ -674,9 +701,6 @@ megasas_build_ldio(struct megasas_instance *instance, struct scsi_cmnd *scp,
/*
* Construct SGL
*/
sge_sz = (IS_DMA64) ? sizeof(struct megasas_sge64) :
sizeof(struct megasas_sge32);

if (IS_DMA64) {
ldio->flags |= MFI_FRAME_SGL64;
ldio->sge_count = megasas_make_sgl64(instance, scp, &ldio->sgl);
Expand All @@ -690,13 +714,11 @@ megasas_build_ldio(struct megasas_instance *instance, struct scsi_cmnd *scp,
ldio->sense_buf_phys_addr_hi = 0;
ldio->sense_buf_phys_addr_lo = cmd->sense_phys_addr;

sge_bytes = sge_sz * ldio->sge_count;

cmd->frame_count = (sge_bytes / MEGAMFI_FRAME_SIZE) +
((sge_bytes % MEGAMFI_FRAME_SIZE) ? 1 : 0) + 1;

if (cmd->frame_count > 7)
cmd->frame_count = 8;
/*
* Compute the total number of frames this command consumes. FW uses
* this number to pull sufficient number of frames from host memory.
*/
cmd->frame_count = megasas_get_frame_count(ldio->sge_count);

return cmd->frame_count;
}
Expand Down

0 comments on commit ec20974

Please sign in to comment.