-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SCSI] zfcp: Update FCP protocol related code
Use common data structures for FCP CMND, FCP RSP and related definitions and remove zfcp private definitions. Split the FCP CMND setup and FCP RSP evaluation code in seperate functions. Use inline functions to not negatively impact the I/O path. Reviewed-by: Swen Schillig <swen@vnet.ibm.com> Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
- Loading branch information
Christof Schmitt
authored and
James Bottomley
committed
Dec 4, 2009
1 parent
8830271
commit 4318e08
Showing
7 changed files
with
156 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* zfcp device driver | ||
* | ||
* Fibre Channel related definitions and inline functions for the zfcp | ||
* device driver | ||
* | ||
* Copyright IBM Corporation 2009 | ||
*/ | ||
|
||
#ifndef ZFCP_FC_H | ||
#define ZFCP_FC_H | ||
|
||
#include <scsi/fc/fc_fcp.h> | ||
#include <scsi/scsi_cmnd.h> | ||
#include <scsi/scsi_tcq.h> | ||
|
||
/** | ||
* zfcp_fc_scsi_to_fcp - setup FCP command with data from scsi_cmnd | ||
* @fcp: fcp_cmnd to setup | ||
* @scsi: scsi_cmnd where to get LUN, task attributes/flags and CDB | ||
*/ | ||
static inline | ||
void zfcp_fc_scsi_to_fcp(struct fcp_cmnd *fcp, struct scsi_cmnd *scsi) | ||
{ | ||
char tag[2]; | ||
|
||
int_to_scsilun(scsi->device->lun, (struct scsi_lun *) &fcp->fc_lun); | ||
|
||
if (scsi_populate_tag_msg(scsi, tag)) { | ||
switch (tag[0]) { | ||
case MSG_ORDERED_TAG: | ||
fcp->fc_pri_ta |= FCP_PTA_ORDERED; | ||
break; | ||
case MSG_SIMPLE_TAG: | ||
fcp->fc_pri_ta |= FCP_PTA_SIMPLE; | ||
break; | ||
}; | ||
} else | ||
fcp->fc_pri_ta = FCP_PTA_SIMPLE; | ||
|
||
if (scsi->sc_data_direction == DMA_FROM_DEVICE) | ||
fcp->fc_flags |= FCP_CFL_RDDATA; | ||
if (scsi->sc_data_direction == DMA_TO_DEVICE) | ||
fcp->fc_flags |= FCP_CFL_WRDATA; | ||
|
||
memcpy(fcp->fc_cdb, scsi->cmnd, scsi->cmd_len); | ||
|
||
fcp->fc_dl = scsi_bufflen(scsi); | ||
} | ||
|
||
/** | ||
* zfcp_fc_fcp_tm - setup FCP command as task management command | ||
* @fcp: fcp_cmnd to setup | ||
* @dev: scsi_device where to send the task management command | ||
* @tm: task management flags to setup tm command | ||
*/ | ||
static inline | ||
void zfcp_fc_fcp_tm(struct fcp_cmnd *fcp, struct scsi_device *dev, u8 tm_flags) | ||
{ | ||
int_to_scsilun(dev->lun, (struct scsi_lun *) &fcp->fc_lun); | ||
fcp->fc_tm_flags |= tm_flags; | ||
} | ||
|
||
/** | ||
* zfcp_fc_evap_fcp_rsp - evaluate FCP RSP IU and update scsi_cmnd accordingly | ||
* @fcp_rsp: FCP RSP IU to evaluate | ||
* @scsi: SCSI command where to update status and sense buffer | ||
*/ | ||
static inline | ||
void zfcp_fc_eval_fcp_rsp(struct fcp_resp_with_ext *fcp_rsp, | ||
struct scsi_cmnd *scsi) | ||
{ | ||
struct fcp_resp_rsp_info *rsp_info; | ||
char *sense; | ||
u32 sense_len, resid; | ||
u8 rsp_flags; | ||
|
||
set_msg_byte(scsi, COMMAND_COMPLETE); | ||
scsi->result |= fcp_rsp->resp.fr_status; | ||
|
||
rsp_flags = fcp_rsp->resp.fr_flags; | ||
|
||
if (unlikely(rsp_flags & FCP_RSP_LEN_VAL)) { | ||
rsp_info = (struct fcp_resp_rsp_info *) &fcp_rsp[1]; | ||
if (rsp_info->rsp_code == FCP_TMF_CMPL) | ||
set_host_byte(scsi, DID_OK); | ||
else { | ||
set_host_byte(scsi, DID_ERROR); | ||
return; | ||
} | ||
} | ||
|
||
if (unlikely(rsp_flags & FCP_SNS_LEN_VAL)) { | ||
sense = (char *) &fcp_rsp[1]; | ||
if (rsp_flags & FCP_RSP_LEN_VAL) | ||
sense += fcp_rsp->ext.fr_sns_len; | ||
sense_len = min(fcp_rsp->ext.fr_sns_len, | ||
(u32) SCSI_SENSE_BUFFERSIZE); | ||
memcpy(scsi->sense_buffer, sense, sense_len); | ||
} | ||
|
||
if (unlikely(rsp_flags & FCP_RESID_UNDER)) { | ||
resid = fcp_rsp->ext.fr_resid; | ||
scsi_set_resid(scsi, resid); | ||
if (scsi_bufflen(scsi) - resid < scsi->underflow && | ||
!(rsp_flags & FCP_SNS_LEN_VAL) && | ||
fcp_rsp->resp.fr_status == SAM_STAT_GOOD) | ||
set_host_byte(scsi, DID_ERROR); | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.