svn commit: r367857 - in head: share/man/man4 sys/dev/isp sys/dev/ispfw sys/modules/ispfw sys/modules/ispfw/isp_1000 sys/modules/ispfw/isp_1040 sys/modules/ispfw/isp_1080 sys/modules/ispfw/isp_1216...

Alexander Motin mav at FreeBSD.org
Fri Nov 20 01:15:49 UTC 2020


Author: mav
Date: Fri Nov 20 01:15:48 2020
New Revision: 367857
URL: https://svnweb.freebsd.org/changeset/base/367857

Log:
  Remove parallel SCSI and 1/2Gb FC support from isp(4).
  
  This removes 288KB (36%) of the driver code and zillions of hacks and
  workarounds, making single driver uniformly support several different
  generations of hardware interfaces, not counting minor card variations.
  After years of the hopeless fight, I don't think it worth to continue
  support for hardware obsolete for 15-20 years.  Instead much cleaner
  now code should allow to move forward toward better locking, multiple
  queues and other cool features.
  
  All the remaining Qlogic cards starting from 4Gb 24xx to 32Gb 27xx use
  the same hardware/firmware interface with minor incremental improvements,
  so it seems to be a good new starting point.  Except one PCI-X model all
  all of them are PCIe and so still usable in modern systems.
  
  Discussed with:	ken, scottl, jpaetzel, imp
  Relnotes:	yes

Deleted:
  head/sys/dev/ispfw/asm_1040.h
  head/sys/dev/ispfw/asm_1080.h
  head/sys/dev/ispfw/asm_12160.h
  head/sys/dev/ispfw/asm_2100.h
  head/sys/dev/ispfw/asm_2200.h
  head/sys/dev/ispfw/asm_2300.h
  head/sys/dev/ispfw/asm_2322.h
  head/sys/modules/ispfw/isp_1000/
  head/sys/modules/ispfw/isp_1040/
  head/sys/modules/ispfw/isp_1080/
  head/sys/modules/ispfw/isp_12160/
  head/sys/modules/ispfw/isp_2100/
  head/sys/modules/ispfw/isp_2200/
  head/sys/modules/ispfw/isp_2300/
  head/sys/modules/ispfw/isp_2322/
Modified:
  head/share/man/man4/isp.4
  head/share/man/man4/ispfw.4
  head/sys/dev/isp/isp.c
  head/sys/dev/isp/isp_freebsd.c
  head/sys/dev/isp/isp_freebsd.h
  head/sys/dev/isp/isp_library.c
  head/sys/dev/isp/isp_library.h
  head/sys/dev/isp/isp_pci.c
  head/sys/dev/isp/isp_target.c
  head/sys/dev/isp/ispmbox.h
  head/sys/dev/isp/ispreg.h
  head/sys/dev/isp/ispvar.h
  head/sys/dev/ispfw/ispfw.c
  head/sys/modules/ispfw/Makefile

Modified: head/share/man/man4/isp.4
==============================================================================
--- head/share/man/man4/isp.4	Fri Nov 20 00:30:58 2020	(r367856)
+++ head/share/man/man4/isp.4	Fri Nov 20 01:15:48 2020	(r367857)
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2009-2018 Alexander Motin <mav at FreeBSD.org>
+.\" Copyright (c) 2009-2020 Alexander Motin <mav at FreeBSD.org>
 .\" Copyright (c) 2006 Marcus Alves Grando
 .\" Copyright (c) 1998-2001 Matthew Jacob, for NASA/Ames Research Center
 .\"
@@ -26,12 +26,12 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 28, 2019
+.Dd November 19, 2020
 .Dt ISP 4
 .Os
 .Sh NAME
 .Nm isp
-.Nd Qlogic based SPI and FibreChannel SCSI Host Adapters
+.Nd Qlogic FibreChannel SCSI Host Adapters driver
 .Sh SYNOPSIS
 To compile this driver into the kernel,
 place the following lines in your
@@ -51,23 +51,16 @@ ispfw_load="YES"
 .Ed
 .Sh DESCRIPTION
 This driver provides access to
-.Tn SPI
-or
 .Tn FibreChannel
 SCSI devices.
 .Pp
-SPI supports initiator mode for Ultra SCSI and wide mode transactions for
-.Tn SCSI ,
-Ultra2 LVD (1080, 1280), and Ultra3 LVD (10160, 12160).
-.Pp
-Fibre Channel supports initiator and target modes of FCP SCSI profile,
-utilizing Class 3 and Class 2 (2200 and later) connections.
+It supports initiator and target modes of FCP SCSI profile,
+utilizing Class 3 and Class 2 connections.
 Support is available for Public and Private loops, Point-to-Point
 and Fabric connections.
 .Pp
-FC-Tape is supported on 4Gb (2400) and newer controllers.
-FC-Tape is highly recommended for connections to tape drives that support
-it.
+Supported FC-Tape functionality is highly recommended for connections
+to tape drives that support it.
 It encompasses four elements from the T-10 FCP-4 specification:
 .Bl -bullet -offset indent
 .It
@@ -100,39 +93,8 @@ Cards supported by the
 .Nm
 driver include:
 .Bl -tag -width xxxxxx -offset indent
