PERFORCE change 111846 for review

Matt Jacob mjacob at FreeBSD.org
Sun Dec 17 09:04:46 PST 2006


http://perforce.freebsd.org/chv.cgi?CH=111846

Change 111846 by mjacob at mjexp on 2006/12/17 17:04:23

	Integrate a few useful changes.

Affected files ...

.. //depot/projects/mjexp/sys/dev/isp/isp.c#4 integrate
.. //depot/projects/mjexp/sys/dev/isp/isp_freebsd.c#5 integrate
.. //depot/projects/mjexp/sys/dev/isp/isp_pci.c#4 integrate
.. //depot/projects/mjexp/sys/dev/isp/isp_sbus.c#4 integrate
.. //depot/projects/mjexp/sys/dev/isp/ispmbox.h#4 integrate
.. //depot/projects/mjexp/sys/dev/mpt/mpt_cam.c#5 integrate

Differences ...

==== //depot/projects/mjexp/sys/dev/isp/isp.c#4 (text+ko) ====

@@ -43,7 +43,7 @@
 #endif
 #ifdef	__FreeBSD__
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/isp/isp.c,v 1.133 2006/12/05 07:50:23 mjacob Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/isp/isp.c,v 1.135 2006/12/17 16:59:18 mjacob Exp $");
 #include <dev/isp/isp_freebsd.h>
 #endif
 #ifdef	__OpenBSD__
@@ -524,6 +524,7 @@
 			}
 		} 
 		if (val & BIU2400_DMA_ACTIVE) {
+			ISP_RESET0(isp);
 			isp_prt(isp, ISP_LOGERR, "DMA Failed to Stop on Reset");
 			return;
 		}
@@ -544,6 +545,7 @@
 			}
 		}
 		if (val & BIU2400_SOFT_RESET) {
+			ISP_RESET0(isp);
 			isp_prt(isp, ISP_LOGERR, "Failed to come out of reset");
 			return;
 		}
@@ -585,6 +587,7 @@
 		USEC_DELAY(100);
 		if (--loops < 0) {
 			ISP_DUMPREGS(isp, "chip reset timed out");
+			ISP_RESET0(isp);
 			return;
 		}
 	}
@@ -626,6 +629,7 @@
 			}
 		}
 		if (val != 0) {
+			ISP_RESET0(isp);
 			isp_prt(isp, ISP_LOGERR, "reset didn't clear");
 			return;
 		}
@@ -691,6 +695,7 @@
 		while (ISP_READ(isp, OUTMAILBOX0) == MBOX_BUSY) {
 			USEC_DELAY(100);
 			if (--loops < 0) {
+				ISP_RESET0(isp);
 				isp_prt(isp, ISP_LOGERR,
 				    "MBOX_BUSY never cleared on reset");
 				return;
@@ -712,6 +717,7 @@
 	mbs.logval = MBLOGALL;
 	isp_mboxcmd(isp, &mbs);
 	if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
+		ISP_RESET0(isp);
 		return;
 	}
 
@@ -728,11 +734,13 @@
 		mbs.logval = MBLOGALL;
 		isp_mboxcmd(isp, &mbs);
 		if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
+			ISP_RESET0(isp);
 			return;
 		}
 		if (mbs.param[1] != 0xdead || mbs.param[2] != 0xbeef ||
 		    mbs.param[3] != 0xffff || mbs.param[4] != 0x1111 ||
 		    mbs.param[5] != 0xa5a5) {
+			ISP_RESET0(isp);
 			isp_prt(isp, ISP_LOGERR,
 			    "Register Test Failed (0x%x 0x%x 0x%x 0x%x 0x%x)",
 			    mbs.param[1], mbs.param[2], mbs.param[3],
@@ -820,6 +828,7 @@
 				if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
 					isp_prt(isp, ISP_LOGERR,
 					    "F/W Risc Ram Load Failed");
+					ISP_RESET0(isp);
 					return;
 				}
 				la += nw;
@@ -881,6 +890,7 @@
 				if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
 					isp_prt(isp, ISP_LOGERR,
 					    "F/W Risc Ram Load Failed");
+					ISP_RESET0(isp);
 					return;
 				}
 				la += nw;
@@ -897,6 +907,7 @@
 				isp_mboxcmd(isp, &mbs);
 				if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
 					isp_prt(isp, ISP_LOGERR, dcrc);
+					ISP_RESET0(isp);
 					return;
 				}
 				break;
