Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 Mar 2017 13:42:08 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r315482 - head/sys/dev/isp
Message-ID:  <201703181342.v2IDg8nA053463@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Sat Mar 18 13:42:08 2017
New Revision: 315482
URL: https://svnweb.freebsd.org/changeset/base/315482

Log:
  Use isp_target_put_entry() in places where it can be.
  
  This unifies the code and removes some duplication.
  
  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 12:39:24 2017	(r315481)
+++ head/sys/dev/isp/isp_freebsd.c	Sat Mar 18 13:42:08 2017	(r315482)
@@ -1632,23 +1632,10 @@ isp_refire_notify_ack(void *arg)
 static void
 isp_target_putback_atio(union ccb *ccb)
 {
-	ispsoftc_t *isp;
-	struct ccb_scsiio *cso;
-	void *qe;
+	ispsoftc_t *isp = XS_ISP(ccb);
+	struct ccb_scsiio *cso = &ccb->csio;
 	at2_entry_t local, *at = &local;
 
-	isp = XS_ISP(ccb);
-
-	qe = isp_getrqentry(isp);
-	if (qe == NULL) {
-		xpt_print(ccb->ccb_h.path,
-		    "%s: Request Queue Overflow\n", __func__);
-		callout_reset(&PISP_PCMD(ccb)->wdog, 10,
-		    isp_refire_putback_atio, ccb);
-		return;
-	}
-	memset(qe, 0, QENTRY_LEN);
-	cso = &ccb->csio;
 	ISP_MEMZERO(at, sizeof (at2_entry_t));
 	at->at_header.rqs_entry_type = RQSTYPE_ATIO2;
 	at->at_header.rqs_entry_count = 1;
@@ -1660,10 +1647,11 @@ isp_target_putback_atio(union ccb *ccb)
 	at->at_status = CT_OK;
 	at->at_rxid = cso->tag_id;
 	at->at_iid = cso->ccb_h.target_id;
-	isp_put_atio2(isp, at, qe);
-	ISP_TDQE(isp, "isp_target_putback_atio", isp->isp_reqidx, qe);
-	ISP_SYNC_REQUEST(isp);
-	isp_complete_ctio(ccb);
+	if (isp_target_put_entry(isp, at)) {
+		callout_reset(&PISP_PCMD(ccb)->wdog, 10,
+		    isp_refire_putback_atio, ccb);
+	} else
+		isp_complete_ctio(ccb);
 }
 
 static void