-.It Qlogic 1000
-Fast Wide, Ultra Fast Wide cards, Single Ended or Differential SBus cards.
-.It Qlogic 1020
-Fast Wide and Differential Fast Wide SCSI PCI cards.
-.It Qlogic 1040
-Ultra Wide and Differential Ultra Wide SCSI PCI cards.
-Also known as the DEC KZPBA-CA (single ended) and KZPBA-CB (HVD differential).
-.It Qlogic 1080
-LVD Ultra2 Wide SCSI PCI cards.
-.It Qlogic 10160
-LVD Ultra3 Wide SCSI PCI cards.
-.It Qlogic 1240
-Dual Bus Ultra Wide and Differential Ultra Wide SCSI PCI cards.
-.It Qlogic 1280
-Dual Bus LVD Ultra2 Wide SCSI PCI cards.
-.It Qlogic 12160
-Dual Bus LVD Ultra3 Wide SCSI PCI cards.
-.It Qlogic 210X
-Copper and Optical Fibre Channel Arbitrated Loop PCI cards (single, dual).
-.It Qlogic 220X
-Copper and Optical Fibre Channel Arbitrated Loop PCI cards (single, dual, quad).
-.It Qlogic 2300
-Optical 2Gb Fibre Channel PCI cards.
-.It Qlogic 2312
-Optical 2Gb Fibre Channel PCI cards.
-.It Qlogic 234X
-Optical 2Gb Fibre Channel PCI cards (2312 chipset, single and dual attach).
-.It Qlogic 2322
-Optical 2Gb Fibre Channel PCIe cards.
-.It Qlogic 200
-Dell branded version of the QLogic 2312.
 .It Qlogic 2422
-Optical 4Gb Fibre Channel PCI cards.
+Optical 4Gb Fibre Channel PCI-X cards.
 .It Qlogic 246x (aka 2432)
 Optical 4Gb Fibre Channel PCIe cards.
 .It Qlogic 256x (aka 2532)
@@ -260,6 +222,3 @@ Later improvement was done by
 .An Alexander Motin Aq Mt mav at FreeBSD.org .
 .Sh BUGS
 The driver currently ignores some NVRAM settings.
-.Pp
-Fabric support for 2100 cards has been so problematic, and these cards are so
-old now that it is just not worth your time to try it.

Modified: head/share/man/man4/ispfw.4
==============================================================================
--- head/share/man/man4/ispfw.4	Fri Nov 20 00:30:58 2020	(r367856)
+++ head/share/man/man4/ispfw.4	Fri Nov 20 01:15:48 2020	(r367857)
@@ -1,5 +1,5 @@
-.\" Copyright (c) 2000
-.\"     Matthew Jacob
+.\" Copyright (c) 2009-2020 Alexander Motin <mav at FreeBSD.org>
+.\" Copyright (c) 2000 Matthew Jacob
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -22,12 +22,12 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 30, 2015
+.Dd November 19, 2020
 .Dt ISPFW 4
 .Os
 .Sh NAME
 .Nm ispfw
-.Nd "Firmware for Qlogic based SPI and FibreChannel SCSI Host Adapters"
+.Nd "Firmware for Qlogic FibreChannel SCSI Host Adapters"
 .Sh SYNOPSIS
 To compile this driver into the kernel,
 place the following line in your
@@ -44,7 +44,7 @@ ispfw_load="YES"
 .Ed
 .Sh DESCRIPTION
 This trivial driver provides access to firmware sets for the Qlogic
-based SPI and FibreChannel SCSI Host Adapters.
+FibreChannel SCSI Host Adapters.
 It may either be
 statically linked into the kernel, or loaded as a module.
 In either
@@ -58,3 +58,5 @@ This will kick the f/w into getting unstuck.
 .Sh AUTHORS
 This driver was written by
 .An Matthew Jacob .
+Later improvement was done by
+.An Alexander Motin Aq Mt mav at FreeBSD.org .

Modified: head/sys/dev/isp/isp.c
==============================================================================
--- head/sys/dev/isp/isp.c	Fri Nov 20 00:30:58 2020	(r367856)
+++ head/sys/dev/isp/isp.c	Fri Nov 20 01:15:48 2020	(r367857)
@@ -1,7 +1,7 @@
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
- *  Copyright (c) 2009-2018 Alexander Motin <mav at FreeBSD.org>
+ *  Copyright (c) 2009-2020 Alexander Motin <mav at FreeBSD.org>
  *  Copyright (c) 1997-2009 by Matthew Jacob
  *  All rights reserved.
  *
