Commit ade4fb94 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Martin K. Petersen

scsi: qedf: Use FC rport as argument for qedf_initiate_tmf()

When sending a TMF we're only concerned with the rport and the LUN ID, so
use struct fc_rport as argument for qedf_initiate_tmf().
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/r/20231002154328.43718-5-hare@suse.de
Cc: Saurav Kashyap <skashyap@marvell.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 17865dc2
...@@ -112,6 +112,7 @@ struct qedf_ioreq { ...@@ -112,6 +112,7 @@ struct qedf_ioreq {
#define QEDF_CMD_ERR_SCSI_DONE 0x5 #define QEDF_CMD_ERR_SCSI_DONE 0x5
u8 io_req_flags; u8 io_req_flags;
uint8_t tm_flags; uint8_t tm_flags;
u64 tm_lun;
struct qedf_rport *fcport; struct qedf_rport *fcport;
#define QEDF_CMD_ST_INACTIVE 0 #define QEDF_CMD_ST_INACTIVE 0
#define QEDFC_CMD_ST_IO_ACTIVE 1 #define QEDFC_CMD_ST_IO_ACTIVE 1
...@@ -497,7 +498,7 @@ extern void qedf_process_warning_compl(struct qedf_ctx *qedf, ...@@ -497,7 +498,7 @@ extern void qedf_process_warning_compl(struct qedf_ctx *qedf,
struct fcoe_cqe *cqe, struct qedf_ioreq *io_req); struct fcoe_cqe *cqe, struct qedf_ioreq *io_req);
extern void qedf_process_error_detect(struct qedf_ctx *qedf, extern void qedf_process_error_detect(struct qedf_ctx *qedf,
struct fcoe_cqe *cqe, struct qedf_ioreq *io_req); struct fcoe_cqe *cqe, struct qedf_ioreq *io_req);
extern void qedf_flush_active_ios(struct qedf_rport *fcport, int lun); extern void qedf_flush_active_ios(struct qedf_rport *fcport, u64 lun);
extern void qedf_release_cmd(struct kref *ref); extern void qedf_release_cmd(struct kref *ref);
extern int qedf_initiate_abts(struct qedf_ioreq *io_req, extern int qedf_initiate_abts(struct qedf_ioreq *io_req,
bool return_scsi_cmd_on_abts); bool return_scsi_cmd_on_abts);
...@@ -522,7 +523,7 @@ extern int qedf_initiate_cleanup(struct qedf_ioreq *io_req, ...@@ -522,7 +523,7 @@ extern int qedf_initiate_cleanup(struct qedf_ioreq *io_req,
bool return_scsi_cmd_on_abts); bool return_scsi_cmd_on_abts);
extern void qedf_process_cleanup_compl(struct qedf_ctx *qedf, extern void qedf_process_cleanup_compl(struct qedf_ctx *qedf,
struct fcoe_cqe *cqe, struct qedf_ioreq *io_req); struct fcoe_cqe *cqe, struct qedf_ioreq *io_req);
extern int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags); extern int qedf_initiate_tmf(struct fc_rport *rport, u64 lun, u8 tm_flags);
extern void qedf_process_tmf_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, extern void qedf_process_tmf_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe,
struct qedf_ioreq *io_req); struct qedf_ioreq *io_req);
extern void qedf_process_cqe(struct qedf_ctx *qedf, struct fcoe_cqe *cqe); extern void qedf_process_cqe(struct qedf_ctx *qedf, struct fcoe_cqe *cqe);
......
...@@ -546,7 +546,7 @@ static int qedf_build_bd_list_from_sg(struct qedf_ioreq *io_req) ...@@ -546,7 +546,7 @@ static int qedf_build_bd_list_from_sg(struct qedf_ioreq *io_req)
} }
static void qedf_build_fcp_cmnd(struct qedf_ioreq *io_req, static void qedf_build_fcp_cmnd(struct qedf_ioreq *io_req,
struct fcp_cmnd *fcp_cmnd) struct fcp_cmnd *fcp_cmnd)
{ {
struct scsi_cmnd *sc_cmd = io_req->sc_cmd; struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
...@@ -554,8 +554,12 @@ static void qedf_build_fcp_cmnd(struct qedf_ioreq *io_req, ...@@ -554,8 +554,12 @@ static void qedf_build_fcp_cmnd(struct qedf_ioreq *io_req,
memset(fcp_cmnd, 0, FCP_CMND_LEN); memset(fcp_cmnd, 0, FCP_CMND_LEN);
/* 8 bytes: SCSI LUN info */ /* 8 bytes: SCSI LUN info */
int_to_scsilun(sc_cmd->device->lun, if (io_req->cmd_type == QEDF_TASK_MGMT_CMD)
(struct scsi_lun *)&fcp_cmnd->fc_lun); int_to_scsilun(io_req->tm_lun,
(struct scsi_lun *)&fcp_cmnd->fc_lun);
else
int_to_scsilun(sc_cmd->device->lun,
(struct scsi_lun *)&fcp_cmnd->fc_lun);
/* 4 bytes: flag info */ /* 4 bytes: flag info */
fcp_cmnd->fc_pri_ta = 0; fcp_cmnd->fc_pri_ta = 0;
...@@ -1095,7 +1099,7 @@ static void qedf_parse_fcp_rsp(struct qedf_ioreq *io_req, ...@@ -1095,7 +1099,7 @@ static void qedf_parse_fcp_rsp(struct qedf_ioreq *io_req,
} }
/* The sense buffer can be NULL for TMF commands */ /* The sense buffer can be NULL for TMF commands */
if (sc_cmd->sense_buffer) { if (sc_cmd && sc_cmd->sense_buffer) {
memset(sc_cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); memset(sc_cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
if (fcp_sns_len) if (fcp_sns_len)
memcpy(sc_cmd->sense_buffer, sense_data, memcpy(sc_cmd->sense_buffer, sense_data,
...@@ -1580,7 +1584,7 @@ static void qedf_flush_els_req(struct qedf_ctx *qedf, ...@@ -1580,7 +1584,7 @@ static void qedf_flush_els_req(struct qedf_ctx *qedf,
/* A value of -1 for lun is a wild card that means flush all /* A value of -1 for lun is a wild card that means flush all
* active SCSI I/Os for the target. * active SCSI I/Os for the target.
*/ */
void qedf_flush_active_ios(struct qedf_rport *fcport, int lun) void qedf_flush_active_ios(struct qedf_rport *fcport, u64 lun)
{ {
struct qedf_ioreq *io_req; struct qedf_ioreq *io_req;
struct qedf_ctx *qedf; struct qedf_ctx *qedf;
...@@ -1768,10 +1772,6 @@ void qedf_flush_active_ios(struct qedf_rport *fcport, int lun) ...@@ -1768,10 +1772,6 @@ void qedf_flush_active_ios(struct qedf_rport *fcport, int lun)
kref_put(&io_req->refcount, qedf_release_cmd); kref_put(&io_req->refcount, qedf_release_cmd);
continue; continue;
} }
if (lun > -1) {
if (io_req->lun != lun)
continue;
}
/* /*
* Use kref_get_unless_zero in the unlikely case the command * Use kref_get_unless_zero in the unlikely case the command
...@@ -2281,7 +2281,7 @@ void qedf_process_cleanup_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, ...@@ -2281,7 +2281,7 @@ void qedf_process_cleanup_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe,
complete(&io_req->cleanup_done); complete(&io_req->cleanup_done);
} }
static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, static int qedf_execute_tmf(struct qedf_rport *fcport, u64 tm_lun,
uint8_t tm_flags) uint8_t tm_flags)
{ {
struct qedf_ioreq *io_req; struct qedf_ioreq *io_req;
...@@ -2291,17 +2291,10 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, ...@@ -2291,17 +2291,10 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,
int rc = 0; int rc = 0;
uint16_t xid; uint16_t xid;
int tmo = 0; int tmo = 0;
int lun = 0;
unsigned long flags; unsigned long flags;
struct fcoe_wqe *sqe; struct fcoe_wqe *sqe;
u16 sqe_idx; u16 sqe_idx;
if (!sc_cmd) {
QEDF_ERR(&qedf->dbg_ctx, "sc_cmd is NULL\n");
return FAILED;
}
lun = (int)sc_cmd->device->lun;
if (!test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags)) { if (!test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags)) {
QEDF_ERR(&(qedf->dbg_ctx), "fcport not offloaded\n"); QEDF_ERR(&(qedf->dbg_ctx), "fcport not offloaded\n");
rc = FAILED; rc = FAILED;
...@@ -2321,7 +2314,7 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, ...@@ -2321,7 +2314,7 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,
qedf->target_resets++; qedf->target_resets++;
/* Initialize rest of io_req fields */ /* Initialize rest of io_req fields */
io_req->sc_cmd = sc_cmd; io_req->sc_cmd = NULL;
io_req->fcport = fcport; io_req->fcport = fcport;
io_req->cmd_type = QEDF_TASK_MGMT_CMD; io_req->cmd_type = QEDF_TASK_MGMT_CMD;
...@@ -2335,6 +2328,7 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, ...@@ -2335,6 +2328,7 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,
/* Default is to return a SCSI command when an error occurs */ /* Default is to return a SCSI command when an error occurs */
io_req->return_scsi_cmd_on_abts = false; io_req->return_scsi_cmd_on_abts = false;
io_req->tm_lun = tm_lun;
/* Obtain exchange id */ /* Obtain exchange id */
xid = io_req->xid; xid = io_req->xid;
...@@ -2389,7 +2383,7 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, ...@@ -2389,7 +2383,7 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,
if (tm_flags == FCP_TMF_LUN_RESET) if (tm_flags == FCP_TMF_LUN_RESET)
qedf_flush_active_ios(fcport, lun); qedf_flush_active_ios(fcport, tm_lun);
else else
qedf_flush_active_ios(fcport, -1); qedf_flush_active_ios(fcport, -1);
...@@ -2404,23 +2398,18 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, ...@@ -2404,23 +2398,18 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,
return rc; return rc;
} }
int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) int qedf_initiate_tmf(struct fc_rport *rport, u64 lun, u8 tm_flags)
{ {
struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device));
struct fc_rport_libfc_priv *rp = rport->dd_data; struct fc_rport_libfc_priv *rp = rport->dd_data;
struct qedf_rport *fcport = (struct qedf_rport *)&rp[1]; struct qedf_rport *fcport = (struct qedf_rport *)&rp[1];
struct qedf_ctx *qedf; struct qedf_ctx *qedf = fcport->qedf;
struct fc_lport *lport = shost_priv(sc_cmd->device->host); struct fc_lport *lport = rp->local_port;
int rc = SUCCESS; int rc = SUCCESS;
int rval;
struct qedf_ioreq *io_req = NULL;
int ref_cnt = 0;
struct fc_rport_priv *rdata = fcport->rdata; struct fc_rport_priv *rdata = fcport->rdata;
QEDF_ERR(NULL, QEDF_ERR(NULL,
"tm_flags 0x%x sc_cmd %p op = 0x%02x target_id = 0x%x lun=%d\n", "tm_flags 0x%x target_id = 0x%x lun=%llu\n",
tm_flags, sc_cmd, sc_cmd->cmd_len ? sc_cmd->cmnd[0] : 0xff, tm_flags, rport->scsi_target_id, lun);
rport->scsi_target_id, (int)sc_cmd->device->lun);
if (!rdata || !kref_get_unless_zero(&rdata->kref)) { if (!rdata || !kref_get_unless_zero(&rdata->kref)) {
QEDF_ERR(NULL, "stale rport\n"); QEDF_ERR(NULL, "stale rport\n");
...@@ -2431,33 +2420,10 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) ...@@ -2431,33 +2420,10 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
(tm_flags == FCP_TMF_TGT_RESET) ? "TARGET RESET" : (tm_flags == FCP_TMF_TGT_RESET) ? "TARGET RESET" :
"LUN RESET"); "LUN RESET");
if (qedf_priv(sc_cmd)->io_req) { rc = fc_block_rport(rport);
io_req = qedf_priv(sc_cmd)->io_req;
ref_cnt = kref_read(&io_req->refcount);
QEDF_ERR(NULL,
"orig io_req = %p xid = 0x%x ref_cnt = %d.\n",
io_req, io_req->xid, ref_cnt);
}
rval = fc_remote_port_chkready(rport);
if (rval) {
QEDF_ERR(NULL, "device_reset rport not ready\n");
rc = FAILED;
goto tmf_err;
}
rc = fc_block_scsi_eh(sc_cmd);
if (rc) if (rc)
goto tmf_err; goto tmf_err;
if (!fcport) {
QEDF_ERR(NULL, "device_reset: rport is NULL\n");
rc = FAILED;
goto tmf_err;
}
qedf = fcport->qedf;
if (!qedf) { if (!qedf) {
QEDF_ERR(NULL, "qedf is NULL.\n"); QEDF_ERR(NULL, "qedf is NULL.\n");
rc = FAILED; rc = FAILED;
...@@ -2494,7 +2460,7 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) ...@@ -2494,7 +2460,7 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
goto tmf_err; goto tmf_err;
} }
rc = qedf_execute_tmf(fcport, sc_cmd, tm_flags); rc = qedf_execute_tmf(fcport, lun, tm_flags);
tmf_err: tmf_err:
kref_put(&rdata->kref, fc_rport_destroy); kref_put(&rdata->kref, fc_rport_destroy);
...@@ -2511,7 +2477,6 @@ void qedf_process_tmf_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, ...@@ -2511,7 +2477,6 @@ void qedf_process_tmf_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe,
fcp_rsp = &cqe->cqe_info.rsp_info; fcp_rsp = &cqe->cqe_info.rsp_info;
qedf_parse_fcp_rsp(io_req, fcp_rsp); qedf_parse_fcp_rsp(io_req, fcp_rsp);
io_req->sc_cmd = NULL;
complete(&io_req->tm_done); complete(&io_req->tm_done);
} }
......
...@@ -774,7 +774,7 @@ static int qedf_eh_abort(struct scsi_cmnd *sc_cmd) ...@@ -774,7 +774,7 @@ static int qedf_eh_abort(struct scsi_cmnd *sc_cmd)
goto drop_rdata_kref; goto drop_rdata_kref;
} }
rc = fc_block_scsi_eh(sc_cmd); rc = fc_block_rport(rport);
if (rc) if (rc)
goto drop_rdata_kref; goto drop_rdata_kref;
...@@ -858,18 +858,19 @@ static int qedf_eh_abort(struct scsi_cmnd *sc_cmd) ...@@ -858,18 +858,19 @@ static int qedf_eh_abort(struct scsi_cmnd *sc_cmd)
static int qedf_eh_target_reset(struct scsi_cmnd *sc_cmd) static int qedf_eh_target_reset(struct scsi_cmnd *sc_cmd)
{ {
QEDF_ERR(NULL, "%d:0:%d:%lld: TARGET RESET Issued...", struct scsi_target *starget = scsi_target(sc_cmd->device);
sc_cmd->device->host->host_no, sc_cmd->device->id, struct fc_rport *rport = starget_to_rport(starget);
sc_cmd->device->lun);
return qedf_initiate_tmf(sc_cmd, FCP_TMF_TGT_RESET); QEDF_ERR(NULL, "TARGET RESET Issued...");
return qedf_initiate_tmf(rport, 0, FCP_TMF_TGT_RESET);
} }
static int qedf_eh_device_reset(struct scsi_cmnd *sc_cmd) static int qedf_eh_device_reset(struct scsi_cmnd *sc_cmd)
{ {
QEDF_ERR(NULL, "%d:0:%d:%lld: LUN RESET Issued... ", struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device));
sc_cmd->device->host->host_no, sc_cmd->device->id,
sc_cmd->device->lun); QEDF_ERR(NULL, "LUN RESET Issued...\n");
return qedf_initiate_tmf(sc_cmd, FCP_TMF_LUN_RESET); return qedf_initiate_tmf(rport, sc_cmd->device->lun, FCP_TMF_LUN_RESET);
} }
bool qedf_wait_for_upload(struct qedf_ctx *qedf) bool qedf_wait_for_upload(struct qedf_ctx *qedf)
......
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