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

Alexander Motin mav at FreeBSD.org
Fri Nov 27 15:50:22 UTC 2020


Author: mav
Date: Fri Nov 27 15:50:20 2020
New Revision: 368105
URL: https://svnweb.freebsd.org/changeset/base/368105

Log:
  Some code reorganization.
  
   - Remove code duplication by adding two new functions to execute prepared
  queue entry via either mbox or request queue and wait for result.
   - Since the new function executing via request queue sleeps any way, make
  it sleep also in case of overflows or handle shortages.  It should make it
  more reliable and less affecting other less flexible request queue users.
   - Turn isp_target_put_entry() into not target-specific isp_send_entry().
   - Make handling of responses with control handles more universal.
   - Move RQSTYPE_RPT_ID_ACQ handling into new function.
   - Inline isp_handle_other_response(), becoming trivial after above.
   - Clean the list of IOCBs from pre-24xx ones.

Modified:
  head/sys/dev/isp/isp.c
  head/sys/dev/isp/isp_freebsd.c
  head/sys/dev/isp/isp_library.c
  head/sys/dev/isp/isp_library.h
  head/sys/dev/isp/isp_target.c
  head/sys/dev/isp/isp_target.h
  head/sys/dev/isp/ispmbox.h
  head/sys/dev/isp/ispvar.h