@@ -98,21 +98,11 @@ static const uint8_t alpa_map[] = {
 /*
  * Local function prototypes.
  */
-static void isp_parse_async(ispsoftc_t *, uint16_t);
-static void isp_parse_async_fc(ispsoftc_t *, uint16_t);
 static int isp_handle_other_response(ispsoftc_t *, int, isphdr_t *, uint32_t *);
-static void isp_parse_status(ispsoftc_t *, ispstatusreq_t *, XS_T *, uint32_t *);
 static void isp_parse_status_24xx(ispsoftc_t *, isp24xx_statusreq_t *, XS_T *, uint32_t *);
-static void isp_fastpost_complete(ispsoftc_t *, uint32_t);
-static void isp_scsi_init(ispsoftc_t *);
-static void isp_scsi_channel_init(ispsoftc_t *, int);
-static void isp_fibre_init(ispsoftc_t *);
-static void isp_fibre_init_2400(ispsoftc_t *);
 static void isp_clear_portdb(ispsoftc_t *, int);
 static void isp_mark_portdb(ispsoftc_t *, int);
 static int isp_plogx(ispsoftc_t *, int, uint16_t, uint32_t, int);
-static int isp_port_login(ispsoftc_t *, uint16_t, uint32_t);
-static int isp_port_logout(ispsoftc_t *, uint16_t, uint32_t);
 static int isp_getpdb(ispsoftc_t *, int, uint16_t, isp_pdb_t *);
 static int isp_gethandles(ispsoftc_t *, int, uint16_t *, int *, int);
 static void isp_dump_chip_portdb(ispsoftc_t *, int);
@@ -123,7 +113,6 @@ static int isp_scan_loop(ispsoftc_t *, int);
 static int isp_gid_pt(ispsoftc_t *, int);
 static int isp_scan_fabric(ispsoftc_t *, int);
 static int isp_login_device(ispsoftc_t *, int, uint32_t, isp_pdb_t *, uint16_t *);
-static int isp_send_change_request(ispsoftc_t *, int);
 static int isp_register_fc4_type(ispsoftc_t *, int);
 static int isp_register_fc4_features_24xx(ispsoftc_t *, int);
 static int isp_register_port_name_24xx(ispsoftc_t *, int);
@@ -132,17 +121,10 @@ static uint16_t isp_next_handle(ispsoftc_t *, uint16_t
 static int isp_fw_state(ispsoftc_t *, int);
 static void isp_mboxcmd(ispsoftc_t *, mbreg_t *);
 
-static void isp_spi_update(ispsoftc_t *, int);
-static void isp_setdfltsdparm(ispsoftc_t *);
 static void isp_setdfltfcparm(ispsoftc_t *, int);
 static int isp_read_nvram(ispsoftc_t *, int);
-static int isp_read_nvram_2400(ispsoftc_t *, uint8_t *);
-static void isp_rdnvram_word(ispsoftc_t *, int, uint16_t *);
+static int isp_read_nvram_2400(ispsoftc_t *);
 static void isp_rd_2400_nvram(ispsoftc_t *, uint32_t, uint32_t *);
-static void isp_parse_nvram_1020(ispsoftc_t *, uint8_t *);
-static void isp_parse_nvram_1080(ispsoftc_t *, int, uint8_t *);
-static void isp_parse_nvram_12160(ispsoftc_t *, int, uint8_t *);
-static void isp_parse_nvram_2100(ispsoftc_t *, uint8_t *);
 static void isp_parse_nvram_2400(ispsoftc_t *, uint8_t *);
 
 static void
@@ -177,16 +159,6 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults)
 	const char *btype = "????";
 	static const char dcrc[] = "Downloaded RISC Code Checksum Failure";
 
-	/*
-	 * Basic types (SCSI, FibreChannel and PCI or SBus)
-	 * have been set in the MD code. We figure out more
-	 * here. Possibly more refined types based upon PCI
-	 * identification. Chip revision has been gathered.
-	 *
-	 * After we've fired this chip up, zero out the conf1 register
-	 * for SCSI adapters and do other settings for the 2100.
-	 */
-
 	isp->isp_state = ISP_NILSTATE;
 	ISP_DISABLE_INTS(isp);
 
@@ -194,229 +166,25 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults)
 	 * Put the board into PAUSE mode (so we can read the SXP registers
 	 * or write FPM/FBM registers).
 	 */
-	if (IS_24XX(isp)) {
-		ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_HOST_INT);
-		ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RISC_INT);
-		ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_PAUSE);
-	} else {
-		ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE);
-	}
+	ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_HOST_INT);
+	ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RISC_INT);
+	ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_PAUSE);
 
