@@ -546,16 +546,20 @@ static int qedf_build_bd_list_from_sg(struct qedf_ioreq *io_req)
546546}
547547
548548static 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
24992465tmf_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
0 commit comments