@@ -935,6 +946,7 @@
 			isp_prt(isp, ISP_LOGERR,
 			    "F/W download failed at word %d",
 			    isp->isp_mbxwrk1 - code_org);
+			ISP_RESET0(isp);
 			return;
 		}
 		/*
@@ -947,6 +959,7 @@
 		isp_mboxcmd(isp, &mbs);
 		if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
 			isp_prt(isp, ISP_LOGERR, dcrc);
+			ISP_RESET0(isp);
 			return;
 		}
 		isp->isp_loaded_fw = 1;
@@ -989,6 +1002,7 @@
 	isp_mboxcmd(isp, &mbs);
 	if (IS_2322(isp) || IS_24XX(isp)) {
 		if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
+			ISP_RESET0(isp);
 			return;
 		}
 	}
@@ -1016,11 +1030,13 @@
 	mbs.logval = MBLOGALL;
 	isp_mboxcmd(isp, &mbs);
 	if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
+		ISP_RESET0(isp);
 		return;
 	}
 
 	if (IS_24XX(isp) && mbs.param[1] == 0xdead) {
 		isp_prt(isp, ISP_LOGERR, "f/w didn't *really* start");
+		ISP_RESET0(isp);
 		return;
 	}
 
@@ -1107,6 +1123,7 @@
 		mbs.logval = MBLOGALL;
 		isp_mboxcmd(isp, &mbs);
 		if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
+			ISP_RESET0(isp);
 			return;
 		}
 		if (isp->isp_maxcmds >= mbs.param[2]) {
@@ -6352,7 +6369,7 @@
 	ISPOPMAP(0xff, 0xff),	/* 0x06: MBOX_MAILBOX_REG_TEST */
 	ISPOPMAP(0x03, 0x07),	/* 0x07: MBOX_VERIFY_CHECKSUM	*/
 	ISPOPMAP(0x01, 0x4f),	/* 0x08: MBOX_ABOUT_FIRMWARE */
-	ISPOPMAP(0xdf, 0x01),	/* 0x09: LOAD RAM */
+	ISPOPMAP(0xdf, 0x01),	/* 0x09: MBOX_LOAD_RISC_RAM_2100 */
 	ISPOPMAP(0xdf, 0x01),	/* 0x0a: DUMP RAM */
 	ISPOPMAP(0x1ff, 0x01),	/* 0x0b: MBOX_LOAD_RISC_RAM */
 	ISPOPMAP(0x00, 0x00),	/* 0x0c: */

==== //depot/projects/mjexp/sys/dev/isp/isp_freebsd.c#5 (text+ko) ====

@@ -29,7 +29,7 @@
  * Platform (FreeBSD) dependent common attachment code for Qlogic adapters.
  */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/isp/isp_freebsd.c,v 1.130 2006/12/09 01:30:05 mjacob Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/isp/isp_freebsd.c,v 1.131 2006/12/17 16:59:18 mjacob Exp $");
 #include <dev/isp/isp_freebsd.h>
 #include <sys/unistd.h>
 #include <sys/kthread.h>