-	if (IS_FC(isp)) {
-		switch (isp->isp_type) {
-		case ISP_HA_FC_2100:
-			btype = "2100";
-			break;
-		case ISP_HA_FC_2200:
-			btype = "2200";
-			break;
-		case ISP_HA_FC_2300:
-			btype = "2300";
-			break;
-		case ISP_HA_FC_2312:
-			btype = "2312";
-			break;
-		case ISP_HA_FC_2322:
-			btype = "2322";
-			break;
-		case ISP_HA_FC_2400:
-			btype = "2422";
-			break;
-		case ISP_HA_FC_2500:
-			btype = "2532";
-			break;
-		case ISP_HA_FC_2600:
-			btype = "2600";
-			break;
-		case ISP_HA_FC_2700:
-			btype = "2700";
-			break;
-		default:
-			break;
-		}
-
-		if (!IS_24XX(isp)) {
-			/*
-			 * While we're paused, reset the FPM module and FBM
-			 * fifos.
-			 */
-			ISP_WRITE(isp, BIU2100_CSR, BIU2100_FPM0_REGS);
-			ISP_WRITE(isp, FPM_DIAG_CONFIG, FPM_SOFT_RESET);
-			ISP_WRITE(isp, BIU2100_CSR, BIU2100_FB_REGS);
-			ISP_WRITE(isp, FBM_CMD, FBMCMD_FIFO_RESET_ALL);
-			ISP_WRITE(isp, BIU2100_CSR, BIU2100_RISC_REGS);
-		}
-	} else if (IS_1240(isp)) {
-		sdparam *sdp;
-
-		btype = "1240";
-		isp->isp_clock = 60;
-		sdp = SDPARAM(isp, 0);
-		sdp->isp_ultramode = 1;
-		sdp = SDPARAM(isp, 1);
-		sdp->isp_ultramode = 1;
-		/*
-		 * XXX: Should probably do some bus sensing.
-		 */
-	} else if (IS_ULTRA3(isp)) {
-		sdparam *sdp = isp->isp_param;
-
-		isp->isp_clock = 100;
-
-		if (IS_10160(isp))
-			btype = "10160";
-		else if (IS_12160(isp))
-			btype = "12160";
-		else
-			btype = "<UNKLVD>";
-		sdp->isp_lvdmode = 1;
-
-		if (IS_DUALBUS(isp)) {
-			sdp++;
-			sdp->isp_lvdmode = 1;
-		}
-	} else if (IS_ULTRA2(isp)) {
-		static const char m[] = "bus %d is in %s Mode";
-		uint16_t l;
-		sdparam *sdp = SDPARAM(isp, 0);
-
-		isp->isp_clock = 100;
-
-		if (IS_1280(isp))
-			btype = "1280";
-		else if (IS_1080(isp))
-			btype = "1080";
-		else
-			btype = "<UNKLVD>";
-
-		l = ISP_READ(isp, SXP_PINS_DIFF) & ISP1080_MODE_MASK;
-		switch (l) {
-		case ISP1080_LVD_MODE:
-			sdp->isp_lvdmode = 1;
-			isp_prt(isp, ISP_LOGCONFIG, m, 0, "LVD");
-			break;
-		case ISP1080_HVD_MODE:
-			sdp->isp_diffmode = 1;
-			isp_prt(isp, ISP_LOGCONFIG, m, 0, "Differential");
-			break;
-		case ISP1080_SE_MODE:
-			sdp->isp_ultramode = 1;
-			isp_prt(isp, ISP_LOGCONFIG, m, 0, "Single-Ended");
-			break;
-		default:
-			isp_prt(isp, ISP_LOGERR,
-			    "unknown mode on bus %d (0x%x)", 0, l);
-			break;
-		}
-
-		if (IS_DUALBUS(isp)) {
-			sdp = SDPARAM(isp, 1);
-			l = ISP_READ(isp, SXP_PINS_DIFF|SXP_BANK1_SELECT);
-			l &= ISP1080_MODE_MASK;
-			switch (l) {
-			case ISP1080_LVD_MODE:
-				sdp->isp_lvdmode = 1;
-				isp_prt(isp, ISP_LOGCONFIG, m, 1, "LVD");
-				break;
-			case ISP1080_HVD_MODE:
-				sdp->isp_diffmode = 1;
-				isp_prt(isp, ISP_LOGCONFIG,
-				    m, 1, "Differential");
-				break;
-			case ISP1080_SE_MODE:
-				sdp->isp_ultramode = 1;
-				isp_prt(isp, ISP_LOGCONFIG,
-				    m, 1, "Single-Ended");
-				break;
-			default:
-				isp_prt(isp, ISP_LOGERR,
-				    "unknown mode on bus %d (0x%x)", 1, l);
-				break;
-			}
-		}
-	} else {
-		sdparam *sdp = SDPARAM(isp, 0);
-		i = ISP_READ(isp, BIU_CONF0) & BIU_CONF0_HW_MASK;
-		switch (i) {
-		default:
-			isp_prt(isp, ISP_LOGALL, "Unknown Chip Type 0x%x", i);
-			/* FALLTHROUGH */
-		case 1:
-			btype = "1020";
-			isp->isp_type = ISP_HA_SCSI_1020;
-			isp->isp_clock = 40;
-			break;
-		case 2:
-			/*
-			 * Some 1020A chips are Ultra Capable, but don't
-			 * run the clock rate up for that unless told to
-			 * do so by the Ultra Capable bits being set.
-			 */
-			btype = "1020A";
-			isp->isp_type = ISP_HA_SCSI_1020A;
-			isp->isp_clock = 40;
-			break;
-		case 3:
-			btype = "1040";
-			isp->isp_type = ISP_HA_SCSI_1040;
-			isp->isp_clock = 60;
-			break;
-		case 4:
-			btype = "1040A";
-			isp->isp_type = ISP_HA_SCSI_1040A;
-			isp->isp_clock = 60;
-			break;
-		case 5:
-			btype = "1040B";
-			isp->isp_type = ISP_HA_SCSI_1040B;
-			isp->isp_clock = 60;
-			break;
-		case 6:
-			btype = "1040C";
-			isp->isp_type = ISP_HA_SCSI_1040C;
-			isp->isp_clock = 60;
-                        break;
-		}
-		/*
-		 * Now, while we're at it, gather info about ultra
-		 * and/or differential mode.
-		 */
-		if (ISP_READ(isp, SXP_PINS_DIFF) & SXP_PINS_DIFF_MODE) {
-			isp_prt(isp, ISP_LOGCONFIG, "Differential Mode");
-			sdp->isp_diffmode = 1;
-		} else {
-			sdp->isp_diffmode = 0;
-		}
-		i = ISP_READ(isp, RISC_PSR);
-		if (isp->isp_bustype == ISP_BT_SBUS) {
-			i &= RISC_PSR_SBUS_ULTRA;
-		} else {
-			i &= RISC_PSR_PCI_ULTRA;
-		}
-		if (i != 0) {
-			isp_prt(isp, ISP_LOGCONFIG, "Ultra Mode Capable");
-			sdp->isp_ultramode = 1;
-			/*
-			 * If we're in Ultra Mode, we have to be 60MHz clock-
-			 * even for the SBus version.
-			 */
-			isp->isp_clock = 60;
-		} else {
-			sdp->isp_ultramode = 0;
-			/*
-			 * Clock is known. Gronk.
-			 */
-		}
-
-		/*
-		 * Machine dependent clock (if set) overrides
-		 * our generic determinations.
-		 */
-		if (isp->isp_mdvec->dv_clock) {
-			if (isp->isp_mdvec->dv_clock < isp->isp_clock) {
-				isp->isp_clock = isp->isp_mdvec->dv_clock;
-			}
-		}
+	switch (isp->isp_type) {
+	case ISP_HA_FC_2400:
+		btype = "2422";
+		break;
+	case ISP_HA_FC_2500:
+		btype = "2532";
+		break;
+	case ISP_HA_FC_2600:
+		btype = "2600";
+		break;
+	case ISP_HA_FC_2700:
+		btype = "2700";
+		break;
+	default:
+		break;
 	}
 
 	/*
@@ -424,87 +192,48 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults)
 	 * and give it a chance to recover.
 	 */
 
-	if (IS_SCSI(isp)) {
-		ISP_WRITE(isp, BIU_ICR, BIU_ICR_SOFT_RESET);
-		/*
-		 * A slight delay...
-		 */
-		ISP_DELAY(100);
-
-		/*
-		 * Clear data && control DMA engines.
-		 */
-		ISP_WRITE(isp, CDMA_CONTROL, DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT);
-		ISP_WRITE(isp, DDMA_CONTROL, DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT);
-
-
-	} else if (IS_24XX(isp)) {
-		/*
-		 * Stop DMA and wait for it to stop.
-		 */
-		ISP_WRITE(isp, BIU2400_CSR, BIU2400_DMA_STOP|(3 << 4));
-		for (val = loops = 0; loops < 30000; loops++) {
-			ISP_DELAY(10);
-			val = ISP_READ(isp, BIU2400_CSR);
-			if ((val & BIU2400_DMA_ACTIVE) == 0) {
-				break;
-			}
+	/*
+	 * Stop DMA and wait for it to stop.
+	 */
+	ISP_WRITE(isp, BIU2400_CSR, BIU2400_DMA_STOP|(3 << 4));
+	for (val = loops = 0; loops < 30000; loops++) {
+		ISP_DELAY(10);
+		val = ISP_READ(isp, BIU2400_CSR);
+		if ((val & BIU2400_DMA_ACTIVE) == 0) {
+			break;
 		}
-		if (val & BIU2400_DMA_ACTIVE) {
-			isp_prt(isp, ISP_LOGERR, "DMA Failed to Stop on Reset");
-			return;
+	}
+	if (val & BIU2400_DMA_ACTIVE) {
+		isp_prt(isp, ISP_LOGERR, "DMA Failed to Stop on Reset");
+		return;
+	}
+	/*
+	 * Hold it in SOFT_RESET and STOP state for 100us.
+	 */
+	ISP_WRITE(isp, BIU2400_CSR, BIU2400_SOFT_RESET|BIU2400_DMA_STOP|(3 << 4));
+	ISP_DELAY(100);
+	for (loops = 0; loops < 10000; loops++) {
+		ISP_DELAY(5);
+		val = ISP_READ(isp, OUTMAILBOX0);
+	}
+	for (val = loops = 0; loops < 500000; loops ++) {
+		val = ISP_READ(isp, BIU2400_CSR);
+		if ((val & BIU2400_SOFT_RESET) == 0) {
+			break;
 		}
-		/*
-		 * Hold it in SOFT_RESET and STOP state for 100us.
-		 */
-		ISP_WRITE(isp, BIU2400_CSR, BIU2400_SOFT_RESET|BIU2400_DMA_STOP|(3 << 4));
-		ISP_DELAY(100);
-		for (loops = 0; loops < 10000; loops++) {
-			ISP_DELAY(5);
-			val = ISP_READ(isp, OUTMAILBOX0);
-		}
-		for (val = loops = 0; loops < 500000; loops ++) {
-			val = ISP_READ(isp, BIU2400_CSR);
-			if ((val & BIU2400_SOFT_RESET) == 0) {
-				break;
-			}
-		}
-		if (val & BIU2400_SOFT_RESET) {
-			isp_prt(isp, ISP_LOGERR, "Failed to come out of reset");
-			return;
-		}
-	} else {
-		ISP_WRITE(isp, BIU2100_CSR, BIU2100_SOFT_RESET);
-		/*
-		 * A slight delay...
-		 */
-		ISP_DELAY(100);
-
-		/*
-		 * Clear data && control DMA engines.
-		 */
-		ISP_WRITE(isp, CDMA2100_CONTROL, DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT);
-		ISP_WRITE(isp, TDMA2100_CONTROL, DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT);
-		ISP_WRITE(isp, RDMA2100_CONTROL, DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT);
 	}
+	if (val & BIU2400_SOFT_RESET) {
+		isp_prt(isp, ISP_LOGERR, "Failed to come out of reset");
+		return;
+	}
 
 	/*
 	 * Wait for ISP to be ready to go...
 	 */
 	loops = MBOX_DELAY_COUNT;
 	for (;;) {
-		if (IS_SCSI(isp)) {
-			if (!(ISP_READ(isp, BIU_ICR) & BIU_ICR_SOFT_RESET)) {
-				break;
-			}
-		} else if (IS_24XX(isp)) {
-			if (ISP_READ(isp, OUTMAILBOX0) == 0) {
-				break;
-			}
-		} else {
-			if (!(ISP_READ(isp, BIU2100_CSR) & BIU2100_SOFT_RESET))
-				break;
-		}
+		if (ISP_READ(isp, OUTMAILBOX0) == 0)
+			break;
 		ISP_DELAY(100);
 		if (--loops < 0) {
 			ISP_DUMPREGS(isp, "chip reset timed out");
@@ -513,136 +242,47 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults)
 	}
 
 	/*
-	 * After we've fired this chip up, zero out the conf1 register
-	 * for SCSI adapters and other settings for the 2100.
-	 */
-
-	if (IS_SCSI(isp)) {
-		ISP_WRITE(isp, BIU_CONF1, 0);
-	} else if (!IS_24XX(isp)) {
-		ISP_WRITE(isp, BIU2100_CSR, 0);
-	}
-
-	/*
 	 * Reset RISC Processor
 	 */
-	if (IS_24XX(isp)) {
-		ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_RESET);
-		ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_RELEASE);
-		ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RESET);
-	} else {
-		ISP_WRITE(isp, HCCR, HCCR_CMD_RESET);
-		ISP_DELAY(100);
-		ISP_WRITE(isp, BIU_SEMA, 0);
-	}
+	ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_RESET);
+	ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_RELEASE);
+	ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RESET);
 
 	/*
 	 * Post-RISC Reset stuff.
 	 */
