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

Matt Jacob mjacob at FreeBSD.org
Fri Mar 26 15:13:31 UTC 2010


Author: mjacob
Date: Fri Mar 26 15:13:31 2010
New Revision: 205698
URL: http://svn.freebsd.org/changeset/base/205698

Log:
  Clean up some printing stuff so that we can have a bit finer control
  on debug output. Add a new platform function requirement to allow
  for printing based upon the ITL nexus instead of the isp unit plus
  channel, target and lun. This allows some printouts and error messages
  from the core code to appear in the same format as the platform's
  subsystem (in FreeBSD's case, CAM path).
  
  MFC after:	1 week

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

Modified: head/sys/dev/isp/isp.c
==============================================================================
--- head/sys/dev/isp/isp.c	Fri Mar 26 14:52:58 2010	(r205697)
+++ head/sys/dev/isp/isp.c	Fri Mar 26 15:13:31 2010	(r205698)
@@ -74,14 +74,9 @@ __FBSDID("$FreeBSD$");
  */
 static const char fconf[] = "Chan %d PortDB[%d] changed:\n current =(0x%x at 0x%06x 0x%08x%08x 0x%08x%08x)\n database=(0x%x at 0x%06x 0x%08x%08x 0x%08x%08x)";
 static const char notresp[] = "Not RESPONSE in RESPONSE Queue (type 0x%x) @ idx %d (next %d) nlooked %d";
-static const char xact1[] = "HBA attempted queued transaction with disconnect not set for %d.%d.%d";
-static const char xact2[] = "HBA attempted queued transaction to target routine %d on target %d bus %d";
-static const char xact3[] = "HBA attempted queued cmd for %d.%d.%d when queueing disabled";
-static const char pskip[] = "SCSI phase skipped for target %d.%d.%d";
 static const char topology[] = "Chan %d WWPN 0x%08x%08x PortID 0x%06x N-Port Handle %d, Connection '%s'";
-static const char finmsg[] = "%d.%d.%d: FIN dl%d resid %ld STS 0x%x SKEY %c XS_ERR=0x%x";
 static const char sc4[] = "NVRAM";
-static const char bun[] = "bad underrun for %d.%d (count %d, resid %d, status %s)";
+static const char bun[] = "bad underrun (count %d, resid %d, status %s)";
 static const char lipd[] = "Chan %d LIP destroyed %d active commands";
 static const char sacq[] = "unable to acquire scratch area";
 
@@ -107,6 +102,7 @@ static const uint8_t alpa_map[] = {
 /*
  * Local function prototypes.
  */
+static void isp_prt_endcmd(ispsoftc_t *, XS_T *);
 static int isp_parse_async(ispsoftc_t *, uint16_t);
 static int isp_parse_async_fc(ispsoftc_t *, uint16_t);
 static int isp_handle_other_response(ispsoftc_t *, int, isphdr_t *, uint32_t *);
@@ -1431,10 +1427,8 @@ isp_scsi_channel_init(ispsoftc_t *isp, i
 			    (sdp->isp_devparam[tgt].goal_offset << 8) |
 			    (sdp->isp_devparam[tgt].goal_period);
 		}
-		isp_prt(isp, ISP_LOGDEBUG0,
-		    "Initial Settings bus%d tgt%d flags 0x%x off 0x%x per 0x%x",
-		    chan, tgt, mbs.param[2], mbs.param[3] >> 8,
-		    mbs.param[3] & 0xff);
+		isp_prt(isp, ISP_LOGDEBUG0, "Initial Settings bus%d tgt%d flags 0x%x off 0x%x per 0x%x",
+		    chan, tgt, mbs.param[2], mbs.param[3] >> 8, mbs.param[3] & 0xff);
 		isp_mboxcmd(isp, &mbs);
 		if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
 			sdf = DPARM_SAFE_DFLT;
@@ -1705,8 +1699,7 @@ isp_fibre_init(ispsoftc_t *isp)
 		isp_prt(isp, ISP_LOGERR, sacq);
 		return;
 	}
-	isp_prt(isp, ISP_LOGDEBUG0,
-	    "isp_fibre_init: fwopt 0x%x xfwopt 0x%x zfwopt 0x%x",
+	isp_prt(isp, ISP_LOGDEBUG0, "isp_fibre_init: fwopt 0x%x xfwopt 0x%x zfwopt 0x%x",
 	    icbp->icb_fwoptions, icbp->icb_xfwoptions, icbp->icb_zfwoptions);
 
 	isp_put_icb(isp, icbp, (isp_icb_t *)fcp->isp_scratch);
@@ -4435,7 +4428,7 @@ isp_start(XS_T *xs)
 		 */
 		return (dmaresult);
 	}
-	isp_prt(isp, ISP_LOGDEBUG0, "START cmd for %d.%d.%d cmd 0x%x datalen %ld", XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs), XS_CDBP(xs)[0], (long) XS_XFRLEN(xs));
+	isp_xs_prt(isp, xs, ISP_LOGDEBUG0, "START cmd cdb[0]=0x%x datalen %ld", XS_CDBP(xs)[0], (long) XS_XFRLEN(xs));
 	isp->isp_nactive++;
 	return (CMD_QUEUED);
 }
