Skip to content

Commit ade4fb9

Browse files
hreineckemartinkpetersen
authored andcommitted
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: Hannes Reinecke <hare@suse.de> Link: https://lore.kernel.org/r/20231002154328.43718-5-hare@suse.de Cc: Saurav Kashyap <skashyap@marvell.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 17865dc commit ade4fb9

3 files changed

Lines changed: 33 additions & 66 deletions

File tree

drivers/scsi/qedf/qedf.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ struct qedf_ioreq {
112112
#define QEDF_CMD_ERR_SCSI_DONE 0x5
113113
u8 io_req_flags;
114114
uint8_t tm_flags;
115+
u64 tm_lun;
115116
struct qedf_rport *fcport;
116117
#define QEDF_CMD_ST_INACTIVE 0
117118
#define QEDFC_CMD_ST_IO_ACTIVE 1
@@ -497,7 +498,7 @@ extern void qedf_process_warning_compl(struct qedf_ctx *qedf,
497498
struct fcoe_cqe *cqe, struct qedf_ioreq *io_req);
498499
extern void qedf_process_error_detect(struct qedf_ctx *qedf,
499500
struct fcoe_cqe *cqe, struct qedf_ioreq *io_req);
500-
extern void qedf_flush_active_ios(struct qedf_rport *fcport, int lun);
501+
extern void qedf_flush_active_ios(struct qedf_rport *fcport, u64 lun);
501502
extern void qedf_release_cmd(struct kref *ref);
502503
extern int qedf_initiate_abts(struct qedf_ioreq *io_req,
503504
bool return_scsi_cmd_on_abts);
@@ -522,7 +523,7 @@ extern int qedf_initiate_cleanup(struct qedf_ioreq *io_req,
522523
bool return_scsi_cmd_on_abts);
523524
extern void qedf_process_cleanup_compl(struct qedf_ctx *qedf,
524525
struct fcoe_cqe *cqe, struct qedf_ioreq *io_req);
525-
extern int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags);
526+
extern int qedf_initiate_tmf(struct fc_rport *rport, u64 lun, u8 tm_flags);
526527
extern void qedf_process_tmf_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe,
527528
struct qedf_ioreq *io_req);
528529
extern void qedf_process_cqe(struct qedf_ctx *qedf, struct fcoe_cqe *cqe);

drivers/scsi/qedf/qedf_io.c

Lines changed: 20 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -546,16 +546,20 @@ static int qedf_build_bd_list_from_sg(struct qedf_ioreq *io_req)
546546
}
547547