-	if (IS_24XX(isp)) {
-		for (val = loops = 0; loops < 5000000; loops++) {
-			ISP_DELAY(5);
-			val = ISP_READ(isp, OUTMAILBOX0);
-			if (val == 0) {
-				break;
-			}
+	for (val = loops = 0; loops < 5000000; loops++) {
+		ISP_DELAY(5);
+		val = ISP_READ(isp, OUTMAILBOX0);
+		if (val == 0) {
+			break;
 		}
-		if (val != 0) {
-			isp_prt(isp, ISP_LOGERR, "reset didn't clear");
-			return;
-		}
-	} else if (IS_SCSI(isp)) {
-		uint16_t tmp = isp->isp_mdvec->dv_conf1;
-		/*
-		 * Busted FIFO. Turn off all but burst enables.
-		 */
-		if (isp->isp_type == ISP_HA_SCSI_1040A) {
-			tmp &= BIU_BURST_ENABLE;
-		}
-		ISP_SETBITS(isp, BIU_CONF1, tmp);
-		if (tmp & BIU_BURST_ENABLE) {
-			ISP_SETBITS(isp, CDMA_CONF, DMA_ENABLE_BURST);
-			ISP_SETBITS(isp, DDMA_CONF, DMA_ENABLE_BURST);
-		}
-		if (SDPARAM(isp, 0)->isp_ptisp) {
-			if (SDPARAM(isp, 0)->isp_ultramode) {
-				while (ISP_READ(isp, RISC_MTR) != 0x1313) {
-					ISP_WRITE(isp, RISC_MTR, 0x1313);
-					ISP_WRITE(isp, HCCR, HCCR_CMD_STEP);
-				}
-			} else {
-				ISP_WRITE(isp, RISC_MTR, 0x1212);
-			}
-			/*
-			 * PTI specific register
-			 */
-			ISP_WRITE(isp, RISC_EMB, DUAL_BANK);
-		} else {
-			ISP_WRITE(isp, RISC_MTR, 0x1212);
-		}
-		ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE);
-	} else {
-		ISP_WRITE(isp, RISC_MTR2100, 0x1212);
-		if (IS_2200(isp) || IS_23XX(isp)) {
-			ISP_WRITE(isp, HCCR, HCCR_2X00_DISABLE_PARITY_PAUSE);
-		}
-		ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE);
 	}