Modified: head/sys/dev/isp/isp_target.c
==============================================================================
--- head/sys/dev/isp/isp_target.c	Sat Mar 18 12:39:24 2017	(r315481)
+++ head/sys/dev/isp/isp_target.c	Sat Mar 18 13:42:08 2017	(r315482)
@@ -421,22 +421,37 @@ isp_target_put_entry(ispsoftc_t *isp, vo
 		return (-1);
 	}
 	switch (etype) {
+	case RQSTYPE_NOTIFY_ACK:
+		if (IS_24XX(isp))
+			isp_put_notify_24xx_ack(isp, (na_fcentry_24xx_t *)ap,
+			    (na_fcentry_24xx_t *)outp);
+		else if (ISP_CAP_2KLOGIN(isp))
+			isp_put_notify_ack_fc_e(isp, (na_fcentry_e_t *)ap,
+			    (na_fcentry_e_t *)outp);
+		else
+			isp_put_notify_ack_fc(isp, ap, (na_fcentry_t *)outp);
+		break;
 	case RQSTYPE_ATIO2:
-		if (ISP_CAP_2KLOGIN(isp)) {
-			isp_put_atio2e(isp, (at2e_entry_t *) ap, (at2e_entry_t *) outp);
-		} else {
-			isp_put_atio2(isp, (at2_entry_t *) ap, (at2_entry_t *) outp);
-		}
+		if (ISP_CAP_2KLOGIN(isp))
+			isp_put_atio2e(isp, (at2e_entry_t *)ap,
+			    (at2e_entry_t *)outp);
+		else
+			isp_put_atio2(isp, (at2_entry_t *)ap,
+			    (at2_entry_t *)outp);
 		break;
 	case RQSTYPE_CTIO2:
-		if (ISP_CAP_2KLOGIN(isp)) {
-			isp_put_ctio2e(isp, (ct2e_entry_t *) ap, (ct2e_entry_t *) outp);
-		} else {
-			isp_put_ctio2(isp, (ct2_entry_t *) ap, (ct2_entry_t *) outp);
-		}
+		if (ISP_CAP_2KLOGIN(isp))
+			isp_put_ctio2e(isp, (ct2e_entry_t *)ap,
+			    (ct2e_entry_t *)outp);
+		else
+			isp_put_ctio2(isp, (ct2_entry_t *)ap,
+			    (ct2_entry_t *)outp);
 		break;
 	case RQSTYPE_CTIO7:
-		isp_put_ctio7(isp, (ct7_entry_t *) ap, (ct7_entry_t *) outp);
+		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);
@@ -830,7 +845,6 @@ int
 isp_notify_ack(ispsoftc_t *isp, void *arg)
 {
 	char storage[QENTRY_LEN];
-	void *outp;
 
 	/*
 	 * This is in case a Task Management Function ends up here.
@@ -840,14 +854,7 @@ isp_notify_ack(ispsoftc_t *isp, void *ar
 		return (isp_endcmd(isp, aep, NIL_HANDLE, 0, 0, 0));
 	}
 
-	outp = isp_getrqentry(isp);
-	if (outp == NULL) {
-		isp_prt(isp, ISP_LOGWARN, rqo, __func__);
-		return (1);
-	}
-
 	ISP_MEMZERO(storage, QENTRY_LEN);
-
 	if (IS_24XX(isp)) {
 		in_fcentry_24xx_t *in = arg;
 		na_fcentry_24xx_t *na = (na_fcentry_24xx_t *) storage;
@@ -881,7 +888,6 @@ isp_notify_ack(ispsoftc_t *isp, void *ar
 				na->na_srr_reject_explanation = 0x2a;
 			}
 		}
-		isp_put_notify_24xx_ack(isp, na, (na_fcentry_24xx_t *)outp);
 	} else {
 		in_fcentry_t *in = arg;
 		na_fcentry_t *na = (na_fcentry_t *) storage;
@@ -908,18 +914,10 @@ isp_notify_ack(ispsoftc_t *isp, void *ar
 		}
 		na->na_header.rqs_entry_type = RQSTYPE_NOTIFY_ACK;
 		na->na_header.rqs_entry_count = 1;
-		if (ISP_CAP_2KLOGIN(isp)) {
-			isp_put_notify_ack_fc_e(isp, (na_fcentry_e_t *)na,
-			    (na_fcentry_e_t *)outp);
-		} else {
-			isp_put_notify_ack_fc(isp, na, (na_fcentry_t *)outp);
-		}
 		isp_prt(isp, ISP_LOGTDEBUG0, "notify ack handle %x seqid %x flags %x tflags %x response %x", iid, na->na_seqid,
 		    na->na_flags, na->na_task_flags, na->na_response);
 	}
-	ISP_TDQE(isp, "isp_notify_ack", isp->isp_reqidx, storage);
-	ISP_SYNC_REQUEST(isp);
-	return (0);
+	return (isp_target_put_entry(isp, &storage));
 }
 
 int
@@ -930,7 +928,6 @@ isp_acknak_abts(ispsoftc_t *isp, void *a
 	uint8_t tmpb;
 	abts_t *abts = arg;
 	abts_rsp_t *rsp = (abts_rsp_t *) storage;
-	void *outp;
 
 	if (!IS_24XX(isp)) {
 		isp_prt(isp, ISP_LOGERR, "%s: called for non-24XX card", __func__);
@@ -942,12 +939,6 @@ isp_acknak_abts(ispsoftc_t *isp, void *a
 		return (0);
 	}
 
-	outp = isp_getrqentry(isp);
-	if (outp == NULL) {
-		isp_prt(isp, ISP_LOGWARN, rqo, __func__);
-		return (1);
-	}
-
 	ISP_MEMCPY(rsp, abts, QENTRY_LEN);
 	rsp->abts_rsp_header.rqs_entry_type = RQSTYPE_ABTS_RSP;
 
@@ -990,15 +981,7 @@ isp_acknak_abts(ispsoftc_t *isp, void *a
 			break;
 		}
 	}
-
-	/*
-	 * The caller will have set response values as appropriate
-	 * in the ABTS structure just before calling us.
-	 */
-	isp_put_abts_rsp(isp, rsp, (abts_rsp_t *)outp);
-	ISP_TDQE(isp, "isp_acknak_abts", isp->isp_reqidx, storage);
-	ISP_SYNC_REQUEST(isp);
-	return (0);
+	return (isp_target_put_entry(isp, rsp));
 }
 
 static void



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703181342.v2IDg8nA053463>