@@ -3458,42 +3458,52 @@
 void
 isp_mbox_wait_complete(ispsoftc_t *isp, mbreg_t *mbp)
 {
-	int usecs = mbp->timeout;
-	int j;
+	unsigned int usecs = mbp->timeout;
+	unsigned int max, olim, ilim;
 
 	if (usecs == 0) {
 		usecs = MBCMD_DEFAULT_TIMEOUT;
 	}
-	if (isp->isp_mbxwrk0) {
-		usecs *= isp->isp_mbxwrk0;
-	}
+	max = isp->isp_mbxwrk0 + 1;
+
 	if (isp->isp_osinfo.mbox_sleep_ok) {
-		int ms = usecs / 1000;
+		unsigned int ms = (usecs + 999) / 1000;
+
 		isp->isp_osinfo.mbox_sleep_ok = 0;
 		isp->isp_osinfo.mbox_sleeping = 1;
+		for (olim = 0; olim < max; olim++) {
 #if __FreeBSD_version < 500000  || !defined(ISP_SMPLOCK)
-		tsleep(&isp->isp_mbxworkp, PRIBIO, "ispmbx_sleep",
-		    isp_mstohz(ms));
+			tsleep(&isp->isp_mbxworkp, PRIBIO, "ispmbx_sleep",
+			    isp_mstohz(ms));
 #else
-		msleep(&isp->isp_mbxworkp, &isp->isp_mtx, PRIBIO,
-		    "ispmbx_sleep", isp_mstohz(ms));
+			msleep(&isp->isp_mbxworkp, &isp->isp_mtx, PRIBIO,
+			    "ispmbx_sleep", isp_mstohz(ms));
 #endif
+			if (isp->isp_osinfo.mboxcmd_done) {
+				break;
+			}
+		}
 		isp->isp_osinfo.mbox_sleep_ok = 1;
 		isp->isp_osinfo.mbox_sleeping = 0;
 	} else {
-		for (j = 0; j < usecs; j += 100) {
-			uint32_t isr;
-			uint16_t sema, mbox;
-			if (isp->isp_osinfo.mboxcmd_done) {
-				break;
-			}
-			if (ISP_READ_ISR(isp, &isr, &sema, &mbox)) {
-				isp_intr(isp, isr, sema, mbox);
+		for (olim = 0; olim < max; olim++) {
+			for (ilim = 0; ilim < usecs; ilim += 100) {
+				uint32_t isr;
+				uint16_t sema, mbox;
 				if (isp->isp_osinfo.mboxcmd_done) {
 					break;
 				}
+				if (ISP_READ_ISR(isp, &isr, &sema, &mbox)) {
+					isp_intr(isp, isr, sema, mbox);
+					if (isp->isp_osinfo.mboxcmd_done) {
+						break;
+					}
+				}
+				USEC_DELAY(100);
 			}
-			USEC_DELAY(100);
+			if (isp->isp_osinfo.mboxcmd_done) {
+				break;
+			}
 		}
 	}
 	if (isp->isp_osinfo.mboxcmd_done == 0) {
@@ -3524,12 +3534,16 @@
 int
 isp_mstohz(int ms)
 {
+	int hz;
 	struct timeval t;
 	t.tv_sec = ms / 1000;
 	t.tv_usec = (ms % 1000) * 1000;
-	ms = tvtohz(&t);
-	if (ms < 0) {
-		ms = 0x7fffffff;
+	hz = tvtohz(&t);
+	if (hz < 0) {
+		hz = 0x7fffffff;
+	}
+	if (hz == 0) {
+		hz = 1;
 	}
-	return (ms);
+	return (hz);
 }

==== //depot/projects/mjexp/sys/dev/isp/isp_pci.c#4 (text+ko) ====

@@ -30,7 +30,7 @@
  * FreeBSD Version.
  */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/isp/isp_pci.c,v 1.128 2006/12/10 03:41:48 mjacob Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/isp/isp_pci.c,v 1.129 2006/12/16 05:54:29 mjacob Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -81,6 +81,7 @@
 isp_pci_dmateardown(ispsoftc_t *, XS_T *, uint32_t);
 
 
+static void isp_pci_reset0(ispsoftc_t *);
 static void isp_pci_reset1(ispsoftc_t *);
 static void isp_pci_dumpregs(ispsoftc_t *, const char *);
 
@@ -91,7 +92,7 @@
 	isp_pci_mbxdma,
 	isp_pci_dmasetup,
 	isp_pci_dmateardown,
-	NULL,
+	isp_pci_reset0,
 	isp_pci_reset1,
 	isp_pci_dumpregs,
 	NULL,
@@ -105,7 +106,7 @@
 	isp_pci_mbxdma,
 	isp_pci_dmasetup,
 	isp_pci_dmateardown,
-	NULL,
+	isp_pci_reset0,
 	isp_pci_reset1,
 	isp_pci_dumpregs,
 	NULL,
@@ -119,7 +120,7 @@
 	isp_pci_mbxdma,
 	isp_pci_dmasetup,
 	isp_pci_dmateardown,
-	NULL,
+	isp_pci_reset0,
 	isp_pci_reset1,
 	isp_pci_dumpregs,
 	NULL,
@@ -133,7 +134,7 @@
 	isp_pci_mbxdma,
 	isp_pci_dmasetup,
 	isp_pci_dmateardown,
-	NULL,
+	isp_pci_reset0,
 	isp_pci_reset1,
 	isp_pci_dumpregs
 };
@@ -145,7 +146,7 @@
 	isp_pci_mbxdma,
 	isp_pci_dmasetup,
 	isp_pci_dmateardown,
-	NULL,
+	isp_pci_reset0,
 	isp_pci_reset1,
 	isp_pci_dumpregs
 };
@@ -157,7 +158,7 @@
 	isp_pci_mbxdma,
 	isp_pci_dmasetup,
 	isp_pci_dmateardown,
-	NULL,
+	isp_pci_reset0,
 	isp_pci_reset1,
 	isp_pci_dumpregs
 };
@@ -169,7 +170,7 @@
 	isp_pci_mbxdma,
 	isp_pci_dmasetup,
 	isp_pci_dmateardown,
-	NULL,
+	isp_pci_reset0,
 	isp_pci_reset1,
 	NULL
 };
@@ -2882,6 +2883,12 @@
 
 
 static void
+isp_pci_reset0(ispsoftc_t *isp)
+{
+	ISP_DISABLE_INTS(isp);
+}
+
+static void
 isp_pci_reset1(ispsoftc_t *isp)
 {
 	if (!IS_24XX(isp)) {

==== //depot/projects/mjexp/sys/dev/isp/isp_sbus.c#4 (text+ko) ====

@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/isp/isp_sbus.c,v 1.24 2006/12/10 03:41:48 mjacob Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/isp/isp_sbus.c,v 1.25 2006/12/16 05:54:29 mjacob Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -63,6 +63,7 @@
 static void
 isp_sbus_dmateardown(ispsoftc_t *, XS_T *, uint32_t);
 
+static void isp_sbus_reset0(ispsoftc_t *);
 static void isp_sbus_reset1(ispsoftc_t *);
 static void isp_sbus_dumpregs(ispsoftc_t *, const char *);
 
@@ -73,7 +74,7 @@
 	isp_sbus_mbxdma,
 	isp_sbus_dmasetup,
 	isp_sbus_dmateardown,
-	NULL,
+	isp_sbus_reset0,
 	isp_sbus_reset1,
 	isp_sbus_dumpregs,
 	NULL,
@@ -826,6 +827,12 @@
 }
 
 static void
+isp_sbus_reset0(ispsoftc_t *isp)
+{
+	ISP_DISABLE_INTS(isp);
+}
+
+static void
 isp_sbus_reset1(ispsoftc_t *isp)
 {
 	ISP_ENABLE_INTS(isp);

==== //depot/projects/mjexp/sys/dev/isp/ispmbox.h#4 (text+ko) ====

@@ -1,4 +1,4 @@
-/* $FreeBSD: src/sys/dev/isp/ispmbox.h,v 1.56 2006/12/09 01:33:55 mjacob Exp $ */
+/* $FreeBSD: src/sys/dev/isp/ispmbox.h,v 1.57 2006/12/17 16:59:19 mjacob Exp $ */
 /*-
  * Mailbox and Queue Entry Definitions for for Qlogic ISP SCSI adapters.
  *
@@ -42,7 +42,7 @@
 #define MBOX_MAILBOX_REG_TEST		0x0006
 #define MBOX_VERIFY_CHECKSUM		0x0007
 #define MBOX_ABOUT_FIRMWARE		0x0008
-					/*   9 */
+#define	MBOX_LOAD_RISC_RAM_2100		0x0009
 					/*   a */
 #define	MBOX_LOAD_RISC_RAM		0x000b
 					/*   c */

==== //depot/projects/mjexp/sys/dev/mpt/mpt_cam.c#5 (text+ko) ====

@@ -94,7 +94,7 @@
  * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/mpt/mpt_cam.c,v 1.46 2006/12/10 01:13:56 mjacob Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/mpt/mpt_cam.c,v 1.47 2006/12/16 07:39:55 mjacob Exp $");
 
 #include <dev/mpt/mpt.h>
 #include <dev/mpt/mpt_cam.h>
@@ -110,6 +110,12 @@
 #include <sys/callout.h>
 #include <sys/kthread.h>
 
+#if __FreeBSD_version >= 700000
+#ifndef	CAM_NEW_TRAN_CODE
+#define	CAM_NEW_TRAN_CODE	1
+#endif
+#endif
+
 static void mpt_poll(struct cam_sim *);
 static timeout_t mpt_timeout;
 static void mpt_action(struct cam_sim *, union ccb *);
@@ -2951,7 +2957,11 @@
 		break;
 	}
 
+#ifdef	CAM_NEW_TRAN_CODE
 #define	IS_CURRENT_SETTINGS(c)	((c)->type == CTS_TYPE_CURRENT_SETTINGS)
+#else
+#define	IS_CURRENT_SETTINGS(c)	((c)->flags & CCB_TRANS_CURRENT_SETTINGS)
+#endif
 #define	DP_DISC_ENABLE	0x1
 #define	DP_DISC_DISABL	0x2
 #define	DP_DISC		(DP_DISC_ENABLE|DP_DISC_DISABL)
@@ -2968,8 +2978,10 @@
 
 	case XPT_SET_TRAN_SETTINGS:	/* Nexus Settings */
 	{
+#ifdef	CAM_NEW_TRAN_CODE
 		struct ccb_trans_settings_scsi *scsi;
 		struct ccb_trans_settings_spi *spi;
+#endif
 		uint8_t dval;
 		u_int period;
 		u_int offset;
@@ -2982,6 +2994,7 @@
 			break;
 		}
 
+#ifdef	CAM_NEW_TRAN_CODE
 		scsi = &cts->proto_specific.scsi;
 		spi = &cts->xport_specific.spi;
 
@@ -2992,6 +3005,7 @@
 			mpt_set_ccb_status(ccb, CAM_REQ_CMP);
 			break;
 		}
+#endif
 
 		/*
 		 * Skip attempting settings on RAID volume disks.
@@ -3021,6 +3035,28 @@
 		period = 0;
 		offset = 0;
 
+#ifndef	CAM_NEW_TRAN_CODE
+		if ((cts->valid & CCB_TRANS_DISC_VALID) != 0) {
+			dval |= (cts->flags & CCB_TRANS_DISC_ENB) ?
+			    DP_DISC_ENABLE : DP_DISC_DISABL;
+		}
+
+		if ((cts->valid & CCB_TRANS_TQ_VALID) != 0) {
+			dval |= (cts->flags & CCB_TRANS_TAG_ENB) ?
+			    DP_TQING_ENABLE : DP_TQING_DISABL;
+		}
+
+		if ((cts->valid & CCB_TRANS_BUS_WIDTH_VALID) != 0) {
+			dval |= cts->bus_width ? DP_WIDE : DP_NARROW;
+		}
+
+		if ((cts->valid & CCB_TRANS_SYNC_RATE_VALID) &&
+		    (cts->valid & CCB_TRANS_SYNC_OFFSET_VALID)) {
+			dval |= DP_SYNC;
+			period = cts->sync_period;
+			offset = cts->sync_offset;
+		}
+#else
 		if ((spi->valid & CTS_SPI_VALID_DISC) != 0) {
 			dval |= ((spi->flags & CTS_SPI_FLAGS_DISC_ENB) != 0) ?
 			    DP_DISC_ENABLE : DP_DISC_DISABL;
@@ -3056,6 +3092,7 @@
 			period &= MPI_SCSIDEVPAGE1_RP_MIN_SYNC_PERIOD_MASK;
 	    		period >>= MPI_SCSIDEVPAGE1_RP_SHIFT_MIN_SYNC_PERIOD;
 		}
+#endif
 		CAMLOCK_2_MPTLOCK(mpt);
 		if (dval & DP_DISC_ENABLE) {
 			mpt->mpt_disc_enable |= (1 << tgt);
@@ -3091,8 +3128,10 @@
 	}
 	case XPT_GET_TRAN_SETTINGS:
 	{
+#ifdef	CAM_NEW_TRAN_CODE
+		struct ccb_trans_settings_scsi *scsi;
 		cts = &ccb->cts;
-		struct ccb_trans_settings_scsi *scsi;
+		cts->protocol = PROTO_SCSI;
 		if (mpt->is_fc) {
 			struct ccb_trans_settings_fc *fc =
 			    &cts->xport_specific.fc;
@@ -3104,24 +3143,38 @@
 		} else if (mpt->is_sas) {
 			struct ccb_trans_settings_sas *sas =
 			    &cts->xport_specific.sas;
-
 			cts->protocol_version = SCSI_REV_SPC2;
 			cts->transport = XPORT_SAS;
 			cts->transport_version = 0;
 			sas->valid = CTS_SAS_VALID_SPEED;
 			sas->bitrate = 300000;
 		} else {
+			cts->protocol_version = SCSI_REV_2;
+			cts->transport = XPORT_SPI;
+			cts->transport_version = 2;
 			if (mpt_get_spi_settings(mpt, cts) != 0) {
 				mpt_set_ccb_status(ccb, CAM_REQ_CMP_ERR);
-			} else {
-				mpt_set_ccb_status(ccb, CAM_REQ_CMP);
+				break;
 			}
-			break;
 		}
-		cts->protocol = PROTO_SCSI;
 		scsi = &cts->proto_specific.scsi;
 		scsi->valid = CTS_SCSI_VALID_TQ;
 		scsi->flags = CTS_SCSI_FLAGS_TAG_ENB;
+#else
+		cts = &ccb->cts;
+		if (mpt->is_fc) {
+			cts->flags = CCB_TRANS_TAG_ENB | CCB_TRANS_DISC_ENB;
+			cts->valid = CCB_TRANS_DISC_VALID | CCB_TRANS_TQ_VALID;
+			cts->bus_width = MSG_EXT_WDTR_BUS_8_BIT;
+		} else if (mpt->is_sas) {
+			cts->flags = CCB_TRANS_TAG_ENB | CCB_TRANS_DISC_ENB;
+			cts->valid = CCB_TRANS_DISC_VALID | CCB_TRANS_TQ_VALID;
+			cts->bus_width = MSG_EXT_WDTR_BUS_8_BIT;
+		} else if (mpt_get_spi_settings(mpt, cts) != 0) {
+			mpt_set_ccb_status(ccb, CAM_REQ_CMP_ERR);
+			break;
+		}
+#endif
 		mpt_set_ccb_status(ccb, CAM_REQ_CMP);
 		break;
 	}
@@ -3296,18 +3349,15 @@
 static int
 mpt_get_spi_settings(struct mpt_softc *mpt, struct ccb_trans_settings *cts)
 {
+#ifdef	CAM_NEW_TRAN_CODE
 	struct ccb_trans_settings_scsi *scsi = &cts->proto_specific.scsi;
 	struct ccb_trans_settings_spi *spi = &cts->xport_specific.spi;
+#endif
 	target_id_t tgt;
 	uint32_t dval, pval, oval;
 	int rv;
 
-	cts->protocol = PROTO_SCSI;
-	cts->protocol_version = SCSI_REV_2;
-	cts->transport = XPORT_SPI;
-	cts->transport_version = 2;
-
-	if (cts->type == CTS_TYPE_USER_SETTINGS) {
+	if (IS_CURRENT_SETTINGS(cts) == 0) {
 		tgt = cts->ccb_h.target_id;
 	} else if (xpt_path_sim(cts->ccb_h.path) == mpt->phydisk_sim) {
 		if (mpt_map_physdisk(mpt, (union ccb *)cts, &tgt)) {
@@ -3364,6 +3414,29 @@
 		pval = MPI_SCSIPORTPAGE0_CAP_GET_MIN_SYNC_PERIOD(pval);
 	}
 
+#ifndef	CAM_NEW_TRAN_CODE
+	cts->flags &= ~(CCB_TRANS_DISC_ENB|CCB_TRANS_TAG_ENB);
+	cts->valid = 0;
+	cts->sync_period = pval;
+	cts->sync_offset = oval;
+	cts->valid |= CCB_TRANS_SYNC_RATE_VALID;
+	cts->valid |= CCB_TRANS_SYNC_OFFSET_VALID;
+	cts->valid |= CCB_TRANS_BUS_WIDTH_VALID;
+	if (dval & DP_WIDE) {
+		cts->bus_width = MSG_EXT_WDTR_BUS_16_BIT;
+	} else {
+		cts->bus_width = MSG_EXT_WDTR_BUS_8_BIT;
+	}
+	if (cts->ccb_h.target_lun != CAM_LUN_WILDCARD) {
+		cts->valid |= CCB_TRANS_DISC_VALID | CCB_TRANS_TQ_VALID;
+		if (dval & DP_DISC_ENABLE) {
+			cts->flags |= CCB_TRANS_DISC_ENB;
+		}
+		if (dval & DP_TQING_ENABLE) {
+			cts->flags |= CCB_TRANS_TAG_ENB;
+		}
+	}
+#else
 	spi->valid = 0;
 	scsi->valid = 0;
 	spi->flags = 0;
@@ -3388,6 +3461,7 @@
 			spi->flags |= CTS_SPI_FLAGS_DISC_ENB;
 		}
 	}
+#endif
 	mpt_lprt(mpt, MPT_PRT_NEGOTIATION,
 	    "mpt_get_spi_settings[%d]: %s flags 0x%x per 0x%x off=%d\n", tgt,
 	    IS_CURRENT_SETTINGS(cts)? "ACTIVE" : "NVRAM ", dval, pval, oval);


More information about the p4-projects mailing list