@@ -5248,7 +5241,7 @@ again:
 				} else {
 					ptr = rnames[resp[FCP_RSPNS_CODE_OFFSET]];
 				}
-				isp_prt(isp, ISP_LOGWARN, "%d.%d.%d FCP RESPONSE, LENGTH %u: %s CDB0=0x%02x", XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs), rlen, ptr, XS_CDBP(xs)[0] & 0xff);
+				isp_xs_prt(isp, xs, ISP_LOGWARN, "FCP RESPONSE, LENGTH %u: %s CDB0=0x%02x", rlen, ptr, XS_CDBP(xs)[0] & 0xff);
 				if (resp[FCP_RSPNS_CODE_OFFSET] != 0) {
 					XS_SETERR(xs, HBA_BOTCH);
 				}
@@ -5325,25 +5318,9 @@ again:
 		isp_destroy_handle(isp, sp->req_handle);
 
 		if (((isp->isp_dblev & (ISP_LOGDEBUG1|ISP_LOGDEBUG2|ISP_LOGDEBUG3))) ||
-		    ((isp->isp_dblev & ISP_LOGDEBUG0) && ((!XS_NOERR(xs)) ||
-		    (*XS_STSP(xs) != SCSI_GOOD)))) {
-			char skey;
-			if (req_state_flags & RQSF_GOT_SENSE) {
-				skey = XS_SNSKEY(xs) & 0xf;
-				if (skey < 10)
-					skey += '0';
-				else
-					skey += 'a' - 10;
-			} else if (*XS_STSP(xs) == SCSI_CHECK) {
-				skey = '?';
-			} else {
-				skey = '.';
-			}
-			isp_prt(isp, ISP_LOGALL, finmsg, XS_CHANNEL(xs),
-			    XS_TGT(xs), XS_LUN(xs), XS_XFRLEN(xs), (long) XS_GET_RESID(xs),
-			    *XS_STSP(xs), skey, XS_ERR(xs));
+		    ((isp->isp_dblev & (ISP_LOGDEBUG0|ISP_LOG_CWARN) && ((!XS_NOERR(xs)) || (*XS_STSP(xs) != SCSI_GOOD))))) {
+			isp_prt_endcmd(isp, xs);
 		}
-
 		if (isp->isp_nactive > 0) {
 		    isp->isp_nactive--;
 		}
@@ -5393,6 +5370,25 @@ out:
  * Support routines.
  */
 
+static void
+isp_prt_endcmd(ispsoftc_t *isp, XS_T *xs)
+{
+	char cdbstr[16 * 5 + 1];
+	int i, lim;
+
+	lim = XS_CDBLEN(xs) > 16? 16 : XS_CDBLEN(xs);
+	ISP_SNPRINTF(cdbstr, sizeof (cdbstr), "0x%02x ", XS_CDBP(xs)[0]);
+	for (i = 1; i < lim; i++) {
+		ISP_SNPRINTF(cdbstr, sizeof (cdbstr), "%s0x%02x ", cdbstr, XS_CDBP(xs)[i]);
+	}
+	if (XS_SENSE_VALID(xs)) {
+		isp_xs_prt(isp, xs, ISP_LOGALL, "FIN dl%d resid %ld CDB=%s KEY/ASC/ASCQ=0x%02x/0x%02x/0x%02x",
+		    XS_XFRLEN(xs), (long) XS_GET_RESID(xs), cdbstr, XS_SNSKEY(xs), XS_SNSASC(xs), XS_SNSASCQ(xs));
+	} else {
+		isp_xs_prt(isp, xs, ISP_LOGALL, "FIN dl%d resid %ld CDB=%s STS 0x%x XS_ERR=0x%x", XS_XFRLEN(xs), (long) XS_GET_RESID(xs), cdbstr, *XS_STSP(xs), XS_ERR(xs));
+	}
+}
+
 /*
  * Parse an ASYNC mailbox complete
  *
@@ -5937,8 +5933,7 @@ isp_parse_async_fc(ispsoftc_t *isp, uint
  */
 
 static int