548548
static void qedf_build_fcp_cmnd(struct qedf_ioreq *io_req,
549-
struct fcp_cmnd *fcp_cmnd)
549+
struct fcp_cmnd *fcp_cmnd)
550550
{
551551
struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
552552

553553
/* fcp_cmnd is 32 bytes */
554554
memset(fcp_cmnd, 0, FCP_CMND_LEN);
555555

556556
/* 8 bytes: SCSI LUN info */
557-
int_to_scsilun(sc_cmd->device->lun,
558-
(struct scsi_lun *)&fcp_cmnd->fc_lun);
557+
if (io_req->cmd_type == QEDF_TASK_MGMT_CMD)
558+
int_to_scsilun(io_req->tm_lun,
559+
(struct scsi_lun *)&fcp_cmnd->fc_lun);
560+
else
561+
int_to_scsilun(sc_cmd->device->lun,
562+
(struct scsi_lun *)&fcp_cmnd->fc_lun);
559563

560564
/* 4 bytes: flag info */
561565
fcp_cmnd->fc_pri_ta = 0;
@@ -1095,7 +1099,7 @@ static void qedf_parse_fcp_rsp(struct qedf_ioreq *io_req,
10951099
}
10961100

10971101
/* The sense buffer can be NULL for TMF commands */
1098-
if (sc_cmd->sense_buffer) {
1102+
if (sc_cmd && sc_cmd->sense_buffer) {
10991103
memset(sc_cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
11001104
if (fcp_sns_len)
11011105
memcpy(sc_cmd->sense_buffer, sense_data,
@@ -1580,7 +1584,7 @@ static void qedf_flush_els_req(struct qedf_ctx *qedf,
15801584
/* A value of -1 for lun is a wild card that means flush all
15811585
* active SCSI I/Os for the target.
15821586
*/
1583-
void qedf_flush_active_ios(struct qedf_rport *fcport, int lun)
1587+
void qedf_flush_active_ios(struct qedf_rport *fcport, u64 lun)
15841588
{
15851589
struct qedf_ioreq *io_req;
15861590
struct qedf_ctx *qedf;
@@ -1768,10 +1772,6 @@ void qedf_flush_active_ios(struct qedf_rport *fcport, int lun)
17681772
kref_put(&io_req->refcount, qedf_release_cmd);
17691773
continue;
17701774
}
1771-
if (lun > -1) {
1772-
if (io_req->lun != lun)
1773-
continue;
1774-
}
17751775

17761776
/*
17771777
* 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,
22812281
complete(&io_req->cleanup_done);
22822282
}
22832283

2284-
static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,
2284+
static int qedf_execute_tmf(struct qedf_rport *fcport, u64 tm_lun,
22852285
uint8_t tm_flags)
22862286
{
22872287
struct qedf_ioreq *io_req;
@@ -2291,17 +2291,10 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,
22912291
int rc = 0;
22922292
uint16_t xid;
22932293
int tmo = 0;
2294-
int lun = 0;
22952294
unsigned long flags;
22962295
struct fcoe_wqe *sqe;
22972296
u16 sqe_idx;
22982297

2299-
if (!sc_cmd) {
2300-
QEDF_ERR(&qedf->dbg_ctx, "sc_cmd is NULL\n");
2301-
return FAILED;
2302-
}
2303-
2304-
lun = (int)sc_cmd->device->lun;
23052298
if (!test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags)) {
23062299
QEDF_ERR(&(qedf->dbg_ctx), "fcport not offloaded\n");
23072300
rc = FAILED;
@@ -2321,7 +2314,7 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,
23212314
qedf->target_resets++;
23222315

23232316
/* Initialize rest of io_req fields */
2324-
io_req->sc_cmd = sc_cmd;
2317+
io_req->sc_cmd = NULL;
23252318
io_req->fcport = fcport;
23262319
io_req->cmd_type = QEDF_TASK_MGMT_CMD;
23272320

@@ -2335,6 +2328,7 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,
23352328

23362329
/* Default is to return a SCSI command when an error occurs */
23372330
io_req->return_scsi_cmd_on_abts = false;
2331+
io_req->tm_lun = tm_lun;
23382332

23392333
/* Obtain exchange id */
23402334
xid = io_req->xid;
@@ -2389,7 +2383,7 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,
23892383

23902384

23912385
if (tm_flags == FCP_TMF_LUN_RESET)
2392-
qedf_flush_active_ios(fcport, lun);
2386+
qedf_flush_active_ios(fcport, tm_lun);
23932387
else
23942388
qedf_flush_active_ios(fcport, -1);
23952389

@@ -2404,23 +2398,18 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,
24042398
return rc;
24052399
}
24062400

2407-
int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
2401+
int qedf_initiate_tmf(struct fc_rport *rport, u64 lun, u8 tm_flags)
24082402
{
2409-
struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device));
24102403
struct fc_rport_libfc_priv *rp = rport->dd_data;
24112404
struct qedf_rport *fcport = (struct qedf_rport *)&rp[1];
2412-
struct qedf_ctx *qedf;
2413-
struct fc_lport *lport = shost_priv(sc_cmd->device->host);
2405+
struct qedf_ctx *qedf = fcport->qedf;
2406+
struct fc_lport *lport = rp->local_port;
24142407
int rc = SUCCESS;
2415-
int rval;
2416-
struct qedf_ioreq *io_req = NULL;
2417-
int ref_cnt = 0;
24182408
struct fc_rport_priv *rdata = fcport->rdata;
24192409

24202410
QEDF_ERR(NULL,
2421-
"tm_flags 0x%x sc_cmd %p op = 0x%02x target_id = 0x%x lun=%d\n",
2422-
tm_flags, sc_cmd, sc_cmd->cmd_len ? sc_cmd->cmnd[0] : 0xff,
2423-
rport->scsi_target_id, (int)sc_cmd->device->lun);
2411+
"tm_flags 0x%x target_id = 0x%x lun=%llu\n",
2412+
tm_flags, rport->scsi_target_id, lun);
24242413

24252414
if (!rdata || !kref_get_unless_zero(&rdata->kref)) {
24262415
QEDF_ERR(NULL, "stale rport\n");
@@ -2431,33 +2420,10 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
24312420
(tm_flags == FCP_TMF_TGT_RESET) ? "TARGET RESET" :
24322421
"LUN RESET");
24332422

2434-
if (qedf_priv(sc_cmd)->io_req) {
2435-
io_req = qedf_priv(sc_cmd)->io_req;
2436-
ref_cnt = kref_read(&io_req->refcount);
2437-
QEDF_ERR(NULL,
2438-
"orig io_req = %p xid = 0x%x ref_cnt = %d.\n",
2439-
io_req, io_req->xid, ref_cnt);
2440-
}
2441-
2442-
rval = fc_remote_port_chkready(rport);
2443-
if (rval) {
2444-
QEDF_ERR(NULL, "device_reset rport not ready\n");
2445-
rc = FAILED;
2446-
goto tmf_err;
2447-
}
2448-
2449-
rc = fc_block_scsi_eh(sc_cmd);
2423+
rc = fc_block_rport(rport);
24502424
if (rc)
24512425
goto tmf_err;
24522426

2453-
if (!fcport) {
2454-
QEDF_ERR(NULL, "device_reset: rport is NULL\n");
2455-
rc = FAILED;
2456-
goto tmf_err;
2457-
}
2458-
2459-
qedf = fcport->qedf;
2460-
24612427
if (!qedf) {
24622428
QEDF_ERR(NULL, "qedf is NULL.\n");
24632429
rc = FAILED;
@@ -2494,7 +2460,7 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
24942460
goto tmf_err;
24952461
}
24962462

2497-
rc = qedf_execute_tmf(fcport, sc_cmd, tm_flags);
2463+
rc = qedf_execute_tmf(fcport, lun, tm_flags);
24982464

24992465
tmf_err:
25002466
kref_put(&rdata->kref, fc_rport_destroy);
@@ -2511,7 +2477,6 @@ void qedf_process_tmf_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe,
25112477
fcp_rsp = &cqe->cqe_info.rsp_info;
25122478
qedf_parse_fcp_rsp(io_req, fcp_rsp);
25132479

2514-
io_req->sc_cmd = NULL;
25152480
complete(&io_req->tm_done);
25162481
}
25172482

drivers/scsi/qedf/qedf_main.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ static int qedf_eh_abort(struct scsi_cmnd *sc_cmd)
774774
goto drop_rdata_kref;
775775
}
776776

777-
rc = fc_block_scsi_eh(sc_cmd);
777+
rc = fc_block_rport(rport);
778778
if (rc)
779779
goto drop_rdata_kref;
780780

@@ -858,18 +858,19 @@ static int qedf_eh_abort(struct scsi_cmnd *sc_cmd)
858858

859859
static int qedf_eh_target_reset(struct scsi_cmnd *sc_cmd)
860860
{
861-
QEDF_ERR(NULL, "%d:0:%d:%lld: TARGET RESET Issued...",
862-
sc_cmd->device->host->host_no, sc_cmd->device->id,
863-
sc_cmd->device->lun);
864-
return qedf_initiate_tmf(sc_cmd, FCP_TMF_TGT_RESET);
861+
struct scsi_target *starget = scsi_target(sc_cmd->device);
862+
struct fc_rport *rport = starget_to_rport(starget);
863+
864+
QEDF_ERR(NULL, "TARGET RESET Issued...");
865+
return qedf_initiate_tmf(rport, 0, FCP_TMF_TGT_RESET);
865866
}
866867

867868
static int qedf_eh_device_reset(struct scsi_cmnd *sc_cmd)
868869
{
869-
QEDF_ERR(NULL, "%d:0:%d:%lld: LUN RESET Issued... ",
870-
sc_cmd->device->host->host_no, sc_cmd->device->id,
871-
sc_cmd->device->lun);
872-
return qedf_initiate_tmf(sc_cmd, FCP_TMF_LUN_RESET);
870+
struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device));
871+
872+
QEDF_ERR(NULL, "LUN RESET Issued...\n");
873+
return qedf_initiate_tmf(rport, sc_cmd->device->lun, FCP_TMF_LUN_RESET);
873874
}
874875

875876
bool qedf_wait_for_upload(struct qedf_ctx *qedf)

0 commit comments

Comments
 (0)