Skip to content

Commit

Permalink
scsi: remove abuses of scsi_populate_tag
Browse files Browse the repository at this point in the history
Unless we want to build a SPI tag message we should just check SCMD_TAGGED
instead of reverse engineering a tag type through the use of
scsi_populate_tag_msg.

Also rename the function to spi_populate_tag_msg, make it behave like the
other spi message helpers, and move it to the spi transport class.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Mike Christie <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
  • Loading branch information
Christoph Hellwig committed Nov 12, 2014
1 parent abd0c53 commit 5066863
Show file tree
Hide file tree
Showing 19 changed files with 56 additions and 311 deletions.
14 changes: 1 addition & 13 deletions drivers/s390/scsi/zfcp_fc.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,26 +212,14 @@ static inline
void zfcp_fc_scsi_to_fcp(struct fcp_cmnd *fcp, struct scsi_cmnd *scsi,
u8 tm_flags)
{
char tag[2];

int_to_scsilun(scsi->device->lun, (struct scsi_lun *) &fcp->fc_lun);

if (unlikely(tm_flags)) {
fcp->fc_tm_flags = tm_flags;
return;
}

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;
fcp->fc_pri_ta = FCP_PTA_SIMPLE;

if (scsi->sc_data_direction == DMA_FROM_DEVICE)
fcp->fc_flags |= FCP_CFL_RDDATA;
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/53c700.c
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ NCR_700_start_command(struct scsi_cmnd *SCp)
if((hostdata->tag_negotiated & (1<<scmd_id(SCp)))
&& (slot->tag != SCSI_NO_TAG && SCp->cmnd[0] != REQUEST_SENSE &&
slot->flags != NCR_700_FLAG_AUTOSENSE)) {
count += scsi_populate_tag_msg(SCp, &hostdata->msgout[count]);
count += spi_populate_tag_msg(&hostdata->msgout[count], SCp);
}

if(hostdata->fast &&
Expand Down
9 changes: 0 additions & 9 deletions drivers/scsi/aic7xxx/aic79xx_osm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1619,15 +1619,6 @@ ahd_linux_run_command(struct ahd_softc *ahd, struct ahd_linux_device *dev,
}

if ((dev->flags & (AHD_DEV_Q_TAGGED|AHD_DEV_Q_BASIC)) != 0) {
int msg_bytes;
uint8_t tag_msgs[2];

msg_bytes = scsi_populate_tag_msg(cmd, tag_msgs);
if (msg_bytes && tag_msgs[0] != MSG_SIMPLE_TASK) {
hscb->control |= tag_msgs[0];
if (tag_msgs[0] == MSG_ORDERED_TASK)
dev->commands_since_idle_or_otag = 0;
} else
if (dev->commands_since_idle_or_otag == AHD_OTAG_THRESH
&& (dev->flags & AHD_DEV_Q_TAGGED) != 0) {
hscb->control |= MSG_ORDERED_TASK;
Expand Down
10 changes: 1 addition & 9 deletions drivers/scsi/aic7xxx/aic7xxx_osm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1501,15 +1501,7 @@ ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev,
}

if ((dev->flags & (AHC_DEV_Q_TAGGED|AHC_DEV_Q_BASIC)) != 0) {
int msg_bytes;
uint8_t tag_msgs[2];

msg_bytes = scsi_populate_tag_msg(cmd, tag_msgs);
if (msg_bytes && tag_msgs[0] != MSG_SIMPLE_TASK) {
hscb->control |= tag_msgs[0];
if (tag_msgs[0] == MSG_ORDERED_TASK)
dev->commands_since_idle_or_otag = 0;
} else if (dev->commands_since_idle_or_otag == AHC_OTAG_THRESH
if (dev->commands_since_idle_or_otag == AHC_OTAG_THRESH
&& (dev->flags & AHC_DEV_Q_TAGGED) != 0) {
hscb->control |= MSG_ORDERED_TASK;
dev->commands_since_idle_or_otag = 0;
Expand Down
18 changes: 3 additions & 15 deletions drivers/scsi/bnx2fc/bnx2fc_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,6 @@ void bnx2fc_build_fcp_cmnd(struct bnx2fc_cmd *io_req,
struct fcp_cmnd *fcp_cmnd)
{
struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
char tag[2];

memset(fcp_cmnd, 0, sizeof(struct fcp_cmnd));

Expand All @@ -1739,21 +1738,10 @@ void bnx2fc_build_fcp_cmnd(struct bnx2fc_cmd *io_req,
fcp_cmnd->fc_tm_flags = io_req->mp_req.tm_flags;
fcp_cmnd->fc_flags = io_req->io_req_flags;

if (scsi_populate_tag_msg(sc_cmd, tag)) {
switch (tag[0]) {
case HEAD_OF_QUEUE_TAG:
fcp_cmnd->fc_pri_ta = FCP_PTA_HEADQ;
break;
case ORDERED_QUEUE_TAG:
fcp_cmnd->fc_pri_ta = FCP_PTA_ORDERED;
break;
default:
fcp_cmnd->fc_pri_ta = FCP_PTA_SIMPLE;
break;
}
} else {
if (sc_cmd->flags & SCMD_TAGGED)
fcp_cmnd->fc_pri_ta = FCP_PTA_SIMPLE;
else
fcp_cmnd->fc_pri_ta = 0;
}
}

static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd *io_req,
Expand Down
29 changes: 4 additions & 25 deletions drivers/scsi/csiostor/csio_scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,28 +152,6 @@ csio_scsi_itnexus_loss_error(uint16_t error)
return 0;
}

static inline void
csio_scsi_tag(struct scsi_cmnd *scmnd, uint8_t *tag, uint8_t hq,
uint8_t oq, uint8_t sq)
{
char stag[2];

if (scsi_populate_tag_msg(scmnd, stag)) {
switch (stag[0]) {
case HEAD_OF_QUEUE_TAG:
*tag = hq;
break;
case ORDERED_QUEUE_TAG:
*tag = oq;
break;
default:
*tag = sq;
break;
}
} else
*tag = 0;
}

/*
* csio_scsi_fcp_cmnd - Frame the SCSI FCP command paylod.
* @req: IO req structure.
Expand All @@ -192,11 +170,12 @@ csio_scsi_fcp_cmnd(struct csio_ioreq *req, void *addr)
int_to_scsilun(scmnd->device->lun, &fcp_cmnd->fc_lun);
fcp_cmnd->fc_tm_flags = 0;
fcp_cmnd->fc_cmdref = 0;
fcp_cmnd->fc_pri_ta = 0;

memcpy(fcp_cmnd->fc_cdb, scmnd->cmnd, 16);
csio_scsi_tag(scmnd, &fcp_cmnd->fc_pri_ta,
FCP_PTA_HEADQ, FCP_PTA_ORDERED, FCP_PTA_SIMPLE);
if (scmnd->flags & SCMD_TAGGED)
fcp_cmnd->fc_pri_ta = FCP_PTA_SIMPLE;
else
fcp_cmnd->fc_pri_ta = 0;
fcp_cmnd->fc_dl = cpu_to_be32(scsi_bufflen(scmnd));

if (req->nsge)
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/esp_scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ static struct esp_cmd_entry *find_and_prep_issuable_command(struct esp *esp)
return ent;
}

if (!scsi_populate_tag_msg(cmd, &ent->tag[0])) {
if (!spi_populate_tag_msg(&ent->tag[0], cmd)) {
ent->tag[0] = 0;
ent->tag[1] = 0;
}
Expand Down
11 changes: 2 additions & 9 deletions drivers/scsi/fnic/fnic_scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,11 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic,
struct fc_rport_libfc_priv *rp = rport->dd_data;
struct host_sg_desc *desc;
struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats;
u8 pri_tag = 0;
unsigned int i;
unsigned long intr_flags;
int flags;
u8 exch_flags;
struct scsi_lun fc_lun;
char msg[2];

if (sg_count) {
/* For each SGE, create a device desc entry */
Expand All @@ -357,12 +355,6 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic,

int_to_scsilun(sc->device->lun, &fc_lun);

pri_tag = FCPIO_ICMND_PTA_SIMPLE;
msg[0] = MSG_SIMPLE_TAG;
scsi_populate_tag_msg(sc, msg);
if (msg[0] == MSG_ORDERED_TAG)
pri_tag = FCPIO_ICMND_PTA_ORDERED;

/* Enqueue the descriptor in the Copy WQ */
spin_lock_irqsave(&fnic->wq_copy_lock[0], intr_flags);

Expand Down Expand Up @@ -394,7 +386,8 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic,
io_req->sgl_list_pa,
io_req->sense_buf_pa,
0, /* scsi cmd ref, always 0 */
pri_tag, /* scsi pri and tag */
FCPIO_ICMND_PTA_SIMPLE,
/* scsi pri and tag */
flags, /* command flags */
sc->cmnd, sc->cmd_len,
scsi_bufflen(sc),
Expand Down
16 changes: 3 additions & 13 deletions drivers/scsi/ibmvscsi/ibmvfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1643,19 +1643,9 @@ static int ibmvfc_queuecommand_lck(struct scsi_cmnd *cmnd,
int_to_scsilun(cmnd->device->lun, &vfc_cmd->iu.lun);
memcpy(vfc_cmd->iu.cdb, cmnd->cmnd, cmnd->cmd_len);

if (scsi_populate_tag_msg(cmnd, tag)) {
vfc_cmd->task_tag = cpu_to_be64(tag[1]);
switch (tag[0]) {
case MSG_SIMPLE_TAG:
vfc_cmd->iu.pri_task_attr = IBMVFC_SIMPLE_TASK;
break;
case MSG_HEAD_TAG:
vfc_cmd->iu.pri_task_attr = IBMVFC_HEAD_OF_QUEUE;
break;
case MSG_ORDERED_TAG:
vfc_cmd->iu.pri_task_attr = IBMVFC_ORDERED_TASK;
break;
};
if (cmnd->flags & SCMD_TAGGED) {
vfc_cmd->task_tag = cpu_to_be64(cmnd->tag);
vfc_cmd->iu.pri_task_attr = IBMVFC_SIMPLE_TASK;
}

if (likely(!(rc = ibmvfc_map_sg_data(cmnd, evt, vfc_cmd, vhost->dev))))
Expand Down
34 changes: 4 additions & 30 deletions drivers/scsi/ipr.c
Original file line number Diff line number Diff line change
Expand Up @@ -5658,35 +5658,6 @@ static int ipr_build_ioadl(struct ipr_ioa_cfg *ioa_cfg,
return 0;
}

/**
* ipr_get_task_attributes - Translate SPI Q-Tag to task attributes
* @scsi_cmd: scsi command struct
*
* Return value:
* task attributes
**/
static u8 ipr_get_task_attributes(struct scsi_cmnd *scsi_cmd)
{
u8 tag[2];
u8 rc = IPR_FLAGS_LO_UNTAGGED_TASK;

if (scsi_populate_tag_msg(scsi_cmd, tag)) {
switch (tag[0]) {
case MSG_SIMPLE_TAG:
rc = IPR_FLAGS_LO_SIMPLE_TASK;
break;
case MSG_HEAD_TAG:
rc = IPR_FLAGS_LO_HEAD_OF_Q_TASK;
break;
case MSG_ORDERED_TAG:
rc = IPR_FLAGS_LO_ORDERED_TASK;
break;
};
}

return rc;
}

/**
* ipr_erp_done - Process completion of ERP for a device
* @ipr_cmd: ipr command struct
Expand Down Expand Up @@ -6222,7 +6193,10 @@ static int ipr_queuecommand(struct Scsi_Host *shost,
ioarcb->cmd_pkt.flags_lo |= IPR_FLAGS_LO_DELAY_AFTER_RST;
}
ioarcb->cmd_pkt.flags_lo |= IPR_FLAGS_LO_ALIGNED_BFR;
ioarcb->cmd_pkt.flags_lo |= ipr_get_task_attributes(scsi_cmd);
if (scsi_cmd->flags & SCMD_TAGGED)
ioarcb->cmd_pkt.flags_lo |= IPR_FLAGS_LO_SIMPLE_TASK;
else
ioarcb->cmd_pkt.flags_lo |= IPR_FLAGS_LO_UNTAGGED_TASK;
}

if (scsi_cmd->cmnd[0] >= 0xC0 &&
Expand Down
16 changes: 1 addition & 15 deletions drivers/scsi/lpfc/lpfc_scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -4266,7 +4266,6 @@ lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb;
struct lpfc_iocbq *piocbq = &(lpfc_cmd->cur_iocbq);
int datadir = scsi_cmnd->sc_data_direction;
char tag[2];
uint8_t *ptr;
bool sli4;
uint32_t fcpdl;
Expand All @@ -4288,20 +4287,7 @@ lpfc_scsi_prep_cmnd(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
memset(ptr, 0, (LPFC_FCP_CDB_LEN - scsi_cmnd->cmd_len));
}

if (scsi_populate_tag_msg(scsi_cmnd, tag)) {
switch (tag[0]) {
case HEAD_OF_QUEUE_TAG:
fcp_cmnd->fcpCntl1 = HEAD_OF_Q;
break;
case ORDERED_QUEUE_TAG:
fcp_cmnd->fcpCntl1 = ORDERED_Q;
break;
default:
fcp_cmnd->fcpCntl1 = SIMPLE_Q;
break;
}
} else
fcp_cmnd->fcpCntl1 = SIMPLE_Q;
fcp_cmnd->fcpCntl1 = SIMPLE_Q;

sli4 = (phba->sli_rev == LPFC_SLI_REV4);
piocbq->iocb.un.fcpi.fcpi_XRdy = 0;
Expand Down
34 changes: 3 additions & 31 deletions drivers/scsi/pmcraid.c
Original file line number Diff line number Diff line change
Expand Up @@ -3168,36 +3168,6 @@ static int pmcraid_eh_host_reset_handler(struct scsi_cmnd *scmd)
return pmcraid_reset_bringup(pinstance) == 0 ? SUCCESS : FAILED;
}

/**
* pmcraid_task_attributes - Translate SPI Q-Tags to task attributes
* @scsi_cmd: scsi command struct
*
* Return value
* number of tags or 0 if the task is not tagged
*/
static u8 pmcraid_task_attributes(struct scsi_cmnd *scsi_cmd)
{
char tag[2];
u8 rc = 0;

if (scsi_populate_tag_msg(scsi_cmd, tag)) {
switch (tag[0]) {
case MSG_SIMPLE_TAG:
rc = TASK_TAG_SIMPLE;
break;
case MSG_HEAD_TAG:
rc = TASK_TAG_QUEUE_HEAD;
break;
case MSG_ORDERED_TAG:
rc = TASK_TAG_ORDERED;
break;
};
}

return rc;
}


/**
* pmcraid_init_ioadls - initializes IOADL related fields in IOARCB
* @cmd: pmcraid command struct
Expand Down Expand Up @@ -3553,7 +3523,9 @@ static int pmcraid_queuecommand_lck(
}

ioarcb->request_flags0 |= NO_LINK_DESCS;
ioarcb->request_flags1 |= pmcraid_task_attributes(scsi_cmd);

if (scsi_cmd->flags & SCMD_TAGGED)
ioarcb->request_flags1 |= TASK_TAG_SIMPLE;

if (RES_IS_GSCSI(res->cfg_entry))
ioarcb->request_flags1 |= DELAY_AFTER_RESET;
Expand Down
Loading

0 comments on commit 5066863

Please sign in to comment.