-isp_handle_other_response(ispsoftc_t *isp, int type,
-    isphdr_t *hp, uint32_t *optrp)
+isp_handle_other_response(ispsoftc_t *isp, int type, isphdr_t *hp, uint32_t *optrp)
 {
 	switch (type) {
 	case RQSTYPE_STATUS_CONT:
@@ -6010,24 +6005,18 @@ isp_parse_status(ispsoftc_t *isp, ispsta
 
 	case RQCS_INCOMPLETE:
 		if ((sp->req_state_flags & RQSF_GOT_TARGET) == 0) {
-			isp_prt(isp, ISP_LOGDEBUG1,
-			    "Selection Timeout for %d.%d.%d",
-			    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+			isp_xs_prt(isp, xs, ISP_LOGDEBUG1, "Selection Timeout");
 			if (XS_NOERR(xs)) {
 				XS_SETERR(xs, HBA_SELTIMEOUT);
 				*rp = XS_XFRLEN(xs);
 			}
 			return;
 		}
-		isp_prt(isp, ISP_LOGERR,
-		    "command incomplete for %d.%d.%d, state 0x%x",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs),
-		    sp->req_state_flags);
+		isp_xs_prt(isp, xs, ISP_LOGERR, "Command Incomplete, state 0x%x", sp->req_state_flags);
 		break;
 
 	case RQCS_DMA_ERROR:
-		isp_prt(isp, ISP_LOGERR, "DMA error for command on %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "DMA Error");
 		*rp = XS_XFRLEN(xs);
 		break;
 
@@ -6081,18 +6070,14 @@ isp_parse_status(ispsoftc_t *isp, ispsta
 		if (sp->req_status_flags & RQSTF_NEGOTIATION) {
 			ISP_SNPRINTF(buf, sizeof (buf), "%s Negotiation", buf);
 		}
-		isp_prt(isp, ISP_LOGERR, "%s", buf);
-		isp_prt(isp, ISP_LOGERR, "transport error for %d.%d.%d:\n%s",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs), buf);
+		isp_xs_prt(isp, xs,  ISP_LOGERR, "Transport Error: %s", buf);
 		*rp = XS_XFRLEN(xs);
 		break;
 	}
 	case RQCS_RESET_OCCURRED:
 	{
 		int chan;
-		isp_prt(isp, ISP_LOGWARN,
-		    "bus reset destroyed command for %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGWARN, "Bus Reset destroyed command");
 		for (chan = 0; chan < isp->isp_nchan; chan++) {
 			FCPARAM(isp, chan)->sendmarker = 1;
 		}
@@ -6103,8 +6088,7 @@ isp_parse_status(ispsoftc_t *isp, ispsta
 		return;
 	}
 	case RQCS_ABORTED:
-		isp_prt(isp, ISP_LOGERR, "command aborted for %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "Command Aborted");
 		ISP_SET_SENDMARKER(isp, XS_CHANNEL(xs), 1);
 		if (XS_NOERR(xs)) {
 			XS_SETERR(xs, HBA_ABORTED);
@@ -6112,8 +6096,7 @@ isp_parse_status(ispsoftc_t *isp, ispsta
 		return;
 
 	case RQCS_TIMEOUT:
-		isp_prt(isp, ISP_LOGWARN, "command timed out for %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGWARN, "Command timed out");
 		/*
 	 	 * XXX: Check to see if we logged out of the device.
 		 */
@@ -6124,83 +6107,62 @@ isp_parse_status(ispsoftc_t *isp, ispsta
 
 	case RQCS_DATA_OVERRUN:
 		XS_SET_RESID(xs, sp->req_resid);
-		isp_prt(isp, ISP_LOGERR, "data overrun (%ld) for command on %d.%d.%d",
-		    (long) XS_GET_RESID(xs), XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "data overrun (%ld)", (long) XS_GET_RESID(xs));
 		if (XS_NOERR(xs)) {
 			XS_SETERR(xs, HBA_DATAOVR);
 		}
 		return;
 
 	case RQCS_COMMAND_OVERRUN:
-		isp_prt(isp, ISP_LOGERR,
-		    "command overrun for command on %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "command overrun");
 		break;
 
 	case RQCS_STATUS_OVERRUN:
-		isp_prt(isp, ISP_LOGERR,
-		    "status overrun for command on %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "status overrun");
 		break;
 
 	case RQCS_BAD_MESSAGE:
-		isp_prt(isp, ISP_LOGERR,
-		    "msg not COMMAND COMPLETE after status %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "msg not COMMAND COMPLETE after status");
 		break;
 
 	case RQCS_NO_MESSAGE_OUT:
-		isp_prt(isp, ISP_LOGERR,
-		    "No MESSAGE OUT phase after selection on %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "No MESSAGE OUT phase after selection");
 		break;
 
 	case RQCS_EXT_ID_FAILED:
-		isp_prt(isp, ISP_LOGERR, "EXTENDED IDENTIFY failed %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "EXTENDED IDENTIFY failed");
 		break;
 
 	case RQCS_IDE_MSG_FAILED:
-		isp_prt(isp, ISP_LOGERR,
-		    "INITIATOR DETECTED ERROR rejected by %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "INITIATOR DETECTED ERROR rejected");
 		break;
 
 	case RQCS_ABORT_MSG_FAILED:
-		isp_prt(isp, ISP_LOGERR, "ABORT OPERATION rejected by %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "ABORT OPERATION rejected");
 		break;
 
 	case RQCS_REJECT_MSG_FAILED:
-		isp_prt(isp, ISP_LOGERR, "MESSAGE REJECT rejected by %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "MESSAGE REJECT rejected");
 		break;
 
 	case RQCS_NOP_MSG_FAILED:
-		isp_prt(isp, ISP_LOGERR, "NOP rejected by %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "NOP rejected");
 		break;
 
 	case RQCS_PARITY_ERROR_MSG_FAILED:
-		isp_prt(isp, ISP_LOGERR,
-		    "MESSAGE PARITY ERROR rejected by %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "MESSAGE PARITY ERROR rejected");
 		break;
 
 	case RQCS_DEVICE_RESET_MSG_FAILED:
-		isp_prt(isp, ISP_LOGWARN,
-		    "BUS DEVICE RESET rejected by %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGWARN, "BUS DEVICE RESET rejected");
 		break;
 
 	case RQCS_ID_MSG_FAILED:
-		isp_prt(isp, ISP_LOGERR, "IDENTIFY rejected by %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "IDENTIFY rejected");
 		break;
 
 	case RQCS_UNEXP_BUS_FREE:
-		isp_prt(isp, ISP_LOGERR, "%d.%d.%d had an unexpected bus free",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "Unexpected Bus Free");
 		break;
 
 	case RQCS_DATA_UNDERRUN:
@@ -6208,9 +6170,7 @@ isp_parse_status(ispsoftc_t *isp, ispsta
 		if (IS_FC(isp)) {
 			int ru_marked = (sp->req_scsi_status & RQCS_RU) != 0;
 			if (!ru_marked || sp->req_resid > XS_XFRLEN(xs)) {
-				isp_prt(isp, ISP_LOGWARN, bun, XS_TGT(xs),
-				    XS_LUN(xs), XS_XFRLEN(xs), sp->req_resid,
-				    (ru_marked)? "marked" : "not marked");
+				isp_xs_prt(isp, xs, ISP_LOGWARN, bun, XS_XFRLEN(xs), sp->req_resid, (ru_marked)? "marked" : "not marked");
 				if (XS_NOERR(xs)) {
 					XS_SETERR(xs, HBA_BOTCH);
 				}
@@ -6225,18 +6185,15 @@ isp_parse_status(ispsoftc_t *isp, ispsta
 	}
 
 	case RQCS_XACT_ERR1:
-		isp_prt(isp, ISP_LOGERR, xact1, XS_CHANNEL(xs),
-		    XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "HBA attempted queued transaction with disconnect not set");
 		break;
 
 	case RQCS_XACT_ERR2:
-		isp_prt(isp, ISP_LOGERR, xact2,
-		    XS_LUN(xs), XS_TGT(xs), XS_CHANNEL(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "HBA attempted queued transaction to target routine %d", XS_LUN(xs));
 		break;
 
 	case RQCS_XACT_ERR3:
-		isp_prt(isp, ISP_LOGERR, xact3,
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "HBA attempted queued cmd when queueing disabled");
 		break;
 
 	case RQCS_BAD_ENTRY:
@@ -6244,9 +6201,7 @@ isp_parse_status(ispsoftc_t *isp, ispsta
 		break;
 
 	case RQCS_QUEUE_FULL:
-		isp_prt(isp, ISP_LOGDEBUG0,
-		    "internal queues full for %d.%d.%d status 0x%x",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs), *XS_STSP(xs));
+		isp_xs_prt(isp, xs, ISP_LOGDEBUG0, "internal queues full status 0x%x", *XS_STSP(xs));
 
 		/*
 		 * If QFULL or some other status byte is set, then this
@@ -6270,23 +6225,18 @@ isp_parse_status(ispsoftc_t *isp, ispsta
 		return;
 
 	case RQCS_PHASE_SKIPPED:
-		isp_prt(isp, ISP_LOGERR, pskip, XS_CHANNEL(xs),
-		    XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "SCSI phase skipped");
 		break;
 
 	case RQCS_ARQS_FAILED:
-		isp_prt(isp, ISP_LOGERR,
-		    "Auto Request Sense failed for %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "Auto Request Sense Failed");
 		if (XS_NOERR(xs)) {
 			XS_SETERR(xs, HBA_ARQFAIL);
 		}
 		return;
 
 	case RQCS_WIDE_FAILED:
-		isp_prt(isp, ISP_LOGERR,
-		    "Wide Negotiation failed for %d.%d.%d",
-		    XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "Wide Negotiation Failed");
 		if (IS_SCSI(isp)) {
 			sdparam *sdp = SDPARAM(isp, XS_CHANNEL(xs));
 			sdp->isp_devparam[XS_TGT(xs)].goal_flags &= ~DPARM_WIDE;
@@ -6299,9 +6249,7 @@ isp_parse_status(ispsoftc_t *isp, ispsta
 		return;
 
 	case RQCS_SYNCXFER_FAILED:
-		isp_prt(isp, ISP_LOGERR,
-		    "SDTR Message failed for target %d.%d.%d",
-		    XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "SDTR Message Failed");
 		if (IS_SCSI(isp)) {
 			sdparam *sdp = SDPARAM(isp, XS_CHANNEL(xs));
 			sdp += XS_CHANNEL(xs);
@@ -6312,9 +6260,7 @@ isp_parse_status(ispsoftc_t *isp, ispsta
 		break;
 
 	case RQCS_LVD_BUSERR:
-		isp_prt(isp, ISP_LOGERR,
-		    "Bad LVD condition while talking to %d.%d.%d",
-		    XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "Bad LVD condition");
 		break;
 
 	case RQCS_PORT_UNAVAILABLE:
@@ -6384,8 +6330,7 @@ isp_parse_status(ispsoftc_t *isp, ispsta
 }
 
 static void
-isp_parse_status_24xx(ispsoftc_t *isp, isp24xx_statusreq_t *sp,
-    XS_T *xs, long *rp)
+isp_parse_status_24xx(ispsoftc_t *isp, isp24xx_statusreq_t *sp, XS_T *xs, long *rp)
 {
 	int ru_marked, sv_marked;
 	int chan = XS_CHANNEL(xs);
@@ -6398,19 +6343,15 @@ isp_parse_status_24xx(ispsoftc_t *isp, i
 		return;
 
 	case RQCS_DMA_ERROR:
-		isp_prt(isp, ISP_LOGERR, "DMA error for command on %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "DMA error");
 		break;
 
 	case RQCS_TRANSPORT_ERROR:
-		isp_prt(isp, ISP_LOGERR, "transport error for %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs,  ISP_LOGERR, "Transport Error");
 		break;
 
 	case RQCS_RESET_OCCURRED:
-		isp_prt(isp, ISP_LOGWARN,
-		    "reset destroyed command for %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGWARN, "reset destroyed command");
 		FCPARAM(isp, chan)->sendmarker = 1;
 		if (XS_NOERR(xs)) {
 			XS_SETERR(xs, HBA_BUSRESET);
@@ -6418,8 +6359,7 @@ isp_parse_status_24xx(ispsoftc_t *isp, i
 		return;
 
 	case RQCS_ABORTED:
-		isp_prt(isp, ISP_LOGERR, "command aborted for %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "Command Aborted");
 		FCPARAM(isp, chan)->sendmarker = 1;
 		if (XS_NOERR(xs)) {
 			XS_SETERR(xs, HBA_ABORTED);
@@ -6427,8 +6367,7 @@ isp_parse_status_24xx(ispsoftc_t *isp, i
 		return;
 
 	case RQCS_TIMEOUT:
-		isp_prt(isp, ISP_LOGWARN, "command timed out for %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGWARN, "Command Timed Out");
 		if (XS_NOERR(xs)) {
 			XS_SETERR(xs, HBA_CMDTIMEOUT);
 		}
@@ -6436,9 +6375,7 @@ isp_parse_status_24xx(ispsoftc_t *isp, i
 
 	case RQCS_DATA_OVERRUN:
 		XS_SET_RESID(xs, sp->req_resid);
-		isp_prt(isp, ISP_LOGERR,
-		    "data overrun for command on %d.%d.%d",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
+		isp_xs_prt(isp, xs, ISP_LOGERR, "Data Overrun");
 		if (XS_NOERR(xs)) {
 			XS_SETERR(xs, HBA_DATAOVR);
 		}
@@ -6471,19 +6408,14 @@ isp_parse_status_24xx(ispsoftc_t *isp, i
 		sv_marked = (sp->req_scsi_status & (RQCS_SV|RQCS_RV)) != 0;
 		if ((ru_marked == 0 && sv_marked == 0) ||
 		    (sp->req_resid > XS_XFRLEN(xs))) {
-			isp_prt(isp, ISP_LOGWARN, bun, XS_TGT(xs),
-			    XS_LUN(xs), XS_XFRLEN(xs), sp->req_resid,
-			    (ru_marked)? "marked" : "not marked");
+			isp_xs_prt(isp, xs, ISP_LOGWARN, bun, XS_XFRLEN(xs), sp->req_resid, (ru_marked)? "marked" : "not marked");
 			if (XS_NOERR(xs)) {
 				XS_SETERR(xs, HBA_BOTCH);
 			}
 			return;
 		}
 		XS_SET_RESID(xs, sp->req_resid);
-		isp_prt(isp, ISP_LOGDEBUG0,
-		    "%d.%d.%d data underrun (%d) for command 0x%x",
-		    XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs),
-		    sp->req_resid, XS_CDBP(xs)[0] & 0xff);
+		isp_xs_prt(isp, xs, ISP_LOGDEBUG0, "Data Underrun (%d) for command 0x%x", sp->req_resid, XS_CDBP(xs)[0] & 0xff);
 		if (XS_NOERR(xs)) {
 			XS_SETERR(xs, HBA_NOERROR);
 		}
@@ -7384,8 +7316,7 @@ isp_spi_update(ispsoftc_t *isp, int chan
 		if (sdp->isp_devparam[tgt].dev_enable == 0) {
 			sdp->isp_devparam[tgt].dev_update = 0;
 			sdp->isp_devparam[tgt].dev_refresh = 0;
-			isp_prt(isp, ISP_LOGDEBUG0,
-	 		    "skipping target %d bus %d update", tgt, chan);
+			isp_prt(isp, ISP_LOGDEBUG0, "skipping target %d bus %d update", tgt, chan);
 			continue;
 		}
 		/*
@@ -7441,10 +7372,8 @@ isp_spi_update(ispsoftc_t *isp, int chan
 			sdp->isp_devparam[tgt].actv_flags &= ~DPARM_TQING;
 			sdp->isp_devparam[tgt].actv_flags |=
 			    (sdp->isp_devparam[tgt].goal_flags & DPARM_TQING);
-			isp_prt(isp, ISP_LOGDEBUG0,
-			    "bus %d set tgt %d flags 0x%x off 0x%x period 0x%x",
-			    chan, tgt, mbs.param[2], mbs.param[3] >> 8,
-			    mbs.param[3] & 0xff);
+			isp_prt(isp, ISP_LOGDEBUG0, "bus %d set tgt %d flags 0x%x off 0x%x period 0x%x",
+			    chan, tgt, mbs.param[2], mbs.param[3] >> 8, mbs.param[3] & 0xff);
 			get = 0;
 		} else {
 			continue;
@@ -7778,8 +7707,7 @@ isp_read_nvram(ispsoftc_t *isp, int bus)
 	    nvram_data[2] != 'P') {
 		if (isp->isp_bustype != ISP_BT_SBUS) {
 			isp_prt(isp, ISP_LOGWARN, "invalid NVRAM header");
-			isp_prt(isp, ISP_LOGDEBUG0, "%x %x %x",
-			    nvram_data[0], nvram_data[1], nvram_data[2]);
+			isp_prt(isp, ISP_LOGDEBUG0, "%x %x %x", nvram_data[0], nvram_data[1], nvram_data[2]);
 		}
 		retval = -1;
 		goto out;
@@ -8294,8 +8222,7 @@ isp_parse_nvram_2100(ispsoftc_t *isp, ui
 	    ISP2100_NVRAM_TOV(nvram_data));
 	fcp->isp_xfwoptions = ISP2100_XFW_OPTIONS(nvram_data);
 	fcp->isp_zfwoptions = ISP2100_ZFW_OPTIONS(nvram_data);
-	isp_prt(isp, ISP_LOGDEBUG0,
-	    "xfwoptions 0x%x zfw options 0x%x",
+	isp_prt(isp, ISP_LOGDEBUG0, "xfwoptions 0x%x zfw options 0x%x",
 	    ISP2100_XFW_OPTIONS(nvram_data), ISP2100_ZFW_OPTIONS(nvram_data));
 }
 

Modified: head/sys/dev/isp/isp_freebsd.c
==============================================================================
--- head/sys/dev/isp/isp_freebsd.c	Fri Mar 26 14:52:58 2010	(r205697)
+++ head/sys/dev/isp/isp_freebsd.c	Fri Mar 26 15:13:31 2010	(r205698)
@@ -5432,6 +5432,20 @@ isp_prt(ispsoftc_t *isp, int level, cons
 	printf("\n");
 }
 
+void
+isp_xs_prt(ispsoftc_t *isp, XS_T *xs, int level, const char *fmt, ...)
+{
+	va_list ap;
+	if (level != ISP_LOGALL && (level & isp->isp_dblev) == 0) {
+		return;
+	}
+	xpt_print_path(xs->ccb_h.path);
+	va_start(ap, fmt);
+	vprintf(fmt, ap);
+	va_end(ap);
+	printf("\n");
+}
+
 uint64_t
 isp_nanotime_sub(struct timespec *b, struct timespec *a)
 {

Modified: head/sys/dev/isp/isp_freebsd.h
==============================================================================
--- head/sys/dev/isp/isp_freebsd.h	Fri Mar 26 14:52:58 2010	(r205697)
+++ head/sys/dev/isp/isp_freebsd.h	Fri Mar 26 15:13:31 2010	(r205698)
@@ -424,6 +424,8 @@ default:							\
 	imin((sizeof((ccb)->sense_data)), ccb->sense_len)
 
 #define	XS_SNSKEY(ccb)		((ccb)->sense_data.flags & 0xf)
+#define	XS_SNSASC(ccb)		((ccb)->sense_data.add_sense_code)
+#define	XS_SNSASCQ(ccb)		((ccb)->sense_data.add_sense_code_qual)
 #define	XS_TAG_P(ccb)	\
 	(((ccb)->ccb_h.flags & CAM_TAG_ACTION_VALID) && \
 	 (ccb)->tag_action != CAM_TAG_ACTION_NONE)
@@ -461,7 +463,7 @@ default:							\
 	(xs)->ccb_h.status |= CAM_AUTOSNS_VALID;	\
 	memcpy(&(xs)->sense_data, sense_ptr, imin(XS_SNSLEN(xs), sense_len))
 
-#define	XS_SET_STATE_STAT(a, b, c)
+#define	XS_SENSE_VALID(xs)	(((xs)->ccb_h.status & CAM_AUTOSNS_VALID) != 0)
 
 #define	DEFAULT_FRAMESIZE(isp)		isp->isp_osinfo.framesize
 #define	DEFAULT_EXEC_THROTTLE(isp)	isp->isp_osinfo.exec_throttle
@@ -593,6 +595,7 @@ extern int isp_autoconfig;
  * Platform Library Functions
  */
 void isp_prt(ispsoftc_t *, int level, const char *, ...) __printflike(3, 4);
+void isp_xs_prt(ispsoftc_t *, XS_T *, int level, const char *, ...) __printflike(4, 5);
 uint64_t isp_nanotime_sub(struct timespec *, struct timespec *);
 int isp_mbox_acquire(ispsoftc_t *);
 void isp_mbox_wait_complete(ispsoftc_t *, mbreg_t *);

Modified: head/sys/dev/isp/ispvar.h
==============================================================================
--- head/sys/dev/isp/ispvar.h	Fri Mar 26 14:52:58 2010	(r205697)
+++ head/sys/dev/isp/ispvar.h	Fri Mar 26 15:13:31 2010	(r205698)
@@ -954,12 +954,13 @@ void isp_async(ispsoftc_t *, ispasync_t,
 /*
  * Platform Dependent Error and Debug Printout
  *
- * Generally this is:
+ * Two required functions for each platform must be provided:
  *
  *    void isp_prt(ispsoftc_t *, int level, const char *, ...)
+ *    void isp_xs_prt(ispsoftc_t *, XS_T *, int level, const char *, ...)
  *
  * but due to compiler differences on different platforms this won't be
- * formally done here. Instead, it goes in each platform definition file.
+ * formally defined here. Instead, they go in each platform definition file.
  */
 
 #define	ISP_LOGALL	0x0	/* log always */
@@ -972,6 +973,7 @@ void isp_async(ispsoftc_t *, ispasync_t,
 #define	ISP_LOGDEBUG2	0x40	/* log most debug messages */
 #define	ISP_LOGDEBUG3	0x80	/* log high frequency debug messages */
 #define	ISP_LOGSANCFG	0x100	/* log SAN configuration */
+#define	ISP_LOG_CWARN	0x200	/* log SCSI command "warnings" (e.g., check conditions) */
 #define	ISP_LOGTINFO	0x1000	/* log informational messages (target mode) */
 #define	ISP_LOGTDEBUG0	0x2000	/* log simple debug messages (target mode) */
 #define	ISP_LOGTDEBUG1	0x4000	/* log intermediate debug messages (target) */
@@ -1045,6 +1047,8 @@ void isp_async(ispsoftc_t *, ispasync_t,
  *	XS_SNSP(xs)		gets a pointer to the associate sense data
  *	XS_SNSLEN(xs)		gets the length of sense data storage
  *	XS_SNSKEY(xs)		dereferences XS_SNSP to get the current stored Sense Key
+ *	XS_SNSASC(xs)		dereferences XS_SNSP to get the current stored Additional Sense Code
+ *	XS_SNSASCQ(xs)		dereferences XS_SNSP to get the current stored Additional Sense Code Qualifier
  *	XS_TAG_P(xs)		predicate of whether this command should be tagged
  *	XS_TAG_TYPE(xs)		which type of tag to use
  *	XS_SETERR(xs)		set error state
@@ -1065,6 +1069,8 @@ void isp_async(ispsoftc_t *, ispasync_t,
  *
  *	XS_SAVE_SENSE(xs, sp, len)	save sense data
  *
+ *	XS_SENSE_VALID(xs)		indicates whether sense is valid
+ *
  *	DEFAULT_FRAMESIZE(ispsoftc_t *)		Default Frame Size
  *	DEFAULT_EXEC_THROTTLE(ispsoftc_t *)	Default Execution Throttle
  *


More information about the svn-src-head mailing list