-
-	/*
-	 * Set up default request/response queue in-pointer/out-pointer
-	 * register indices.
-	 */
-	if (IS_24XX(isp)) {
-		isp->isp_rqstinrp = BIU2400_REQINP;
-		isp->isp_rqstoutrp = BIU2400_REQOUTP;
-		isp->isp_respinrp = BIU2400_RSPINP;
-		isp->isp_respoutrp = BIU2400_RSPOUTP;
-	} else if (IS_23XX(isp)) {
-		isp->isp_rqstinrp = BIU_REQINP;
-		isp->isp_rqstoutrp = BIU_REQOUTP;
-		isp->isp_respinrp = BIU_RSPINP;
-		isp->isp_respoutrp = BIU_RSPOUTP;
-	} else {
-		isp->isp_rqstinrp = INMAILBOX4;
-		isp->isp_rqstoutrp = OUTMAILBOX4;
-		isp->isp_respinrp = OUTMAILBOX5;
-		isp->isp_respoutrp = INMAILBOX5;
+	if (val != 0) {
+		isp_prt(isp, ISP_LOGERR, "reset didn't clear");
+		return;
 	}
-	ISP_WRITE(isp, isp->isp_rqstinrp, 0);
-	ISP_WRITE(isp, isp->isp_rqstoutrp, 0);
-	ISP_WRITE(isp, isp->isp_respinrp, 0);
-	ISP_WRITE(isp, isp->isp_respoutrp, 0);
-	if (IS_24XX(isp)) {
-		if (!IS_26XX(isp)) {
-			ISP_WRITE(isp, BIU2400_PRI_REQINP, 0);
-			ISP_WRITE(isp, BIU2400_PRI_REQOUTP, 0);
-		}
-		ISP_WRITE(isp, BIU2400_ATIO_RSPINP, 0);
-		ISP_WRITE(isp, BIU2400_ATIO_RSPOUTP, 0);
-	}
 
-	if (!IS_24XX(isp) && isp->isp_bustype == ISP_BT_PCI) {
-		/* Make sure the BIOS is disabled */
-		ISP_WRITE(isp, HCCR, PCI_HCCR_CMD_BIOS);
+	ISP_WRITE(isp, BIU2400_REQINP, 0);
+	ISP_WRITE(isp, BIU2400_REQOUTP, 0);
+	ISP_WRITE(isp, BIU2400_RSPINP, 0);
+	ISP_WRITE(isp, BIU2400_RSPOUTP, 0);
+	if (!IS_26XX(isp)) {
+		ISP_WRITE(isp, BIU2400_PRI_REQINP, 0);
+		ISP_WRITE(isp, BIU2400_PRI_REQOUTP, 0);
 	}
+	ISP_WRITE(isp, BIU2400_ATIO_RSPINP, 0);
+	ISP_WRITE(isp, BIU2400_ATIO_RSPOUTP, 0);
 
 	/*
 	 * Wait for everything to finish firing up.
-	 *
-	 * Avoid doing this on early 2312s because you can generate a PCI
-	 * parity error (chip breakage).
 	 */
-	if (IS_2312(isp) && isp->isp_revision < 2) {
+	loops = MBOX_DELAY_COUNT;
+	while (ISP_READ(isp, OUTMAILBOX0) == MBOX_BUSY) {
 		ISP_DELAY(100);
-	} else {
-		loops = MBOX_DELAY_COUNT;
-		while (ISP_READ(isp, OUTMAILBOX0) == MBOX_BUSY) {
-			ISP_DELAY(100);
-			if (--loops < 0) {
-				isp_prt(isp, ISP_LOGERR, "MBOX_BUSY never cleared on reset");
-				return;
-			}
+		if (--loops < 0) {
+			isp_prt(isp, ISP_LOGERR, "MBOX_BUSY never cleared on reset");
+			return;
 		}
 	}
 
@@ -666,7 +306,7 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults)
 	/*
 	 * Do some operational tests
 	 */
-	if (IS_SCSI(isp) || IS_24XX(isp)) {
+	{
 		static const uint16_t patterns[MAX_MAILBOX] = {
 			0x0000, 0xdead, 0xbeef, 0xffff,
 			0xa5a5, 0x5a5a, 0x7f7f, 0x7ff7,
@@ -678,8 +318,6 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults)
 			0x0000, 0x0001, 0x1000, 0x1010,
 		};
 		int nmbox = ISP_NMBOX(isp);
-		if (IS_SCSI(isp))
-			nmbox = 6;
 		MBSINIT(&mbs, MBOX_MAILBOX_REG_TEST, MBLOGALL, 0);
 		for (i = 1; i < nmbox; i++) {
 			mbs.param[i] = patterns[i];
@@ -720,16 +358,9 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults)
 		}
 	}
 
-	if (IS_24XX(isp)) {
-		code_org = ISP_CODE_ORG_2400;
-	} else if (IS_23XX(isp)) {
-		code_org = ISP_CODE_ORG_2300;
-	} else {
-		code_org = ISP_CODE_ORG;
-	}
-
+	code_org = ISP_CODE_ORG_2400;
 	isp->isp_loaded_fw = 0;
-	if (dodnld && IS_24XX(isp)) {
+	if (dodnld) {
 		const uint32_t *ptr = isp->isp_mdvec->dv_ispfw;
 		uint32_t la, wi, wl;
 
@@ -737,9 +368,7 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults)
 		 * Keep loading until we run out of f/w.
 		 */
 		code_org = ptr[2];	/* 1st load address is our start addr */
-
 		for (;;) {
-
 			isp_prt(isp, ISP_LOGDEBUG0, "load 0x%x words of code at load address 0x%x", ptr[3], ptr[2]);
 
 			wi = 0;
@@ -780,101 +409,6 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults)
 			ptr += ptr[3];
 		}
 		isp->isp_loaded_fw = 1;
-	} else if (dodnld && IS_23XX(isp)) {
-		const uint16_t *ptr = isp->isp_mdvec->dv_ispfw;
-		uint16_t wi, wl, segno;
-		uint32_t la;
-
-		la = code_org;
-		segno = 0;
-
-		for (;;) {
-			uint32_t nxtaddr;
-
-			isp_prt(isp, ISP_LOGDEBUG0, "load 0x%x words of code at load address 0x%x", ptr[3], la);
-
-			wi = 0;
-			wl = ptr[3];
-
-			while (wi < ptr[3]) {
-				uint16_t *cp;
-				uint16_t nw;
-
-				nw = min(wl, min((1 << 15), ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)) / 2));
-				cp = isp->isp_rquest;
-				for (i = 0; i < nw; i++)
-					ISP_IOXPUT_16(isp, ptr[wi + i], &cp[i]);
-				MEMORYBARRIER(isp, SYNC_REQUEST, 0, ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)), -1);
-				MBSINIT(&mbs, 0, MBLOGALL, 0);
-				if (la < 0x10000) {
-					mbs.param[0] = MBOX_LOAD_RISC_RAM_2100;
-					mbs.param[1] = la;
-					mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
-					mbs.param[3] = DMA_WD0(isp->isp_rquest_dma);
-					mbs.param[4] = nw;
-					mbs.param[6] = DMA_WD3(isp->isp_rquest_dma);
-					mbs.param[7] = DMA_WD2(isp->isp_rquest_dma);
-					isp_prt(isp, ISP_LOGDEBUG1, "LOAD RISC RAM 2100 %u words at load address 0x%x\n", nw, la);
-				} else {
-					mbs.param[0] = MBOX_LOAD_RISC_RAM;
-					mbs.param[1] = la;
-					mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
-					mbs.param[3] = DMA_WD0(isp->isp_rquest_dma);
-					mbs.param[4] = nw;
-					mbs.param[6] = DMA_WD3(isp->isp_rquest_dma);
-					mbs.param[7] = DMA_WD2(isp->isp_rquest_dma);
-					mbs.param[8] = la >> 16;
-					isp_prt(isp, ISP_LOGDEBUG1, "LOAD RISC RAM %u words at load address 0x%x\n", nw, la);
-				}
-				isp_mboxcmd(isp, &mbs);
-				if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
-					isp_prt(isp, ISP_LOGERR, "F/W download failed");
-					return;
-				}
-				la += nw;
-				wi += nw;
-				wl -= nw;
-			}
-
-			if (!IS_2322(isp)) {
-				break;
-			}
-
-			if (++segno == 3) {
-				break;
-			}
-
-			/*
-			 * If we're a 2322, the firmware actually comes in
-			 * three chunks. We loaded the first at the code_org
-			 * address. The other two chunks, which follow right
-			 * after each other in memory here, get loaded at
-			 * addresses specfied at offset 0x9..0xB.
-			 */
-
-			nxtaddr = ptr[3];
-			ptr = &ptr[nxtaddr];
-			la = ptr[5] | ((ptr[4] & 0x3f) << 16);
-		}
-		isp->isp_loaded_fw = 1;
-	} else if (dodnld) {
-		const uint16_t *ptr = isp->isp_mdvec->dv_ispfw;
-		u_int i, wl;
-
-		wl = ptr[3];
-		isp_prt(isp, ISP_LOGDEBUG1,
-		    "WRITE RAM %u words at load address 0x%x", wl, code_org);
-		for (i = 0; i < wl; i++) {
-			MBSINIT(&mbs, MBOX_WRITE_RAM_WORD, MBLOGNONE, 0);
-			mbs.param[1] = code_org + i;
-			mbs.param[2] = ptr[i];
-			isp_mboxcmd(isp, &mbs);
-			if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
-				isp_prt(isp, ISP_LOGERR,
-				    "F/W download failed at word %d", i);
-				return;
-			}
-		}
 	} else if (IS_26XX(isp)) {
 		isp_prt(isp, ISP_LOGDEBUG1, "loading firmware from flash");
 		MBSINIT(&mbs, MBOX_LOAD_FLASH_FIRMWARE, MBLOGALL, 5000000);
@@ -894,12 +428,8 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults)
 	 */
 	if (isp->isp_loaded_fw) {
 		MBSINIT(&mbs, MBOX_VERIFY_CHECKSUM, MBLOGNONE, 0);
-		if (IS_24XX(isp)) {
-			mbs.param[1] = code_org >> 16;
-			mbs.param[2] = code_org;
-		} else {
-			mbs.param[1] = code_org;
-		}
+		mbs.param[1] = code_org >> 16;
+		mbs.param[2] = code_org;
 		isp_mboxcmd(isp, &mbs);
 		if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
 			isp_prt(isp, ISP_LOGERR, dcrc);
@@ -917,43 +447,18 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults)
 	if (IS_26XX(isp)) {
 		mbs.param[1] = code_org >> 16;
 		mbs.param[2] = code_org;
-	} else if (IS_24XX(isp)) {
+	} else {
 		mbs.param[1] = code_org >> 16;
 		mbs.param[2] = code_org;
-		if (isp->isp_loaded_fw) {
+		if (isp->isp_loaded_fw)
 			mbs.param[3] = 0;
-		} else {
+		else
 			mbs.param[3] = 1;
-		}
-	} else if (IS_2322(isp)) {
-		mbs.param[1] = code_org;
-		if (isp->isp_loaded_fw) {
-			mbs.param[2] = 0;
-		} else {
-			mbs.param[2] = 1;
-		}
-	} else {
-		mbs.param[1] = code_org;
 	}
 	isp_mboxcmd(isp, &mbs);
