提交 2ad019fc 编写于 作者: J John Garry 提交者: Xie XiuQi

scsi: Add scsi_prot_op_normal()

It is a common pattern to check if a Scmd prot option is "normal", i.e.
regular IO.

Add a common helper for this and fixup any relevant code to use it.
Signed-off-by: NJohn Garry <john.garry@huawei.com>
上级 1086d1b2
...@@ -526,14 +526,14 @@ int iser_reg_rdma_mem(struct iscsi_iser_task *task, ...@@ -526,14 +526,14 @@ int iser_reg_rdma_mem(struct iscsi_iser_task *task,
int err; int err;
use_dma_key = mem->dma_nents == 1 && (all_imm || !iser_always_reg) && use_dma_key = mem->dma_nents == 1 && (all_imm || !iser_always_reg) &&
scsi_get_prot_op(task->sc) == SCSI_PROT_NORMAL; scsi_prot_op_normal(task->sc);
if (!use_dma_key) { if (!use_dma_key) {
desc = device->reg_ops->reg_desc_get(ib_conn); desc = device->reg_ops->reg_desc_get(ib_conn);
reg->mem_h = desc; reg->mem_h = desc;
} }
if (scsi_get_prot_op(task->sc) == SCSI_PROT_NORMAL) if (scsi_prot_op_normal(task->sc))
data_reg = reg; data_reg = reg;
else else
data_reg = &task->desc.data_reg; data_reg = &task->desc.data_reg;
...@@ -542,7 +542,7 @@ int iser_reg_rdma_mem(struct iscsi_iser_task *task, ...@@ -542,7 +542,7 @@ int iser_reg_rdma_mem(struct iscsi_iser_task *task,
if (unlikely(err)) if (unlikely(err))
goto err_reg; goto err_reg;
if (scsi_get_prot_op(task->sc) != SCSI_PROT_NORMAL) { if (!scsi_prot_op_normal(task->sc)) {
struct iser_mem_reg *prot_reg = &task->desc.prot_reg; struct iser_mem_reg *prot_reg = &task->desc.prot_reg;
if (scsi_prot_sg_count(task->sc)) { if (scsi_prot_sg_count(task->sc)) {
......
...@@ -389,7 +389,7 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task) ...@@ -389,7 +389,7 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
return rc; return rc;
} }
if (scsi_get_prot_op(sc) != SCSI_PROT_NORMAL) if (!scsi_prot_op_normal(sc))
task->protected = true; task->protected = true;
transfer_length = scsi_transfer_length(sc); transfer_length = scsi_transfer_length(sc);
......
...@@ -4087,7 +4087,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, ...@@ -4087,7 +4087,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
if ((lpfc_cmd->result == IOERR_RX_DMA_FAILED || if ((lpfc_cmd->result == IOERR_RX_DMA_FAILED ||
lpfc_cmd->result == IOERR_TX_DMA_FAILED) && lpfc_cmd->result == IOERR_TX_DMA_FAILED) &&
pIocbOut->iocb.unsli3.sli3_bg.bgstat) { pIocbOut->iocb.unsli3.sli3_bg.bgstat) {
if (scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) { if (!scsi_prot_op_normal(cmd)) {
/* /*
* This is a response for a BG enabled * This is a response for a BG enabled
* cmd. Parse BG error * cmd. Parse BG error
...@@ -4568,7 +4568,7 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd) ...@@ -4568,7 +4568,7 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)
} }
ndlp = rdata->pnode; ndlp = rdata->pnode;
if ((scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) && if (!scsi_prot_op_normal(cmnd) &&
(!(phba->sli3_options & LPFC_SLI3_BG_ENABLED))) { (!(phba->sli3_options & LPFC_SLI3_BG_ENABLED))) {
lpfc_printf_log(phba, KERN_ERR, LOG_BG, lpfc_printf_log(phba, KERN_ERR, LOG_BG,
...@@ -4638,7 +4638,7 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd) ...@@ -4638,7 +4638,7 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)
lpfc_cmd->start_time = jiffies; lpfc_cmd->start_time = jiffies;
cmnd->host_scribble = (unsigned char *)lpfc_cmd; cmnd->host_scribble = (unsigned char *)lpfc_cmd;
if (scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) { if (!scsi_prot_op_normal(cmnd)) {
if (vport->phba->cfg_enable_bg) { if (vport->phba->cfg_enable_bg) {
lpfc_printf_vlog(vport, lpfc_printf_vlog(vport,
KERN_INFO, LOG_SCSI_CMD, KERN_INFO, LOG_SCSI_CMD,
......
...@@ -1569,7 +1569,7 @@ qla24xx_dif_start_scsi(srb_t *sp) ...@@ -1569,7 +1569,7 @@ qla24xx_dif_start_scsi(srb_t *sp)
#define QDSS_GOT_Q_SPACE BIT_0 #define QDSS_GOT_Q_SPACE BIT_0
/* Only process protection or >16 cdb in this routine */ /* Only process protection or >16 cdb in this routine */
if (scsi_get_prot_op(cmd) == SCSI_PROT_NORMAL) { if (scsi_prot_op_normal(cmd)) {
if (cmd->cmd_len <= 16) if (cmd->cmd_len <= 16)
return qla24xx_start_scsi(sp); return qla24xx_start_scsi(sp);
} }
...@@ -1918,13 +1918,13 @@ qla2xxx_dif_start_scsi_mq(srb_t *sp) ...@@ -1918,13 +1918,13 @@ qla2xxx_dif_start_scsi_mq(srb_t *sp)
} }
if (!qpair->difdix_supported && if (!qpair->difdix_supported &&
scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) { !scsi_prot_op_normal(cmd)) {
cmd->result = DID_NO_CONNECT << 16; cmd->result = DID_NO_CONNECT << 16;
return QLA_INTERFACE_ERROR; return QLA_INTERFACE_ERROR;
} }
/* Only process protection or >16 cdb in this routine */ /* Only process protection or >16 cdb in this routine */
if (scsi_get_prot_op(cmd) == SCSI_PROT_NORMAL) { if (scsi_prot_op_normal(cmd)) {
if (cmd->cmd_len <= 16) if (cmd->cmd_len <= 16)
return qla2xxx_start_scsi_mq(sp); return qla2xxx_start_scsi_mq(sp);
} }
......
...@@ -889,7 +889,7 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) ...@@ -889,7 +889,7 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
} }
if (!vha->flags.difdix_supported && if (!vha->flags.difdix_supported &&
scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) { !scsi_prot_op_normal(cmd)) {
ql_dbg(ql_dbg_io, vha, 0x3004, ql_dbg(ql_dbg_io, vha, 0x3004,
"DIF Cap not reg, fail DIF capable cmd's:%p.\n", "DIF Cap not reg, fail DIF capable cmd's:%p.\n",
cmd); cmd);
......
...@@ -271,6 +271,11 @@ static inline unsigned char scsi_get_prot_op(struct scsi_cmnd *scmd) ...@@ -271,6 +271,11 @@ static inline unsigned char scsi_get_prot_op(struct scsi_cmnd *scmd)
return scmd->prot_op; return scmd->prot_op;
} }
static inline bool scsi_prot_op_normal(struct scsi_cmnd *scmd)
{
return scmd->prot_op == SCSI_PROT_NORMAL;
}
enum scsi_prot_flags { enum scsi_prot_flags {
SCSI_PROT_TRANSFER_PI = 1 << 0, SCSI_PROT_TRANSFER_PI = 1 << 0,
SCSI_PROT_GUARD_CHECK = 1 << 1, SCSI_PROT_GUARD_CHECK = 1 << 1,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册