Modified: head/sys/dev/isp/isp.c
==============================================================================
--- head/sys/dev/isp/isp.c	Fri Nov 27 13:25:12 2020	(r368104)
+++ head/sys/dev/isp/isp.c	Fri Nov 27 15:50:20 2020	(r368105)
@@ -93,7 +93,8 @@ static const uint8_t alpa_map[] = {
 /*
  * Local function prototypes.
  */
-static int isp_handle_other_response(ispsoftc_t *, int, isphdr_t *, uint32_t *, uint16_t);
+static int isp_handle_control(ispsoftc_t *, isphdr_t *);
+static void isp_handle_rpt_id_acq(ispsoftc_t *, isphdr_t *);
 static void isp_parse_status_24xx(ispsoftc_t *, isp24xx_statusreq_t *, XS_T *);
 static void isp_clear_portdb(ispsoftc_t *, int);
 static void isp_mark_portdb(ispsoftc_t *, int);
@@ -1020,8 +1021,7 @@ isp_fc_enable_vp(ispsoftc_t *isp, int chan)
 {
 	fcparam *fcp = FCPARAM(isp, chan);
 	vp_modify_t vp;
-	void *reqp;
-	uint8_t resp[QENTRY_LEN];
+	int retval;
 
 	/* Build a VP MODIFY command in memory */
 	ISP_MEMZERO(&vp, sizeof(vp));
@@ -1044,37 +1044,13 @@ isp_fc_enable_vp(ispsoftc_t *isp, int chan)
 	MAKE_NODE_NAME_FROM_WWN(vp.vp_mod_ports[0].wwpn, fcp->isp_wwpn);
 	MAKE_NODE_NAME_FROM_WWN(vp.vp_mod_ports[0].wwnn, fcp->isp_wwnn);
 
-	/* Prepare space for response in memory */
-	memset(resp, 0xff, sizeof(resp));
-	vp.vp_mod_hdl = isp_allocate_handle(isp, resp, ISP_HANDLE_CTRL);
-	if (vp.vp_mod_hdl == 0) {
-		isp_prt(isp, ISP_LOGERR,
-		    "%s: VP_MODIFY of Chan %d out of handles", __func__, chan);
-		return (EIO);
+	retval = isp_exec_entry_queue(isp, &vp, &vp, 5);
+	if (retval != 0) {
+		isp_prt(isp, ISP_LOGERR, "%s: VP_MODIFY of chan %d error %d",
+		    __func__, chan, retval);
+		return (retval);
 	}
 
-	/* Send request and wait for response. */
-	reqp = isp_getrqentry(isp);
-	if (reqp == NULL) {
-		isp_prt(isp, ISP_LOGERR,
-		    "%s: VP_MODIFY of Chan %d out of rqent", __func__, chan);
-		isp_destroy_handle(isp, vp.vp_mod_hdl);
-		return (EIO);
-	}
-	isp_put_vp_modify(isp, &vp, (vp_modify_t *)reqp);
-	if (isp->isp_dblev & ISP_LOGDEBUG1)
-		isp_print_bytes(isp, "IOCB VP_MODIFY", QENTRY_LEN, reqp);
-	ISP_SYNC_REQUEST(isp);
-	if (msleep(resp, &isp->isp_lock, 0, "VP_MODIFY", 5*hz) == EWOULDBLOCK) {
-		isp_prt(isp, ISP_LOGERR,
-		    "%s: VP_MODIFY of Chan %d timed out", __func__, chan);
-		isp_destroy_handle(isp, vp.vp_mod_hdl);
-		return (EIO);
-	}
-	if (isp->isp_dblev & ISP_LOGDEBUG1)
-		isp_print_bytes(isp, "IOCB VP_MODIFY response", QENTRY_LEN, resp);
-	isp_get_vp_modify(isp, (vp_modify_t *)resp, &vp);
-
 	if (vp.vp_mod_hdr.rqs_flags != 0 || vp.vp_mod_status != VP_STS_OK) {
 		isp_prt(isp, ISP_LOGERR,
 		    "%s: VP_MODIFY of Chan %d failed with flags %x status %d",
@@ -1088,8 +1064,7 @@ static int
 isp_fc_disable_vp(ispsoftc_t *isp, int chan)
 {
 	vp_ctrl_info_t vp;
-	void *reqp;
-	uint8_t resp[QENTRY_LEN];
+	int retval;
 
 	/* Build a VP CTRL command in memory */
 	ISP_MEMZERO(&vp, sizeof(vp));
@@ -1105,37 +1080,13 @@ isp_fc_disable_vp(ispsoftc_t *isp, int chan)
 	vp.vp_ctrl_vp_count = 1;
 	vp.vp_ctrl_idmap[chan / 16] |= (1 << chan % 16);
 
-	/* Prepare space for response in memory */
-	memset(resp, 0xff, sizeof(resp));
-	vp.vp_ctrl_handle = isp_allocate_handle(isp, resp, ISP_HANDLE_CTRL);
-	if (vp.vp_ctrl_handle == 0) {
-		isp_prt(isp, ISP_LOGERR,
-		    "%s: VP_CTRL of Chan %d out of handles", __func__, chan);
-		return (EIO);
+	retval = isp_exec_entry_queue(isp, &vp, &vp, 5);
+	if (retval != 0) {
+		isp_prt(isp, ISP_LOGERR, "%s: VP_CTRL of chan %d error %d",
+		    __func__, chan, retval);
+		return (retval);
 	}
 
-	/* Send request and wait for response. */
-	reqp = isp_getrqentry(isp);
-	if (reqp == NULL) {
-		isp_prt(isp, ISP_LOGERR,
-		    "%s: VP_CTRL of Chan %d out of rqent", __func__, chan);
-		isp_destroy_handle(isp, vp.vp_ctrl_handle);
-		return (EIO);
-	}
-	isp_put_vp_ctrl_info(isp, &vp, (vp_ctrl_info_t *)reqp);
-	if (isp->isp_dblev & ISP_LOGDEBUG1)
-		isp_print_bytes(isp, "IOCB VP_CTRL", QENTRY_LEN, reqp);
-	ISP_SYNC_REQUEST(isp);
-	if (msleep(resp, &isp->isp_lock, 0, "VP_CTRL", 5*hz) == EWOULDBLOCK) {
-		isp_prt(isp, ISP_LOGERR,
-		    "%s: VP_CTRL of Chan %d timed out", __func__, chan);
-		isp_destroy_handle(isp, vp.vp_ctrl_handle);
-		return (EIO);
-	}
-	if (isp->isp_dblev & ISP_LOGDEBUG1)
-		isp_print_bytes(isp, "IOCB VP_CTRL response", QENTRY_LEN, resp);
-	isp_get_vp_ctrl_info(isp, (vp_ctrl_info_t *)resp, &vp);
-
 	if (vp.vp_ctrl_hdr.rqs_flags != 0 || vp.vp_ctrl_status != 0) {
 		isp_prt(isp, ISP_LOGERR,
 		    "%s: VP_CTRL of Chan %d failed with flags %x status %d %d",
@@ -1230,10 +1181,8 @@ static int
 isp_plogx(ispsoftc_t *isp, int chan, uint16_t handle, uint32_t portid, int flags)
 {
 	isp_plogx_t pl;
-	void *reqp;
-	uint8_t resp[QENTRY_LEN];
 	uint32_t sst, parm1;
-	int rval, lev;
+	int retval, lev;
 	const char *msg;
 	char buf[64];
 
@@ -1250,40 +1199,13 @@ isp_plogx(ispsoftc_t *isp, int chan, uint16_t handle, 
 	pl.plogx_rspsz_porthi = (portid >> 16) & 0xff;
 	pl.plogx_flags = flags;
 
-	/* Prepare space for response in memory */
-	memset(resp, 0xff, sizeof(resp));
-	pl.plogx_handle = isp_allocate_handle(isp, resp, ISP_HANDLE_CTRL);
-	if (pl.plogx_handle == 0) {
-		isp_prt(isp, ISP_LOGERR,
-		    "%s: PLOGX of Chan %d out of handles", __func__, chan);
-		return (-1);
+	retval = isp_exec_entry_queue(isp, &pl, &pl, 3 * ICB_LOGIN_TOV);
+	if (retval != 0) {
+		isp_prt(isp, ISP_LOGERR, "%s: PLOGX of chan %d error %d",
+		    __func__, chan, retval);
+		return (retval);
 	}
 
-	/* Send request and wait for response. */
-	reqp = isp_getrqentry(isp);
-	if (reqp == NULL) {
-		isp_prt(isp, ISP_LOGERR,
-		    "%s: PLOGX of Chan %d out of rqent", __func__, chan);
-		isp_destroy_handle(isp, pl.plogx_handle);
-		return (-1);
-	}
-	isp_put_plogx(isp, &pl, (isp_plogx_t *)reqp);
-	if (isp->isp_dblev & ISP_LOGDEBUG1)
-		isp_print_bytes(isp, "IOCB LOGX", QENTRY_LEN, reqp);
-	FCPARAM(isp, chan)->isp_login_hdl = handle;
-	ISP_SYNC_REQUEST(isp);
-	if (msleep(resp, &isp->isp_lock, 0, "PLOGX", 3 * ICB_LOGIN_TOV * hz)
-	    == EWOULDBLOCK) {
-		isp_prt(isp, ISP_LOGERR,
-		    "%s: PLOGX of Chan %d timed out", __func__, chan);
-		isp_destroy_handle(isp, pl.plogx_handle);
-		return (-1);
-	}
-	FCPARAM(isp, chan)->isp_login_hdl = NIL_HANDLE;
-	if (isp->isp_dblev & ISP_LOGDEBUG1)
-		isp_print_bytes(isp, "IOCB LOGX response", QENTRY_LEN, resp);
-	isp_get_plogx(isp, (isp_plogx_t *)resp, &pl);
-
 	if (pl.plogx_status == PLOGX_STATUS_OK) {
 		return (0);
 	} else if (pl.plogx_status != PLOGX_STATUS_IOCBERR) {
@@ -1296,7 +1218,7 @@ isp_plogx(ispsoftc_t *isp, int chan, uint16_t handle, 
 	sst = pl.plogx_ioparm[0].lo16 | (pl.plogx_ioparm[0].hi16 << 16);
 	parm1 = pl.plogx_ioparm[1].lo16 | (pl.plogx_ioparm[1].hi16 << 16);
 
-	rval = -1;
+	retval = -1;
 	lev = ISP_LOGERR;
 	msg = NULL;
 
@@ -1323,7 +1245,7 @@ isp_plogx(ispsoftc_t *isp, int chan, uint16_t handle, 
 	case PLOGX_IOCBERR_NOLOGIN:
 		ISP_SNPRINTF(buf, sizeof (buf), "not logged in (last state 0x%x)", parm1);
 		msg = buf;
-		rval = MBOX_NOT_LOGGED_IN;
+		retval = MBOX_NOT_LOGGED_IN;
 		break;
 	case PLOGX_IOCBERR_REJECT:
 		ISP_SNPRINTF(buf, sizeof (buf), "LS_RJT = 0x%x", parm1);
@@ -1340,13 +1262,13 @@ isp_plogx(ispsoftc_t *isp, int chan, uint16_t handle, 
 		lev = ISP_LOG_SANCFG|ISP_LOG_WARN1;
 		ISP_SNPRINTF(buf, sizeof (buf), "already logged in with N-Port handle 0x%x", parm1);
 		msg = buf;
-		rval = MBOX_PORT_ID_USED | (parm1 << 16);
+		retval = MBOX_PORT_ID_USED | (parm1 << 16);
 		break;
 	case PLOGX_IOCBERR_HNDLUSED:
 		lev = ISP_LOG_SANCFG|ISP_LOG_WARN1;
 		ISP_SNPRINTF(buf, sizeof (buf), "handle already used for PortID 0x%06x", parm1);
 		msg = buf;
-		rval = MBOX_LOOP_ID_USED;
+		retval = MBOX_LOOP_ID_USED;
 		break;
 	case PLOGX_IOCBERR_NOHANDLE:
 		msg = "no handle allocated";
@@ -1363,7 +1285,7 @@ isp_plogx(ispsoftc_t *isp, int chan, uint16_t handle, 
 		isp_prt(isp, lev, "Chan %d PLOGX PortID 0x%06x to N-Port handle 0x%x: %s",
 		    chan, portid, handle, msg);
 	}
-	return (rval);
+	return (retval);
 }
 
 static int
@@ -1883,8 +1805,7 @@ isp_ct_passthru(ispsoftc_t *isp, int chan, uint32_t cm
 {
 	fcparam *fcp = FCPARAM(isp, chan);
 	isp_ct_pt_t pt;
-	void *reqp;
-	uint8_t resp[QENTRY_LEN];
+	int retval;
 
 	if (isp->isp_dblev & ISP_LOGDEBUG1)
 		isp_print_bytes(isp, "CT request", cmd_bcnt, fcp->isp_scratch);
@@ -1909,37 +1830,13 @@ isp_ct_passthru(ispsoftc_t *isp, int chan, uint32_t cm
 	pt.ctp_dataseg[1].ds_basehi = DMA_HI32(fcp->isp_scdma);
 	pt.ctp_dataseg[1].ds_count = rsp_bcnt;
 
-	/* Prepare space for response in memory */
-	memset(resp, 0xff, sizeof(resp));
-	pt.ctp_handle = isp_allocate_handle(isp, resp, ISP_HANDLE_CTRL);
-	if (pt.ctp_handle == 0) {
-		isp_prt(isp, ISP_LOGERR,
-		    "%s: CTP of Chan %d out of handles", __func__, chan);
-		return (-1);
+	retval = isp_exec_entry_queue(isp, &pt, &pt, 2 * pt.ctp_time);
+	if (retval != 0) {
+		isp_prt(isp, ISP_LOGERR, "%s: CTP of chan %d error %d",
+		    __func__, chan, retval);
+		return (retval);
 	}
 
-	/* Send request and wait for response. */
-	reqp = isp_getrqentry(isp);
-	if (reqp == NULL) {
-		isp_prt(isp, ISP_LOGERR,
-		    "%s: CTP of Chan %d out of rqent", __func__, chan);
-		isp_destroy_handle(isp, pt.ctp_handle);
-		return (-1);
-	}
-	isp_put_ct_pt(isp, &pt, (isp_ct_pt_t *)reqp);
-	if (isp->isp_dblev & ISP_LOGDEBUG1)
-		isp_print_bytes(isp, "CT IOCB request", QENTRY_LEN, reqp);
-	ISP_SYNC_REQUEST(isp);
-	if (msleep(resp, &isp->isp_lock, 0, "CTP", pt.ctp_time*hz) == EWOULDBLOCK) {
-		isp_prt(isp, ISP_LOGERR,
-		    "%s: CTP of Chan %d timed out", __func__, chan);
-		isp_destroy_handle(isp, pt.ctp_handle);
-		return (-1);
-	}
-	if (isp->isp_dblev & ISP_LOGDEBUG1)
-		isp_print_bytes(isp, "CT IOCB response", QENTRY_LEN, resp);
-
-	isp_get_ct_pt(isp, (isp_ct_pt_t *)resp, &pt);
 	if (pt.ctp_status && pt.ctp_status != RQCS_DATA_UNDERRUN) {
 		isp_prt(isp, ISP_LOGWARN,
 		    "Chan %d CT pass-through returned 0x%x",
@@ -2873,7 +2770,7 @@ isp_control(ispsoftc_t *isp, ispctl_t ctl, ...)
 	fcparam *fcp;
 	fcportdb_t *lp;
 	XS_T *xs;
-	mbreg_t mbs;
+	mbreg_t *mbr;
 	int chan, tgt;
 	uint32_t handle;
 	va_list ap;
@@ -2919,32 +2816,15 @@ isp_control(ispsoftc_t *isp, ispctl_t ctl, ...)
 		tmf->tmf_tidlo = lp->portid;
 		tmf->tmf_tidhi = lp->portid >> 16;
 		tmf->tmf_vpidx = ISP_GET_VPIDX(isp, chan);
-		isp_put_24xx_tmf(isp, tmf, isp->isp_iocb);
-		if (isp->isp_dblev & ISP_LOGDEBUG1)
-			isp_print_bytes(isp, "TMF IOCB request", QENTRY_LEN, isp->isp_iocb);
-		MEMORYBARRIER(isp, SYNC_IFORDEV, 0, QENTRY_LEN, chan);
 		fcp->sendmarker = 1;
-
 		isp_prt(isp, ISP_LOGALL, "Chan %d Reset N-Port Handle 0x%04x @ Port 0x%06x", chan, lp->handle, lp->portid);
-		MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL,
-		    MBCMD_DEFAULT_TIMEOUT + tmf->tmf_timeout * 1000000);
-		mbs.param[1] = QENTRY_LEN;
-		mbs.param[2] = DMA_WD1(isp->isp_iocb_dma);
-		mbs.param[3] = DMA_WD0(isp->isp_iocb_dma);
-		mbs.param[6] = DMA_WD3(isp->isp_iocb_dma);
-		mbs.param[7] = DMA_WD2(isp->isp_iocb_dma);
-		isp_mboxcmd(isp, &mbs);
-		if (mbs.param[0] != MBOX_COMMAND_COMPLETE)
-			break;
 
-		MEMORYBARRIER(isp, SYNC_IFORCPU, QENTRY_LEN, QENTRY_LEN, chan);
-		if (isp->isp_dblev & ISP_LOGDEBUG1)
-			isp_print_bytes(isp, "TMF IOCB response", QENTRY_LEN, &((isp24xx_statusreq_t *)isp->isp_iocb)[1]);
 		sp = (isp24xx_statusreq_t *) local;
-		isp_get_24xx_response(isp, &((isp24xx_statusreq_t *)isp->isp_iocb)[1], sp);
-		if (sp->req_completion_status == 0) {
+		if (isp_exec_entry_mbox(isp, tmf, sp, 2 * tmf->tmf_timeout))
+			break;
+
+		if (sp->req_completion_status == 0)
 			return (0);
-		}
 		isp_prt(isp, ISP_LOGWARN, "Chan %d reset of target %d returned 0x%x", chan, tgt, sp->req_completion_status);
 		break;
 	}
@@ -2984,30 +2864,12 @@ isp_control(ispsoftc_t *isp, ispctl_t ctl, ...)
 		ab->abrt_tidlo = lp->portid;
 		ab->abrt_tidhi = lp->portid >> 16;
 		ab->abrt_vpidx = ISP_GET_VPIDX(isp, chan);
-		isp_put_24xx_abrt(isp, ab, isp->isp_iocb);
-		if (isp->isp_dblev & ISP_LOGDEBUG1)
-			isp_print_bytes(isp, "AB IOCB quest", QENTRY_LEN, isp->isp_iocb);
-		MEMORYBARRIER(isp, SYNC_IFORDEV, 0, 2 * QENTRY_LEN, chan);
 
-		ISP_MEMZERO(&mbs, sizeof (mbs));
-		MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 5000000);
-		mbs.param[1] = QENTRY_LEN;
-		mbs.param[2] = DMA_WD1(isp->isp_iocb_dma);
-		mbs.param[3] = DMA_WD0(isp->isp_iocb_dma);
-		mbs.param[6] = DMA_WD3(isp->isp_iocb_dma);
-		mbs.param[7] = DMA_WD2(isp->isp_iocb_dma);
-
-		isp_mboxcmd(isp, &mbs);
-		if (mbs.param[0] != MBOX_COMMAND_COMPLETE)
+		if (isp_exec_entry_mbox(isp, ab, ab, 5))
 			break;
 
-		MEMORYBARRIER(isp, SYNC_IFORCPU, QENTRY_LEN, QENTRY_LEN, chan);
-		if (isp->isp_dblev & ISP_LOGDEBUG1)
-			isp_print_bytes(isp, "AB IOCB response", QENTRY_LEN, &((isp24xx_abrt_t *)isp->isp_iocb)[1]);
-		isp_get_24xx_abrt(isp, &((isp24xx_abrt_t *)isp->isp_iocb)[1], ab);
-		if (ab->abrt_nphdl == ISP24XX_ABRT_OKAY) {
+		if (ab->abrt_nphdl == ISP24XX_ABRT_OKAY)
 			return (0);
-		}
 		isp_prt(isp, ISP_LOGWARN, "Chan %d handle %d abort returned 0x%x", chan, tgt, ab->abrt_nphdl);
 	}
 	case ISPCTL_FCLINK_TEST:
@@ -3082,6 +2944,14 @@ isp_control(ispsoftc_t *isp, ispctl_t ctl, ...)
 		}
 		return (0);
 	}
+	case ISPCTL_RUN_MBOXCMD:
+	{
+		va_start(ap, ctl);
+		mbr = va_arg(ap, mbreg_t *);
+		va_end(ap);
+		isp_mboxcmd(isp, mbr);
+		return (0);
+	}
 	case ISPCTL_PLOGX:
 	{
 		isp_plcmd_t *p;
@@ -3134,8 +3004,6 @@ isp_control(ispsoftc_t *isp, ispctl_t ctl, ...)
 void
 isp_intr_atioq(ispsoftc_t *isp)
 {
-	uint8_t qe[QENTRY_LEN];
-	isphdr_t *hp;
 	void *addr;
 	uint32_t iptr, optr, oop;
 
@@ -3145,9 +3013,7 @@ isp_intr_atioq(ispsoftc_t *isp)
 		oop = optr;
 		MEMORYBARRIER(isp, SYNC_ATIOQ, oop, QENTRY_LEN, -1);
 		addr = ISP_QUEUE_ENTRY(isp->isp_atioq, oop);
-		isp_get_hdr(isp, addr, (isphdr_t *)qe);
-		hp = (isphdr_t *)qe;
-		switch (hp->rqs_entry_type) {
+		switch (((isphdr_t *)addr)->rqs_entry_type) {
 		case RQSTYPE_NOTIFY:
 		case RQSTYPE_ATIO:
 		case RQSTYPE_NOTIFY_ACK:	/* Can be set to ATIO queue.*/
@@ -3252,10 +3118,20 @@ isp_intr_respq(ispsoftc_t *isp)
 			isp_done(cont_xs);
 		}
 
-		if (etype == RQSTYPE_RESPONSE) {
+		if (isp_handle_control(isp, hp)) {
+			ISP_MEMZERO(hp, QENTRY_LEN);	/* PERF */
+			continue;
+		}
+
+		switch (etype) {
+		case RQSTYPE_RESPONSE:
 			isp_get_24xx_response(isp, (isp24xx_statusreq_t *)hp, sp);
-			/* FALLTHROUGH */
-		} else if (etype == RQSTYPE_STATUS_CONT) {
+			break;
+		case RQSTYPE_MARKER:
+			isp_prt(isp, ISP_LOG_WARN1, "Marker Response");
+			ISP_MEMZERO(hp, QENTRY_LEN);	/* PERF */
+			continue;
+		case RQSTYPE_STATUS_CONT:
 			isp_get_cont_response(isp, (ispstatus_cont_t *)hp, scp);
 			if (cont > 0) {
 				slen = min(cont, sizeof(scp->req_sense_data));
@@ -3273,8 +3149,12 @@ isp_intr_respq(ispsoftc_t *isp)
 			}
 			ISP_MEMZERO(hp, QENTRY_LEN);	/* PERF */
 			continue;
-		} else if (isp_handle_other_response(isp, etype, hp,
-		    &cptr, RESULT_QUEUE_LEN(isp))) {
+#ifdef	ISP_TARGET_MODE
+		case RQSTYPE_NOTIFY_ACK:	/* Can be set to ATIO queue. */
+		case RQSTYPE_CTIO7:
+		case RQSTYPE_ABTS_RCVD:		/* Can be set to ATIO queue. */
+		case RQSTYPE_ABTS_RSP:
+			isp_target_notify(isp, hp, &cptr, RESULT_QUEUE_LEN(isp));
 			/* More then one IOCB could be consumed. */
 			while (sptr != cptr) {
 				ISP_MEMZERO(hp, QENTRY_LEN);	/* PERF */
@@ -3284,7 +3164,12 @@ isp_intr_respq(ispsoftc_t *isp)
 			ISP_MEMZERO(hp, QENTRY_LEN);	/* PERF */
 			optr = ISP_NXT_QENTRY(cptr, RESULT_QUEUE_LEN(isp));
 			continue;
-		} else {
+#endif
+		case RQSTYPE_RPT_ID_ACQ:	/* Can be set to ATIO queue.*/
+			isp_handle_rpt_id_acq(isp, hp);
+			ISP_MEMZERO(hp, QENTRY_LEN);	/* PERF */
+			continue;
+		default:
 			/* We don't know what was this -- log and skip. */
 			isp_prt(isp, ISP_LOGERR, notresp, etype, cptr, optr);
 			ISP_MEMZERO(hp, QENTRY_LEN);	/* PERF */
@@ -3657,65 +3542,30 @@ isp_intr_async(ispsoftc_t *isp, uint16_t mbox)
 }
 
 /*
- * Handle other response entries. A pointer to the request queue output
- * index is here in case we want to eat several entries at once, although
- * this is not used currently.
+ * Handle completions with control handles by waking up waiting threads.
  */
-
 static int
-isp_handle_other_response(ispsoftc_t *isp, int type, isphdr_t *hp, uint32_t *optrp, uint16_t ql)
+isp_handle_control(ispsoftc_t *isp, isphdr_t *hp)
 {
-	isp_ridacq_t rid;
-	int chan, c;
-	uint32_t hdl, portid;
+	uint32_t hdl;
 	void *ptr;
 
-	switch (type) {
+	switch (hp->rqs_entry_type) {
+	case RQSTYPE_RESPONSE:
 	case RQSTYPE_MARKER:
-		isp_prt(isp, ISP_LOG_WARN1, "Marker Response");
-		return (1);
-	case RQSTYPE_RPT_ID_ACQ:	/* Can be set to ATIO queue.*/
-		isp_get_ridacq(isp, (isp_ridacq_t *)hp, &rid);
-		portid = (uint32_t)rid.ridacq_vp_port_hi << 16 |
-		    rid.ridacq_vp_port_lo;
-		if (rid.ridacq_format == 0) {
-			for (chan = 0; chan < isp->isp_nchan; chan++) {
-				fcparam *fcp = FCPARAM(isp, chan);
-				if (fcp->role == ISP_ROLE_NONE)
-					continue;
-				c = (chan == 0) ? 127 : (chan - 1);
-				if (rid.ridacq_map[c / 16] & (1 << (c % 16)) ||
-				    chan == 0) {
-					fcp->isp_loopstate = LOOP_HAVE_LINK;
-					isp_async(isp, ISPASYNC_CHANGE_NOTIFY,
-					    chan, ISPASYNC_CHANGE_OTHER);
-				} else {
-					fcp->isp_loopstate = LOOP_NIL;
-					isp_async(isp, ISPASYNC_LOOP_DOWN,
-					    chan);
-				}
-			}
-		} else {
-			fcparam *fcp = FCPARAM(isp, rid.ridacq_vp_index);
-			if (rid.ridacq_vp_status == RIDACQ_STS_COMPLETE ||
-			    rid.ridacq_vp_status == RIDACQ_STS_CHANGED) {
-				fcp->isp_topo = (rid.ridacq_map[0] >> 9) & 0x7;
-				fcp->isp_portid = portid;
-				fcp->isp_loopstate = LOOP_HAVE_ADDR;
-				isp_async(isp, ISPASYNC_CHANGE_NOTIFY,
-				    rid.ridacq_vp_index, ISPASYNC_CHANGE_OTHER);
-			} else {
-				fcp->isp_loopstate = LOOP_NIL;
-				isp_async(isp, ISPASYNC_LOOP_DOWN,
-				    rid.ridacq_vp_index);
-			}
-		}
-		return (1);
+	case RQSTYPE_NOTIFY_ACK:
+	case RQSTYPE_CTIO7:
+	case RQSTYPE_TSK_MGMT:
 	case RQSTYPE_CT_PASSTHRU:
 	case RQSTYPE_VP_MODIFY:
 	case RQSTYPE_VP_CTRL:
+	case RQSTYPE_ABORT_IO:
+	case RQSTYPE_MBOX:
 	case RQSTYPE_LOGIN:
+	case RQSTYPE_ELS_PASSTHRU:
 		ISP_IOXGET_32(isp, (uint32_t *)(hp + 1), hdl);
+		if (ISP_H2HT(hdl) != ISP_HANDLE_CTRL)
+			break;
 		ptr = isp_find_xs(isp, hdl);
 		if (ptr != NULL) {
 			isp_destroy_handle(isp, hdl);
@@ -3723,16 +3573,52 @@ isp_handle_other_response(ispsoftc_t *isp, int type, i
 			wakeup(ptr);
 		}
 		return (1);
-	case RQSTYPE_NOTIFY_ACK:	/* Can be set to ATIO queue. */
-	case RQSTYPE_CTIO7:
-	case RQSTYPE_ABTS_RCVD:		/* Can be set to ATIO queue. */
-	case RQSTYPE_ABTS_RSP:
-#ifdef	ISP_TARGET_MODE
-		return (isp_target_notify(isp, hp, optrp, ql));
-#endif
-		/* FALLTHROUGH */
-	default:
-		return (0);
+	}
+	return (0);
+}
+
+static void
+isp_handle_rpt_id_acq(ispsoftc_t *isp, isphdr_t *hp)
+{
+	fcparam *fcp;
+	isp_ridacq_t rid;
+	int chan, c;
+	uint32_t portid;
+
+	isp_get_ridacq(isp, (isp_ridacq_t *)hp, &rid);
+	portid = (uint32_t)rid.ridacq_vp_port_hi << 16 |
+	    rid.ridacq_vp_port_lo;
+	if (rid.ridacq_format == 0) {
+		for (chan = 0; chan < isp->isp_nchan; chan++) {
+			fcp = FCPARAM(isp, chan);
+			if (fcp->role == ISP_ROLE_NONE)
+				continue;
+			c = (chan == 0) ? 127 : (chan - 1);
+			if (rid.ridacq_map[c / 16] & (1 << (c % 16)) ||
+			    chan == 0) {
+				fcp->isp_loopstate = LOOP_HAVE_LINK;
+				isp_async(isp, ISPASYNC_CHANGE_NOTIFY,
+				    chan, ISPASYNC_CHANGE_OTHER);
+			} else {
+				fcp->isp_loopstate = LOOP_NIL;
+				isp_async(isp, ISPASYNC_LOOP_DOWN,
+				    chan);
+			}
+		}
+	} else {
+		fcp = FCPARAM(isp, rid.ridacq_vp_index);
+		if (rid.ridacq_vp_status == RIDACQ_STS_COMPLETE ||
+		    rid.ridacq_vp_status == RIDACQ_STS_CHANGED) {
+			fcp->isp_topo = (rid.ridacq_map[0] >> 9) & 0x7;
+			fcp->isp_portid = portid;
+			fcp->isp_loopstate = LOOP_HAVE_ADDR;
+			isp_async(isp, ISPASYNC_CHANGE_NOTIFY,
+			    rid.ridacq_vp_index, ISPASYNC_CHANGE_OTHER);
+		} else {
+			fcp->isp_loopstate = LOOP_NIL;
+			isp_async(isp, ISPASYNC_LOOP_DOWN,
+			    rid.ridacq_vp_index);
+		}
 	}
 }
 

Modified: head/sys/dev/isp/isp_freebsd.c
==============================================================================
--- head/sys/dev/isp/isp_freebsd.c	Fri Nov 27 13:25:12 2020	(r368104)
+++ head/sys/dev/isp/isp_freebsd.c	Fri Nov 27 15:50:20 2020	(r368105)
@@ -492,8 +492,6 @@ ispioctl(struct cdev *dev, u_long c, caddr_t addr, int
 		int needmarker;
 		struct isp_fc_tsk_mgmt *fct = (struct isp_fc_tsk_mgmt *) addr;
 		uint16_t nphdl;
-		void *reqp;
-		uint8_t resp[QENTRY_LEN];
 		isp24xx_tmf_t tmf;
 		isp24xx_statusreq_t sp;
 		fcparam *fcp;
@@ -564,47 +562,14 @@ ispioctl(struct cdev *dev, u_long c, caddr_t addr, int
 			break;
 		}
 
-		/* Prepare space for response in memory */
-		memset(resp, 0xff, sizeof(resp));
-		tmf.tmf_handle = isp_allocate_handle(isp, resp,
-		    ISP_HANDLE_CTRL);
-		if (tmf.tmf_handle == 0) {
-			isp_prt(isp, ISP_LOGERR,
-			    "%s: TMF of Chan %d out of handles",
-			    __func__, chan);
+		retval = isp_exec_entry_queue(isp, &tmf, &sp, 5);
+		if (retval != 0) {
+			isp_prt(isp, ISP_LOGERR, "%s: TMF of chan %d error %d",
+			    __func__, chan, retval);
 			ISP_UNLOCK(isp);
-			retval = ENOMEM;
 			break;
 		}
 
-		/* Send request and wait for response. */
-		reqp = isp_getrqentry(isp);
-		if (reqp == NULL) {
-			isp_prt(isp, ISP_LOGERR,
-			    "%s: TMF of Chan %d out of rqent",
-			    __func__, chan);
-			isp_destroy_handle(isp, tmf.tmf_handle);
-			ISP_UNLOCK(isp);
-			retval = EIO;
-			break;
-		}
-		isp_put_24xx_tmf(isp, &tmf, (isp24xx_tmf_t *)reqp);
-		if (isp->isp_dblev & ISP_LOGDEBUG1)
-			isp_print_bytes(isp, "IOCB TMF", QENTRY_LEN, reqp);
-		ISP_SYNC_REQUEST(isp);
-		if (msleep(resp, &isp->isp_lock, 0, "TMF", 5*hz) == EWOULDBLOCK) {
-			isp_prt(isp, ISP_LOGERR,
-			    "%s: TMF of Chan %d timed out",
-			    __func__, chan);
-			isp_destroy_handle(isp, tmf.tmf_handle);
-			ISP_UNLOCK(isp);
-			retval = EIO;
-			break;
-		}
-		if (isp->isp_dblev & ISP_LOGDEBUG1)
-		isp_print_bytes(isp, "IOCB TMF response", QENTRY_LEN, resp);
-		isp_get_24xx_response(isp, (isp24xx_statusreq_t *)resp, &sp);
-
 		if (sp.req_completion_status != 0)
 			retval = EIO;
 		else if (needmarker)
@@ -1755,7 +1720,7 @@ isp_handle_platform_target_notify_ack(ispsoftc_t *isp,
 			cto->rsp.m1.ct_resp[2] = (rsp >> 16) & 0xff;
 			cto->rsp.m1.ct_resp[3] = (rsp >> 24) & 0xff;
 		}
-		return (isp_target_put_entry(isp, &cto));
+		return (isp_send_entry(isp, cto));
 	}
 
 	/*
@@ -1780,7 +1745,7 @@ isp_handle_platform_target_notify_ack(ispsoftc_t *isp,
 			cto->ct_oxid = abts->abts_ox_id;
 			cto->ct_vpidx = mp->nt_channel;
 			cto->ct_flags = CT7_NOACK|CT7_TERMINATE;
-			if (isp_target_put_entry(isp, cto)) {
+			if (isp_send_entry(isp, cto)) {
 				return (ENOMEM);
 			}
 			mp->nt_need_ack = 0;
@@ -2353,7 +2318,7 @@ isp_abort_atio(ispsoftc_t *isp, union ccb *ccb)
 			cto->ct_oxid = atp->oxid;
 			cto->ct_vpidx = XS_CHANNEL(accb);
 			cto->ct_flags = CT7_NOACK|CT7_TERMINATE;
-			isp_target_put_entry(isp, cto);
+			isp_send_entry(isp, cto);
 		}
 		isp_put_atpd(isp, XS_CHANNEL(accb), atp);
 		ccb->ccb_h.status = CAM_REQ_CMP;

Modified: head/sys/dev/isp/isp_library.c
==============================================================================
--- head/sys/dev/isp/isp_library.c	Fri Nov 27 13:25:12 2020	(r368104)
+++ head/sys/dev/isp/isp_library.c	Fri Nov 27 15:50:20 2020	(r368105)
@@ -490,6 +490,7 @@ isp_clear_commands(ispsoftc_t *isp)
 		}
 #endif
 		case ISP_HANDLE_CTRL:
+			ISP_MEMZERO(hdp->cmd, QENTRY_LEN);
 			wakeup(hdp->cmd);
 			isp_destroy_handle(isp, hdp->handle);
 			break;
@@ -1654,6 +1655,7 @@ isp_del_wwn_entry(ispsoftc_t *isp, int chan, uint64_t 
 	/* Notify above levels about gone port. */
 	isp_async(isp, ISPASYNC_DEV_GONE, chan, lp);
 }
+#endif	/* ISP_TARGET_MODE */
 
 void
 isp_get_atio7(ispsoftc_t *isp, at7_entry_t *src, at7_entry_t *dst)
@@ -2030,7 +2032,156 @@ isp_get_abts_rsp(ispsoftc_t *isp, abts_rsp_t *src, abt
 	ISP_IOXGET_32(isp, &src->abts_rsp_payload.rsp.subcode2, dst->abts_rsp_payload.rsp.subcode2);
 	ISP_IOXGET_32(isp, &src->abts_rsp_rxid_task, dst->abts_rsp_rxid_task);
 }
-#endif	/* ISP_TARGET_MODE */
+
+void
+isp_put_entry(ispsoftc_t *isp, void *src, void *dst)
+{
+	uint8_t etype = ((isphdr_t *)src)->rqs_entry_type;
+
+	switch (etype) {
+	case RQSTYPE_NOTIFY_ACK:
+		isp_put_notify_ack_24xx(isp, (na_fcentry_24xx_t *)src,
+		    (na_fcentry_24xx_t *)dst);
+		break;
+	case RQSTYPE_CTIO7:
+		isp_put_ctio7(isp, (ct7_entry_t *)src, (ct7_entry_t *)dst);
+		break;
+	case RQSTYPE_TSK_MGMT:
+		isp_put_24xx_tmf(isp, (isp24xx_tmf_t *)src, (isp24xx_tmf_t *)dst);
+		break;
+	case RQSTYPE_CT_PASSTHRU:
+		isp_put_ct_pt(isp, (isp_ct_pt_t *)src, (isp_ct_pt_t *)dst);
+		break;
+	case RQSTYPE_VP_CTRL:
+		isp_put_vp_ctrl_info(isp, (vp_ctrl_info_t *)src, (vp_ctrl_info_t *)dst);
+		break;
+	case RQSTYPE_VP_MODIFY:
+		isp_put_vp_modify(isp, (vp_modify_t *)src, (vp_modify_t *)dst);
+		break;
+	case RQSTYPE_ABORT_IO:
+		isp_put_24xx_abrt(isp, (isp24xx_abrt_t *)src, (isp24xx_abrt_t *)dst);
+		break;
+	case RQSTYPE_LOGIN:
+		isp_put_plogx(isp, (isp_plogx_t *)src, (isp_plogx_t *)dst);
+		break;
+	case RQSTYPE_ABTS_RSP:
+		isp_put_abts_rsp(isp, (abts_rsp_t *)src, (abts_rsp_t *)dst);
+		break;
+	default:
+		panic("%s: Unknown type 0x%x\n", __func__, etype);
+	}
+}
+
+void
+isp_get_entry(ispsoftc_t *isp, void *src, void *dst)
+{
+	uint8_t etype;
+
+	isp_get_hdr(isp, src, (isphdr_t *)dst);
+	etype = ((isphdr_t *)dst)->rqs_entry_type;
+	switch (etype) {
+	case 0:	/* After isp_clear_commands() */
+		ISP_MEMZERO(dst, QENTRY_LEN);
+		break;
+	case RQSTYPE_RESPONSE:
+		isp_get_24xx_response(isp, (isp24xx_statusreq_t *)src, (isp24xx_statusreq_t *)dst);
+		break;
+	case RQSTYPE_CT_PASSTHRU:
+		isp_get_ct_pt(isp, (isp_ct_pt_t *)src, (isp_ct_pt_t *)dst);
+		break;
+	case RQSTYPE_VP_CTRL:
+		isp_get_vp_ctrl_info(isp, (vp_ctrl_info_t *)src, (vp_ctrl_info_t *)dst);
+		break;
+	case RQSTYPE_VP_MODIFY:
+		isp_get_vp_modify(isp, (vp_modify_t *)src, (vp_modify_t *)dst);
+		break;
+	case RQSTYPE_ABORT_IO:
+		isp_get_24xx_abrt(isp, (isp24xx_abrt_t *)src, (isp24xx_abrt_t *)dst);
+		break;
+	case RQSTYPE_LOGIN:
+		isp_get_plogx(isp, (isp_plogx_t *)src, (isp_plogx_t *)dst);
+		break;
+	default:
+		panic("%s: Unknown type 0x%x\n", __func__, etype);
+	}
+}
+
+int
+isp_send_entry(ispsoftc_t *isp, void *src)
+{
+	void *outp;
+
+	outp = isp_getrqentry(isp);
+	if (outp == NULL) {
+		isp_prt(isp, ISP_LOGWARN, "%s: Request Queue Overflow", __func__);
+		return (-1);
+	}
+	isp_put_entry(isp, src, outp);
+	if (isp->isp_dblev & ISP_LOGTDEBUG2)
+	    isp_print_qentry(isp, __func__, isp->isp_reqidx, outp);
+	ISP_SYNC_REQUEST(isp);
+	return (0);
+}
+
+int
+isp_exec_entry_mbox(ispsoftc_t *isp, void *src, void *dst, int timeout)
+{
+	mbreg_t mbs;
+
+	isp_put_entry(isp, src, isp->isp_iocb);
+	MEMORYBARRIER(isp, SYNC_IFORDEV, 0, 2 * QENTRY_LEN, 0);
+
+	MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL,
+	    MBCMD_DEFAULT_TIMEOUT + timeout * 1000000);
+	mbs.param[1] = QENTRY_LEN;
+	mbs.param[2] = DMA_WD1(isp->isp_iocb_dma);
+	mbs.param[3] = DMA_WD0(isp->isp_iocb_dma);
+	mbs.param[6] = DMA_WD3(isp->isp_iocb_dma);
+	mbs.param[7] = DMA_WD2(isp->isp_iocb_dma);
+	isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs);
+	if (mbs.param[0] != MBOX_COMMAND_COMPLETE)
+		return (EIO);
+
+	MEMORYBARRIER(isp, SYNC_IFORCPU, QENTRY_LEN, QENTRY_LEN, 0);
+	isp_get_entry(isp, &((isp24xx_statusreq_t *)isp->isp_iocb)[1], dst);
+	return (0);
+}
+
+int
+isp_exec_entry_queue(ispsoftc_t *isp, void *src, void *dst, int timeout)
+{
+	uint8_t resp[QENTRY_LEN];
+	uint32_t hdl;
+
+	timeout *= hz;
+again:
+	/* Wait for empty request queue slot. */
+	while (!isp_rqentry_avail(isp, QENTRY_MAX) && timeout-- > 0)
+		msleep(resp, &isp->isp_lock, 0, "isprqa", 1);
+	if (timeout <= 0)
+		return (ENOMEM);
+
+	/* Allocate handle.  Should always be available, but stay safe. */
+	hdl = isp_allocate_handle(isp, resp, ISP_HANDLE_CTRL);
+	if (hdl == 0) {
+		if (timeout-- > 0) {
+			msleep(resp, &isp->isp_lock, 0, "ispha", 1);
+			goto again;
+		}
+		return (ENOMEM);
+	}
+	((uint32_t *)src)[1] = hdl;
+
+	/* Execute the request and wait for response. */
+	isp_send_entry(isp, src);
+	if (msleep(resp, &isp->isp_lock, 0, "ispeeq", timeout) != 0) {
+		isp_destroy_handle(isp, hdl);
+		return (EWOULDBLOCK);
+	}
+	isp_get_entry(isp, resp, dst);
+	return (0);
+}
+
 /*
  * vim:ts=8:sw=8
  */

Modified: head/sys/dev/isp/isp_library.h
==============================================================================
--- head/sys/dev/isp/isp_library.h	Fri Nov 27 13:25:12 2020	(r368104)
+++ head/sys/dev/isp/isp_library.h	Fri Nov 27 15:50:20 2020	(r368105)
@@ -141,7 +141,23 @@ void isp_put_rsnn_nn(ispsoftc_t *, rsnn_nn_t *, rsnn_n
 void isp_get_ct_hdr(ispsoftc_t *isp, ct_hdr_t *, ct_hdr_t *);
 void isp_put_ct_hdr(ispsoftc_t *isp, ct_hdr_t *, ct_hdr_t *);
 void isp_put_fcp_rsp_iu(ispsoftc_t *isp, fcp_rsp_iu_t *, fcp_rsp_iu_t *);
+void isp_get_atio7(ispsoftc_t *isp, at7_entry_t *, at7_entry_t *);
+void isp_put_ctio7(ispsoftc_t *, ct7_entry_t *, ct7_entry_t *);
+void isp_get_ctio7(ispsoftc_t *, ct7_entry_t *, ct7_entry_t *);
+void isp_put_notify_24xx(ispsoftc_t *, in_fcentry_24xx_t *, in_fcentry_24xx_t *);
+void isp_get_notify_24xx(ispsoftc_t *, in_fcentry_24xx_t *, in_fcentry_24xx_t *);
+void isp_put_notify_ack_24xx(ispsoftc_t *, na_fcentry_24xx_t *, na_fcentry_24xx_t *);
+void isp_get_notify_ack_24xx(ispsoftc_t *, na_fcentry_24xx_t *, na_fcentry_24xx_t *);
+void isp_get_abts(ispsoftc_t *, abts_t *, abts_t *);
+void isp_put_abts_rsp(ispsoftc_t *, abts_rsp_t *, abts_rsp_t *);
+void isp_get_abts_rsp(ispsoftc_t *, abts_rsp_t *, abts_rsp_t *);
 
+void isp_put_entry(ispsoftc_t *, void *, void *);
+void isp_get_entry(ispsoftc_t *, void *, void *);
+int isp_send_entry(ispsoftc_t *, void *);
+int isp_exec_entry_mbox(ispsoftc_t *, void *, void *, int);
+int isp_exec_entry_queue(ispsoftc_t *, void *, void *, int);
+
 #define ISP_HANDLE_MASK  0x7fff
 
 #ifdef ISP_TARGET_MODE
@@ -162,16 +178,5 @@ int isp_find_pdb_by_portid(ispsoftc_t *, int, uint32_t
 void isp_find_chan_by_did(ispsoftc_t *, uint32_t, uint16_t *);
 void isp_add_wwn_entry(ispsoftc_t *, int, uint64_t, uint64_t, uint16_t, uint32_t, uint16_t);
 void isp_del_wwn_entry(ispsoftc_t *, int, uint64_t, uint16_t, uint32_t);
-
-void isp_get_atio7(ispsoftc_t *isp, at7_entry_t *, at7_entry_t *);
-void isp_put_ctio7(ispsoftc_t *, ct7_entry_t *, ct7_entry_t *);
-void isp_get_ctio7(ispsoftc_t *, ct7_entry_t *, ct7_entry_t *);
-void isp_put_notify_24xx(ispsoftc_t *, in_fcentry_24xx_t *, in_fcentry_24xx_t *);
-void isp_get_notify_24xx(ispsoftc_t *, in_fcentry_24xx_t *, in_fcentry_24xx_t *);
-void isp_put_notify_ack_24xx(ispsoftc_t *, na_fcentry_24xx_t *, na_fcentry_24xx_t *);
-void isp_get_notify_ack_24xx(ispsoftc_t *, na_fcentry_24xx_t *, na_fcentry_24xx_t *);
-void isp_get_abts(ispsoftc_t *, abts_t *, abts_t *);
-void isp_put_abts_rsp(ispsoftc_t *, abts_rsp_t *, abts_rsp_t *);
-void isp_get_abts_rsp(ispsoftc_t *, abts_rsp_t *, abts_rsp_t *);
 #endif /* ISP_TARGET_MODE */
 #endif /* _ISP_LIBRARY_H */

Modified: head/sys/dev/isp/isp_target.c
==============================================================================
--- head/sys/dev/isp/isp_target.c	Fri Nov 27 13:25:12 2020	(r368104)
+++ head/sys/dev/isp/isp_target.c	Fri Nov 27 15:50:20 2020	(r368105)
@@ -55,8 +55,6 @@ __FBSDID("$FreeBSD$");
 #endif
 
 #ifdef	ISP_TARGET_MODE
-static const char rqo[] = "%s: Request Queue Overflow";
-
 static void isp_got_tmf_24xx(ispsoftc_t *, at7_entry_t *);
 static void isp_handle_abts(ispsoftc_t *, abts_t *);
 static void isp_handle_ctio7(ispsoftc_t *, ct7_entry_t *);
@@ -134,7 +132,8 @@ isp_target_notify(ispsoftc_t *isp, void *vptr, uint32_
 	type = isp_get_response_type(isp, (isphdr_t *)vptr);
 	unp.vp = vptr;
 
-	ISP_TDQE(isp, "isp_target_notify", (int) *optrp, vptr);
+	if (isp->isp_dblev & ISP_LOGTDEBUG2)
+		isp_print_qentry(isp, __func__, *optrp, vptr);
 
 	switch (type) {
 	case RQSTYPE_ATIO:
@@ -219,37 +218,6 @@ isp_target_notify(ispsoftc_t *isp, void *vptr, uint32_
 	return (rval);
 }
 
-int
-isp_target_put_entry(ispsoftc_t *isp, void *ap)
-{
-	void *outp;
-	uint8_t etype = ((isphdr_t *) ap)->rqs_entry_type;
-
-	outp = isp_getrqentry(isp);
-	if (outp == NULL) {
-		isp_prt(isp, ISP_LOGWARN, rqo, __func__); 
-		return (-1);
-	}
-	switch (etype) {
-	case RQSTYPE_NOTIFY_ACK:
-		isp_put_notify_ack_24xx(isp, (na_fcentry_24xx_t *)ap,
-		    (na_fcentry_24xx_t *)outp);
-		break;
-	case RQSTYPE_CTIO7:
-		isp_put_ctio7(isp, (ct7_entry_t *)ap, (ct7_entry_t *)outp);
-		break;
-	case RQSTYPE_ABTS_RSP:
-		isp_put_abts_rsp(isp, (abts_rsp_t *)ap, (abts_rsp_t *)outp);
-		break;
-	default:
-		isp_prt(isp, ISP_LOGERR, "%s: Unknown type 0x%x", __func__, etype);
-		return (-1);
-	}
-	ISP_TDQE(isp, __func__, isp->isp_reqidx, ap);
-	ISP_SYNC_REQUEST(isp);
-	return (0);
-}
-
 /*
  * Command completion- both for handling cases of no resources or
  * no blackhole driver, or other cases where we have to, inline,
@@ -331,7 +299,7 @@ isp_endcmd(ispsoftc_t *isp, ...)
 		cto->ct_scsi_status |= (FCP_RESID_UNDERFLOW << 8);
 	}
 	cto->ct_syshandle = hdl;
-	return (isp_target_put_entry(isp, cto));
+	return (isp_send_entry(isp, cto));
 }
 
 /*
@@ -494,7 +462,7 @@ isp_notify_ack(ispsoftc_t *isp, void *arg)
 			na->na_srr_reject_explanation = 0x2a;
 		}
 	}
-	return (isp_target_put_entry(isp, na));
+	return (isp_send_entry(isp, na));
 }
 
 int
@@ -553,7 +521,7 @@ isp_acknak_abts(ispsoftc_t *isp, void *arg, int errno)
 			break;
 		}
 	}
-	return (isp_target_put_entry(isp, rsp));
+	return (isp_send_entry(isp, rsp));
 }
 
 static void

Modified: head/sys/dev/isp/isp_target.h
==============================================================================
--- head/sys/dev/isp/isp_target.h	Fri Nov 27 13:25:12 2020	(r368104)
+++ head/sys/dev/isp/isp_target.h	Fri Nov 27 15:50:20 2020	(r368105)
@@ -71,13 +71,6 @@ typedef struct isp_notify {
 } isp_notify_t;
 
 /*
- * Debug macros
- */
-
-#define	ISP_TDQE(isp, msg, idx, arg)	\
-    if (isp->isp_dblev & ISP_LOGTDEBUG2) isp_print_qentry(isp, msg, idx, arg)
-
-/*
  * Special Constatns
  */
 #define INI_ANY			((uint64_t) -1)

Modified: head/sys/dev/isp/ispmbox.h
==============================================================================
--- head/sys/dev/isp/ispmbox.h	Fri Nov 27 13:25:12 2020	(r368104)
+++ head/sys/dev/isp/ispmbox.h	Fri Nov 27 15:50:20 2020	(r368105)
@@ -358,48 +358,29 @@ typedef struct {
 #define	RQSFLAG_MASK		0x3f
 
 /* RQS entry_type definitions */
-#define	RQSTYPE_REQUEST		0x01
-#define	RQSTYPE_DATASEG		0x02

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-head mailing list