-	if (IS_2322(isp) || IS_24XX(isp)) {
-		if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
-			return;
-		}
-	}
+	if (mbs.param[0] != MBOX_COMMAND_COMPLETE)
+		return;
 
-	if (IS_SCSI(isp)) {
-		/*
-		 * Set CLOCK RATE, but only if asked to.
-		 */
-		if (isp->isp_clock) {
-			MBSINIT(&mbs, MBOX_SET_CLOCK_RATE, MBLOGALL, 0);
-			mbs.param[1] = isp->isp_clock;
-			isp_mboxcmd(isp, &mbs);
-			/* we will try not to care if this fails */
-		}
-	}
-
 	/*
 	 * Ask the chip for the current firmware version.
 	 * This should prove that the new firmware is working.
@@ -964,211 +469,116 @@ isp_reset(ispsoftc_t *isp, int do_load_defaults)
 		return;
 	}
 
-	/*
-	 * The SBus firmware that we are using apparently does not return
-	 * major, minor, micro revisions in the mailbox registers, which
-	 * is really, really, annoying.
-	 */
-	if (ISP_SBUS_SUPPORTED && isp->isp_bustype == ISP_BT_SBUS) {
-		if (dodnld) {
-#ifdef	ISP_TARGET_MODE
-			isp->isp_fwrev[0] = 7;
-			isp->isp_fwrev[1] = 55;
-#else
-			isp->isp_fwrev[0] = 1;
-			isp->isp_fwrev[1] = 37;
-#endif
-			isp->isp_fwrev[2] = 0;
-		}
-	} else {
-		isp->isp_fwrev[0] = mbs.param[1];
-		isp->isp_fwrev[1] = mbs.param[2];
-		isp->isp_fwrev[2] = mbs.param[3];
+	isp->isp_fwrev[0] = mbs.param[1];
+	isp->isp_fwrev[1] = mbs.param[2];
+	isp->isp_fwrev[2] = mbs.param[3];
+	isp->isp_fwattr = mbs.param[6];
+	isp->isp_fwattr |= ((uint64_t) mbs.param[15]) << 16;
+	if (isp->isp_fwattr & ISP2400_FW_ATTR_EXTNDED) {
+		isp->isp_fwattr |=
+		    (((uint64_t) mbs.param[16]) << 32) |
+		    (((uint64_t) mbs.param[17]) << 48);
 	}
 
-	if (IS_FC(isp)) {
-		/*
-		 * We do not believe firmware attributes for 2100 code less
-		 * than 1.17.0, unless it's the firmware we specifically
-		 * are loading.

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


More information about the svn-src-all mailing list