Commit f4b4216f authored by Bart Van Assche's avatar Bart Van Assche Committed by Martin K. Petersen

scsi: bnx2fc: Stop using the SCSI pointer

Set .cmd_size in the SCSI host template instead of using the SCSI pointer
from struct scsi_cmnd. Remove the CMD_SCSI_STATUS() assignment because the
assigned value is not used.

This patch prepares for removal of the SCSI pointer from struct scsi_cmnd.

Link: https://lore.kernel.org/r/20220218195117.25689-29-bvanassche@acm.orgReviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 5d21aa36
...@@ -137,8 +137,6 @@ ...@@ -137,8 +137,6 @@
#define BNX2FC_FW_TIMEOUT (3 * HZ) #define BNX2FC_FW_TIMEOUT (3 * HZ)
#define PORT_MAX 2 #define PORT_MAX 2
#define CMD_SCSI_STATUS(Cmnd) ((Cmnd)->SCp.Status)
/* FC FCP Status */ /* FC FCP Status */
#define FC_GOOD 0 #define FC_GOOD 0
...@@ -493,7 +491,14 @@ struct bnx2fc_unsol_els { ...@@ -493,7 +491,14 @@ struct bnx2fc_unsol_els {
struct work_struct unsol_els_work; struct work_struct unsol_els_work;
}; };
struct bnx2fc_priv {
struct bnx2fc_cmd *io_req;
};
static inline struct bnx2fc_priv *bnx2fc_priv(struct scsi_cmnd *cmd)
{
return scsi_cmd_priv(cmd);
}
struct bnx2fc_cmd *bnx2fc_cmd_alloc(struct bnx2fc_rport *tgt); struct bnx2fc_cmd *bnx2fc_cmd_alloc(struct bnx2fc_rport *tgt);
struct bnx2fc_cmd *bnx2fc_elstm_alloc(struct bnx2fc_rport *tgt, int type); struct bnx2fc_cmd *bnx2fc_elstm_alloc(struct bnx2fc_rport *tgt, int type);
......
...@@ -2974,6 +2974,7 @@ static struct scsi_host_template bnx2fc_shost_template = { ...@@ -2974,6 +2974,7 @@ static struct scsi_host_template bnx2fc_shost_template = {
.track_queue_depth = 1, .track_queue_depth = 1,
.slave_configure = bnx2fc_slave_configure, .slave_configure = bnx2fc_slave_configure,
.shost_groups = bnx2fc_host_groups, .shost_groups = bnx2fc_host_groups,
.cmd_size = sizeof(struct bnx2fc_priv),
}; };
static struct libfc_function_template bnx2fc_libfc_fcn_templ = { static struct libfc_function_template bnx2fc_libfc_fcn_templ = {
......
...@@ -204,7 +204,7 @@ static void bnx2fc_scsi_done(struct bnx2fc_cmd *io_req, int err_code) ...@@ -204,7 +204,7 @@ static void bnx2fc_scsi_done(struct bnx2fc_cmd *io_req, int err_code)
sc_cmd, host_byte(sc_cmd->result), sc_cmd->retries, sc_cmd, host_byte(sc_cmd->result), sc_cmd->retries,
sc_cmd->allowed); sc_cmd->allowed);
scsi_set_resid(sc_cmd, scsi_bufflen(sc_cmd)); scsi_set_resid(sc_cmd, scsi_bufflen(sc_cmd));
sc_cmd->SCp.ptr = NULL; bnx2fc_priv(sc_cmd)->io_req = NULL;
scsi_done(sc_cmd); scsi_done(sc_cmd);
} }
...@@ -765,7 +765,7 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) ...@@ -765,7 +765,7 @@ static int bnx2fc_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
task = &(task_page[index]); task = &(task_page[index]);
bnx2fc_init_mp_task(io_req, task); bnx2fc_init_mp_task(io_req, task);
sc_cmd->SCp.ptr = (char *)io_req; bnx2fc_priv(sc_cmd)->io_req = io_req;
/* Obtain free SQ entry */ /* Obtain free SQ entry */
spin_lock_bh(&tgt->tgt_lock); spin_lock_bh(&tgt->tgt_lock);
...@@ -1147,7 +1147,7 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd) ...@@ -1147,7 +1147,7 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd)
BNX2FC_TGT_DBG(tgt, "Entered bnx2fc_eh_abort\n"); BNX2FC_TGT_DBG(tgt, "Entered bnx2fc_eh_abort\n");
spin_lock_bh(&tgt->tgt_lock); spin_lock_bh(&tgt->tgt_lock);
io_req = (struct bnx2fc_cmd *)sc_cmd->SCp.ptr; io_req = bnx2fc_priv(sc_cmd)->io_req;
if (!io_req) { if (!io_req) {
/* Command might have just completed */ /* Command might have just completed */
printk(KERN_ERR PFX "eh_abort: io_req is NULL\n"); printk(KERN_ERR PFX "eh_abort: io_req is NULL\n");
...@@ -1572,8 +1572,8 @@ void bnx2fc_process_tm_compl(struct bnx2fc_cmd *io_req, ...@@ -1572,8 +1572,8 @@ void bnx2fc_process_tm_compl(struct bnx2fc_cmd *io_req,
printk(KERN_ERR PFX "tmf's fc_hdr r_ctl = 0x%x\n", printk(KERN_ERR PFX "tmf's fc_hdr r_ctl = 0x%x\n",
fc_hdr->fh_r_ctl); fc_hdr->fh_r_ctl);
} }
if (!sc_cmd->SCp.ptr) { if (!bnx2fc_priv(sc_cmd)->io_req) {
printk(KERN_ERR PFX "tm_compl: SCp.ptr is NULL\n"); printk(KERN_ERR PFX "tm_compl: io_req is NULL\n");
return; return;
} }
switch (io_req->fcp_status) { switch (io_req->fcp_status) {
...@@ -1609,7 +1609,7 @@ void bnx2fc_process_tm_compl(struct bnx2fc_cmd *io_req, ...@@ -1609,7 +1609,7 @@ void bnx2fc_process_tm_compl(struct bnx2fc_cmd *io_req,
return; return;
} }
sc_cmd->SCp.ptr = NULL; bnx2fc_priv(sc_cmd)->io_req = NULL;
scsi_done(sc_cmd); scsi_done(sc_cmd);
kref_put(&io_req->refcount, bnx2fc_cmd_release); kref_put(&io_req->refcount, bnx2fc_cmd_release);
...@@ -1773,8 +1773,7 @@ static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd *io_req, ...@@ -1773,8 +1773,7 @@ static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd *io_req,
io_req->fcp_resid = fcp_rsp->fcp_resid; io_req->fcp_resid = fcp_rsp->fcp_resid;
io_req->scsi_comp_flags = rsp_flags; io_req->scsi_comp_flags = rsp_flags;
CMD_SCSI_STATUS(sc_cmd) = io_req->cdb_status = io_req->cdb_status = fcp_rsp->scsi_status_code;
fcp_rsp->scsi_status_code;
/* Fetch fcp_rsp_info and fcp_sns_info if available */ /* Fetch fcp_rsp_info and fcp_sns_info if available */
if (num_rq) { if (num_rq) {
...@@ -1946,8 +1945,8 @@ void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req, ...@@ -1946,8 +1945,8 @@ void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req,
/* parse fcp_rsp and obtain sense data from RQ if available */ /* parse fcp_rsp and obtain sense data from RQ if available */
bnx2fc_parse_fcp_rsp(io_req, fcp_rsp, num_rq, rq_data); bnx2fc_parse_fcp_rsp(io_req, fcp_rsp, num_rq, rq_data);
if (!sc_cmd->SCp.ptr) { if (!bnx2fc_priv(sc_cmd)->io_req) {
printk(KERN_ERR PFX "SCp.ptr is NULL\n"); printk(KERN_ERR PFX "io_req is NULL\n");
return; return;
} }
...@@ -2018,7 +2017,7 @@ void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req, ...@@ -2018,7 +2017,7 @@ void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req,
io_req->fcp_status); io_req->fcp_status);
break; break;
} }
sc_cmd->SCp.ptr = NULL; bnx2fc_priv(sc_cmd)->io_req = NULL;
scsi_done(sc_cmd); scsi_done(sc_cmd);
kref_put(&io_req->refcount, bnx2fc_cmd_release); kref_put(&io_req->refcount, bnx2fc_cmd_release);
} }
...@@ -2044,7 +2043,7 @@ int bnx2fc_post_io_req(struct bnx2fc_rport *tgt, ...@@ -2044,7 +2043,7 @@ int bnx2fc_post_io_req(struct bnx2fc_rport *tgt,
io_req->port = port; io_req->port = port;
io_req->tgt = tgt; io_req->tgt = tgt;
io_req->data_xfer_len = scsi_bufflen(sc_cmd); io_req->data_xfer_len = scsi_bufflen(sc_cmd);
sc_cmd->SCp.ptr = (char *)io_req; bnx2fc_priv(sc_cmd)->io_req = io_req;
stats = per_cpu_ptr(lport->stats, get_cpu()); stats = per_cpu_ptr(lport->stats, get_cpu());
if (sc_cmd->sc_data_direction == DMA_FROM_DEVICE) { if (sc_cmd->sc_data_direction == DMA_FROM_DEVICE) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment