svn commit: r315489 - head/sys/dev/isp

Alexander Motin mav at FreeBSD.org
Sat Mar 18 17:01:13 UTC 2017


Author: mav
Date: Sat Mar 18 17:01:11 2017
New Revision: 315489
URL: https://svnweb.freebsd.org/changeset/base/315489

Log:
  Move RQSTYPE_ABTS_RCVD parsing into generic code.
  
  MFC after:	2 weeks

Modified:
  head/sys/dev/isp/isp_freebsd.c
  head/sys/dev/isp/isp_target.c

Modified: head/sys/dev/isp/isp_freebsd.c
==============================================================================
--- head/sys/dev/isp/isp_freebsd.c	Sat Mar 18 16:09:36 2017	(r315488)
+++ head/sys/dev/isp/isp_freebsd.c	Sat Mar 18 17:01:11 2017	(r315489)
@@ -2601,18 +2601,19 @@ isp_handle_platform_target_tmf(ispsoftc_
 	fcportdb_t *lp;
 	struct ccb_immediate_notify *inot;
 	inot_private_data_t *ntp = NULL;
+	atio_private_data_t *atp;
 	lun_id_t lun;
 
 	isp_prt(isp, ISP_LOGTDEBUG0, "%s: code 0x%x sid  0x%x tagval 0x%016llx chan %d lun %jx", __func__, notify->nt_ncode,
 	    notify->nt_sid, (unsigned long long) notify->nt_tagval, notify->nt_channel, notify->nt_lun);
-	/*
-	 * NB: This assignment is necessary because of tricky type conversion.
-	 * XXX: This is tricky and I need to check this. If the lun isn't known
-	 * XXX: for the task management function, it does not of necessity follow
-	 * XXX: that it should go up stream to the wildcard listener.
-	 */
 	if (notify->nt_lun == LUN_ANY) {
-		lun = CAM_LUN_WILDCARD;
+		if (notify->nt_tagval == TAG_ANY) {
+			lun = CAM_LUN_WILDCARD;
+		} else {
+			atp = isp_find_atpd(isp, notify->nt_channel,
+			    notify->nt_tagval & 0xffffffff);
+			lun = atp ? atp->lun : CAM_LUN_WILDCARD;
+		}
 	} else {
 		lun = notify->nt_lun;
 	}
@@ -4176,55 +4177,6 @@ changed:
 		case RQSTYPE_CTIO:
 			isp_handle_platform_ctio(isp, hp);
 			break;
-		case RQSTYPE_ABTS_RCVD:
-		{
-			abts_t *abts = (abts_t *)hp;
-			isp_notify_t notify, *nt = ¬ify;
-			atio_private_data_t *atp;
-			fcportdb_t *lp;
-			uint16_t chan;
-			uint32_t sid, did;
-
-			did = (abts->abts_did_hi << 16) | abts->abts_did_lo;
-			sid = (abts->abts_sid_hi << 16) | abts->abts_sid_lo;
-			ISP_MEMZERO(nt, sizeof (isp_notify_t));
-
-			nt->nt_hba = isp;
-			nt->nt_did = did;
-			nt->nt_nphdl = abts->abts_nphdl;
-			nt->nt_sid = sid;
-			isp_find_chan_by_did(isp, did, &chan);
-			if (chan == ISP_NOCHAN) {
-				nt->nt_tgt = TGT_ANY;
-			} else {
-				nt->nt_tgt = FCPARAM(isp, chan)->isp_wwpn;
-				if (isp_find_pdb_by_handle(isp, chan, abts->abts_nphdl, &lp)) {
-					nt->nt_wwn = lp->port_wwn;
-				} else {
-					nt->nt_wwn = INI_ANY;
-				}
-			}
-			/*
-			 * Try hard to find the lun for this command.
-			 */
-			atp = isp_find_atpd(isp, chan, abts->abts_rxid_task);
-			nt->nt_lun = atp ? atp->lun : LUN_ANY;
-			nt->nt_need_ack = 1;
-			nt->nt_tagval = abts->abts_rxid_task;
-			nt->nt_tagval |= (((uint64_t) abts->abts_rxid_abts) << 32);
-			if (abts->abts_rxid_task == ISP24XX_NO_TASK) {
-				isp_prt(isp, ISP_LOGTINFO, "[0x%x] ABTS from N-Port handle 0x%x Port 0x%06x has no task id (rx_id 0x%04x ox_id 0x%04x)",
-				    abts->abts_rxid_abts, abts->abts_nphdl, sid, abts->abts_rx_id, abts->abts_ox_id);
-			} else {
-				isp_prt(isp, ISP_LOGTINFO, "[0x%x] ABTS from N-Port handle 0x%x Port 0x%06x for task 0x%x (rx_id 0x%04x ox_id 0x%04x)",
-				    abts->abts_rxid_abts, abts->abts_nphdl, sid, abts->abts_rxid_task, abts->abts_rx_id, abts->abts_ox_id);
-			}
-			nt->nt_channel = chan;
-			nt->nt_ncode = NT_ABORT_TASK;
-			nt->nt_lreserved = hp;
-			isp_handle_platform_target_tmf(isp, nt);
-			break;
-		}
 		}
 		break;
 	}

Modified: head/sys/dev/isp/isp_target.c
==============================================================================
--- head/sys/dev/isp/isp_target.c	Sat Mar 18 16:09:36 2017	(r315488)
+++ head/sys/dev/isp/isp_target.c	Sat Mar 18 17:01:11 2017	(r315489)
@@ -58,6 +58,7 @@ static const char rqo[] = "%s: Request Q
 
 static void isp_got_msg_fc(ispsoftc_t *, in_fcentry_t *);
 static void isp_got_tmf_24xx(ispsoftc_t *, at7_entry_t *);
+static void isp_handle_abts(ispsoftc_t *, abts_t *);
 static void isp_handle_atio2(ispsoftc_t *, at2_entry_t *);
 static void isp_handle_ctio2(ispsoftc_t *, ct2_entry_t *);
 static void isp_handle_ctio7(ispsoftc_t *, ct7_entry_t *);
@@ -361,7 +362,7 @@ isp_target_notify(ispsoftc_t *isp, void 
 
 	case RQSTYPE_ABTS_RCVD:
 		isp_get_abts(isp, abts, (abts_t *)local);
-		isp_async(isp, ISPASYNC_TARGET_ACTION, &local);
+		isp_handle_abts(isp, (abts_t *)local);
 		break;
 	case RQSTYPE_ABTS_RSP:
 		isp_get_abts_rsp(isp, abts_rsp, (abts_rsp_t *)local);
@@ -979,6 +980,47 @@ isp_acknak_abts(ispsoftc_t *isp, void *a
 }
 
 static void
+isp_handle_abts(ispsoftc_t *isp, abts_t *abts)
+{
+	isp_notify_t notify, *nt = ¬ify;
+	fcportdb_t *lp;
+	uint16_t chan;
+	uint32_t sid, did;
+
+	did = (abts->abts_did_hi << 16) | abts->abts_did_lo;
+	sid = (abts->abts_sid_hi << 16) | abts->abts_sid_lo;
+	ISP_MEMZERO(nt, sizeof (isp_notify_t));
+
+	nt->nt_hba = isp;
+	nt->nt_did = did;
+	nt->nt_nphdl = abts->abts_nphdl;
+	nt->nt_sid = sid;
+	isp_find_chan_by_did(isp, did, &chan);
+	if (chan == ISP_NOCHAN) {
+		nt->nt_tgt = TGT_ANY;
+	} else {
+		nt->nt_tgt = FCPARAM(isp, chan)->isp_wwpn;
+		if (isp_find_pdb_by_handle(isp, chan, abts->abts_nphdl, &lp)) {
+			nt->nt_wwn = lp->port_wwn;
+		} else {
+			nt->nt_wwn = INI_ANY;
+		}
+	}
+	nt->nt_lun = LUN_ANY;
+	nt->nt_need_ack = 1;
+	nt->nt_tagval = abts->abts_rxid_task;
+	nt->nt_tagval |= (((uint64_t) abts->abts_rxid_abts) << 32);
+	isp_prt(isp, ISP_LOGTINFO, "[0x%x] ABTS from N-Port handle 0x%x"
+	    " Port 0x%06x for task 0x%x (rx_id 0x%04x ox_id 0x%04x)",
+	    abts->abts_rxid_abts, abts->abts_nphdl, sid, abts->abts_rxid_task,
+	    abts->abts_rx_id, abts->abts_ox_id);
+	nt->nt_channel = chan;
+	nt->nt_ncode = NT_ABORT_TASK;
+	nt->nt_lreserved = abts;
+	isp_async(isp, ISPASYNC_TARGET_NOTIFY, &notify);
+}
+
+static void
 isp_handle_atio2(ispsoftc_t *isp, at2_entry_t *aep)
 {
 	int lun, iid;


More information about the svn-src-all mailing list