Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Jul 2023 21:47:58 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 707e4d1b20aa - main - isp(4): Use the FLT on all supported controllers
Message-ID:  <202307072147.367LlwJK094631@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=707e4d1b20aa3983f7cd2f444d6ce41eebc02698

commit 707e4d1b20aa3983f7cd2f444d6ce41eebc02698
Author:     Joerg Pulz <Joerg.Pulz@frm2.tum.de>
AuthorDate: 2023-07-07 21:43:34 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-07-07 21:45:30 +0000

    isp(4): Use the FLT on all supported controllers
    
    The ISP26xx based HBAs are left as is for now with static NVRAM addressing.
    Those HBAs are known as 83xx (2031 and 8031 for real) and need special handling.
    This is left for further investigation for now.
    
    Cosmetics:
      - rename functions and defines as they are no longer specific to 28xx
      - set reasonable log levels
      - sort FLT and NVRAM functions (in the order they are used)
    
    Tested and approved to work on real hardware with:
      - Qlogic ISP 2532 (QLogic QLE2562 8Gb 2Port FC Adapter)
      - Qlogic ISP 2722 (QLogic QLE2690 16Gb FC Adapter)
      - Qlogic ISP 2812 (QLogic QLE2772 32Gbit 2Port FC Adapter)
    
    PR: 271062
    Reviewed by: imp, mav
    Sponsored by: Technical University of Munich
    Pull Request: https://github.com/freebsd/freebsd-src/pull/726
---
 sys/dev/isp/isp.c    | 417 +++++++++++++++++++++++++++++----------------------
 sys/dev/isp/ispreg.h |  29 ++--
 sys/dev/isp/ispvar.h |   4 +
 3 files changed, 260 insertions(+), 190 deletions(-)

diff --git a/sys/dev/isp/isp.c b/sys/dev/isp/isp.c
index 14795198a850..87f2b04becdb 100644
--- a/sys/dev/isp/isp.c
+++ b/sys/dev/isp/isp.c
@@ -119,18 +119,16 @@ static void isp_mboxcmd(ispsoftc_t *, mbreg_t *);
 
 static void isp_setdfltfcparm(ispsoftc_t *, int);
 static int isp_read_nvram(ispsoftc_t *, int);
+static int isp_read_flthdr_2xxx(ispsoftc_t *);
+static void isp_rd_2xxx_flthdr(ispsoftc_t *, uint32_t, uint32_t *);
+static void isp_parse_flthdr_2xxx(ispsoftc_t *, uint8_t *);
+static int isp_read_flt_2xxx(ispsoftc_t *);
+static void isp_rd_2xxx_flt(ispsoftc_t *, uint32_t, uint32_t *);
+static int isp_parse_flt_2xxx(ispsoftc_t *, uint8_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_2400(ispsoftc_t *, uint8_t *);
 
-static int isp_read_flthdr_28xx(ispsoftc_t *);
-static void isp_rd_28xx_flthdr(ispsoftc_t *, uint32_t, uint32_t *);
-static void isp_parse_flthdr_28xx(ispsoftc_t *, uint8_t *);
-
-static int isp_read_flt_28xx(ispsoftc_t *);
-static void isp_rd_28xx_flt(ispsoftc_t *, uint32_t, uint32_t *);
-static int isp_parse_flt_28xx(ispsoftc_t *, uint8_t *);
-
 static void
 isp_change_fw_state(ispsoftc_t *isp, int chan, int state)
 {
@@ -4342,157 +4340,65 @@ cleanup:
 static int
 isp_read_nvram(ispsoftc_t *isp, int bus)
 {
-	if (IS_28XX(isp)) {
-		fcparam *fcp = FCPARAM(isp, 0);
-		int r = 0;
-
-		fcp->flash_data_addr = ISP28XX_BASE_ADDR;
+	fcparam *fcp = FCPARAM(isp, 0);
+	int r = 0;
+
+	if (isp->isp_type != ISP_HA_FC_2600) {
+		if (IS_28XX(isp)) {
+			fcp->flash_data_addr = ISP28XX_BASE_ADDR;
+			fcp->flt_region_flt = ISP28XX_FLT_ADDR;
+		} else if (IS_27XX(isp)) {
+			fcp->flash_data_addr = ISP27XX_BASE_ADDR;
+			fcp->flt_region_flt = ISP27XX_FLT_ADDR;
+		} else if (IS_25XX(isp)) {
+			fcp->flash_data_addr = ISP25XX_BASE_ADDR;
+			fcp->flt_region_flt = ISP25XX_FLT_ADDR;
+		} else {
+			fcp->flash_data_addr = ISP24XX_BASE_ADDR;
+			fcp->flt_region_flt = ISP24XX_FLT_ADDR;
+		}
 		fcp->flt_length = 0;
-		r = isp_read_flthdr_28xx(isp);
+		r = isp_read_flthdr_2xxx(isp);
 		if (r == 0) {
-			isp_read_flt_28xx(isp);
-		} else {
-			fcp->flt_region_nvram =
-			    (0x300000 + ISP2400_NVRAM_PORT_ADDR(isp->isp_port));
+			isp_read_flt_2xxx(isp);
+		} else { /* fallback to hardcoded NVRAM address */
+			if (IS_28XX(isp)) {
+				fcp->flt_region_nvram = 0x300000;
+			} else if (IS_27XX(isp)) {
+				fcp->flash_data_addr = 0x7fe7c000;
+				fcp->flt_region_nvram = 0;
+			} else if (IS_25XX(isp)) {
+				fcp->flt_region_nvram = 0x48000;
+			} else {
+				fcp->flash_data_addr = 0x7ffe0000;
+				fcp->flt_region_nvram = 0;
+			}
+			fcp->flt_region_nvram += ISP2400_NVRAM_PORT_ADDR(isp->isp_port);
 		}
+	} else {
+		fcp->flash_data_addr = 0x7fe7c000;
+		fcp->flt_region_nvram = 0;
+		fcp->flt_region_nvram += ISP2400_NVRAM_PORT_ADDR(isp->isp_port);
 	}
 	return (isp_read_nvram_2400(isp));
 }
 
 static int
-isp_read_nvram_2400(ispsoftc_t *isp)
-{
-	fcparam *fcp = FCPARAM(isp, 0);
-	int retval = 0;
-	uint32_t addr, csum, lwrds, *dptr;
-	uint8_t nvram_data[ISP2400_NVRAM_SIZE];
-
-	if (IS_28XX(isp)) {
-		addr = fcp->flt_region_nvram;
-	} else {
-		addr = ISP2400_NVRAM_PORT_ADDR(isp->isp_port);
-	}
-	dptr = (uint32_t *) nvram_data;
-	for (lwrds = 0; lwrds < ISP2400_NVRAM_SIZE >> 2; lwrds++) {
-		isp_rd_2400_nvram(isp, addr++, dptr++);
-	}
-	if (nvram_data[0] != 'I' || nvram_data[1] != 'S' ||
-	    nvram_data[2] != 'P') {
-		isp_prt(isp, ISP_LOGWARN, "invalid NVRAM header (%x %x %x)",
-		    nvram_data[0], nvram_data[1], nvram_data[2]);
-		retval = -1;
-		goto out;
-	}
-	dptr = (uint32_t *) nvram_data;
-	for (csum = 0, lwrds = 0; lwrds < ISP2400_NVRAM_SIZE >> 2; lwrds++) {
-		uint32_t tmp;
-		ISP_IOXGET_32(isp, &dptr[lwrds], tmp);
-		csum += tmp;
-	}
-	if (csum != 0) {
-		isp_prt(isp, ISP_LOGWARN, "invalid NVRAM checksum");
-		retval = -1;
-		goto out;
-	}
-	isp_parse_nvram_2400(isp, nvram_data);
-out:
-	return (retval);
-}
-
-static void
-isp_rd_2400_nvram(ispsoftc_t *isp, uint32_t addr, uint32_t *rp)
-{
-	int loops = 0;
-	uint32_t base = 0x7ffe0000;
-	uint32_t tmp = 0;
-
-	if (IS_28XX(isp)) {
-		fcparam *fcp = FCPARAM(isp, 0);
-		base = fcp->flash_data_addr + addr;
-		addr = 0;
-	} else if (IS_26XX(isp)) {
-		base = 0x7fe7c000;	/* XXX: Observation, may be wrong. */
-	} else if (IS_25XX(isp)) {
-		base = 0x7ff00000 | 0x48000;
-	}
-	ISP_WRITE(isp, BIU2400_FLASH_ADDR, base | addr);
-	for (loops = 0; loops < 5000; loops++) {
-		ISP_DELAY(10);
-		tmp = ISP_READ(isp, BIU2400_FLASH_ADDR);
-		if ((tmp & (1U << 31)) != 0) {
-			break;
-		}
-	}
-	if (tmp & (1U << 31)) {
-		*rp = ISP_READ(isp, BIU2400_FLASH_DATA);
-		ISP_SWIZZLE_NVRAM_LONG(isp, rp);
-	} else {
-		*rp = 0xffffffff;
-	}
-}
-
-static void
-isp_parse_nvram_2400(ispsoftc_t *isp, uint8_t *nvram_data)
+isp_read_flthdr_2xxx(ispsoftc_t *isp)
 {
 	fcparam *fcp = FCPARAM(isp, 0);
-	uint64_t wwn;
-
-	isp_prt(isp, ISP_LOGDEBUG0,
-	    "NVRAM 0x%08x%08x 0x%08x%08x maxframelen %d",
-	    (uint32_t) (ISP2400_NVRAM_NODE_NAME(nvram_data) >> 32),
-	    (uint32_t) (ISP2400_NVRAM_NODE_NAME(nvram_data)),
-	    (uint32_t) (ISP2400_NVRAM_PORT_NAME(nvram_data) >> 32),
-	    (uint32_t) (ISP2400_NVRAM_PORT_NAME(nvram_data)),
-	    ISP2400_NVRAM_MAXFRAMELENGTH(nvram_data));
-	isp_prt(isp, ISP_LOGDEBUG0,
-	    "NVRAM loopid %d fwopt1 0x%x fwopt2 0x%x fwopt3 0x%x",
-	    ISP2400_NVRAM_HARDLOOPID(nvram_data),
-	    ISP2400_NVRAM_FIRMWARE_OPTIONS1(nvram_data),
-	    ISP2400_NVRAM_FIRMWARE_OPTIONS2(nvram_data),
-	    ISP2400_NVRAM_FIRMWARE_OPTIONS3(nvram_data));
-
-	wwn = ISP2400_NVRAM_PORT_NAME(nvram_data);
-	fcp->isp_wwpn_nvram = wwn;
-
-	wwn = ISP2400_NVRAM_NODE_NAME(nvram_data);
-	if (wwn) {
-		if ((wwn >> 60) != 2 && (wwn >> 60) != 5) {
-			wwn = 0;
-		}
-	}
-	if (wwn == 0 && (fcp->isp_wwpn_nvram >> 60) == 2) {
-		wwn = fcp->isp_wwpn_nvram;
-		wwn &= ~((uint64_t) 0xfff << 48);
-	}
-	fcp->isp_wwnn_nvram = wwn;
-
-	if ((isp->isp_confopts & ISP_CFG_OWNFSZ) == 0) {
-		DEFAULT_FRAMESIZE(isp) =
-		    ISP2400_NVRAM_MAXFRAMELENGTH(nvram_data);
-	}
-	if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) {
-		fcp->isp_loopid = ISP2400_NVRAM_HARDLOOPID(nvram_data);
-	}
-	fcp->isp_fwoptions = ISP2400_NVRAM_FIRMWARE_OPTIONS1(nvram_data);
-	fcp->isp_xfwoptions = ISP2400_NVRAM_FIRMWARE_OPTIONS2(nvram_data);
-	fcp->isp_zfwoptions = ISP2400_NVRAM_FIRMWARE_OPTIONS3(nvram_data);
-}
-
-static int
-isp_read_flthdr_28xx(ispsoftc_t *isp)
-{
 	int retval = 0;
 	uint32_t addr, lwrds, *dptr;
 	uint16_t csum;
 	uint8_t flthdr_data[FLT_HEADER_SIZE];
 
-	addr = ISP28XX_FLT_ADDR;
+	addr = fcp->flt_region_flt;
 	dptr = (uint32_t *) flthdr_data;
 
 	isp_prt(isp, ISP_LOGDEBUG0,
-	    "FLTL[DEF]: 0x%x", ISP28XX_FLT_ADDR);
+	    "FLTL[DEF]: 0x%x", addr);
 	for (lwrds = 0; lwrds < FLT_HEADER_SIZE >> 2; lwrds++) {
-		isp_rd_28xx_flthdr(isp, addr++, dptr++);
+		isp_rd_2xxx_flthdr(isp, addr++, dptr++);
 	}
 	dptr = (uint32_t *) flthdr_data;
 	for (csum = 0, lwrds = 0; lwrds < FLT_HEADER_SIZE >> 4; lwrds++) {
@@ -4504,13 +4410,13 @@ isp_read_flthdr_28xx(ispsoftc_t *isp)
 		retval = -1;
 		goto out;
 	}
-	isp_parse_flthdr_28xx(isp, flthdr_data);
+	isp_parse_flthdr_2xxx(isp, flthdr_data);
 out:
 	return (retval);
 }
 
 static void
-isp_rd_28xx_flthdr(ispsoftc_t *isp, uint32_t addr, uint32_t *rp)
+isp_rd_2xxx_flthdr(ispsoftc_t *isp, uint32_t addr, uint32_t *rp)
 {
 	fcparam *fcp = FCPARAM(isp, 0);
 	int loops = 0;
@@ -4534,28 +4440,28 @@ isp_rd_28xx_flthdr(ispsoftc_t *isp, uint32_t addr, uint32_t *rp)
 }
 
 static void
-isp_parse_flthdr_28xx(ispsoftc_t *isp, uint8_t *flthdr_data)
+isp_parse_flthdr_2xxx(ispsoftc_t *isp, uint8_t *flthdr_data)
 {
 	fcparam *fcp = FCPARAM(isp, 0);
 	uint16_t ver, csum;
 
-	ver = le16toh((uint16_t) (ISP28XX_FLT_VERSION(flthdr_data)));
-	fcp->flt_length = le16toh((uint16_t) (ISP28XX_FLT_LENGTH(flthdr_data)));
-	csum = le16toh((uint16_t) (ISP28XX_FLT_CSUM(flthdr_data)));
+	ver = le16toh((uint16_t) (ISP2XXX_FLT_VERSION(flthdr_data)));
+	fcp->flt_length = le16toh((uint16_t) (ISP2XXX_FLT_LENGTH(flthdr_data)));
+	csum = le16toh((uint16_t) (ISP2XXX_FLT_CSUM(flthdr_data)));
 
 	if ((fcp->flt_length == 0 ) ||
 	    (fcp->flt_length > (FLT_HEADER_SIZE + FLT_REGIONS_SIZE))) {
-		isp_prt(isp, ISP_LOGWARN,
+		isp_prt(isp, ISP_LOGERR,
 		    "FLT[DEF]: Invalid length=0x%x(%d)",
 		    fcp->flt_length, fcp->flt_length);
 	}
-	isp_prt(isp, ISP_LOGDEBUG0,
+	isp_prt(isp, ISP_LOGCONFIG,
 	    "FLT[DEF]: version=0x%x length=0x%x(%d) checksum=0x%x",
 	    ver, fcp->flt_length, fcp->flt_length, csum);
 }
 
 static int
-isp_read_flt_28xx(ispsoftc_t *isp)
+isp_read_flt_2xxx(ispsoftc_t *isp)
 {
 	fcparam *fcp = FCPARAM(isp, 0);
 	int retval = 0;
@@ -4564,19 +4470,19 @@ isp_read_flt_28xx(ispsoftc_t *isp)
 	uint8_t flt_data[len];
 	fcp->flt_region_entries = len / FLT_REGION_SIZE;
 
-	addr = ISP28XX_FLT_ADDR + (FLT_HEADER_SIZE >> 2);
+	addr = fcp->flt_region_flt + (FLT_HEADER_SIZE >> 2);
 	dptr = (uint32_t *) flt_data;
-	isp_prt(isp, ISP_LOGDEBUG0, "FLT[DEF]: regions=%d",
+	isp_prt(isp, ISP_LOGCONFIG, "FLT[DEF]: regions=%d",
 	    fcp->flt_region_entries);
 	for (lwrds = 0; lwrds < len >> 2; lwrds++) {
-		isp_rd_28xx_flt(isp, addr++, dptr++);
+		isp_rd_2xxx_flt(isp, addr++, dptr++);
 	}
-	retval = isp_parse_flt_28xx(isp, flt_data);
+	retval = isp_parse_flt_2xxx(isp, flt_data);
 	return (retval);
 }
 
 static void
-isp_rd_28xx_flt(ispsoftc_t *isp, uint32_t addr, uint32_t *rp)
+isp_rd_2xxx_flt(ispsoftc_t *isp, uint32_t addr, uint32_t *rp)
 {
 	fcparam *fcp = FCPARAM(isp, 0);
 	int loops = 0;
@@ -4600,7 +4506,7 @@ isp_rd_28xx_flt(ispsoftc_t *isp, uint32_t addr, uint32_t *rp)
 }
 
 static int
-isp_parse_flt_28xx(ispsoftc_t *isp, uint8_t *flt_data)
+isp_parse_flt_2xxx(ispsoftc_t *isp, uint8_t *flt_data)
 {
 	fcparam *fcp = FCPARAM(isp, 0);
 	int count;
@@ -4608,17 +4514,17 @@ isp_parse_flt_28xx(ispsoftc_t *isp, uint8_t *flt_data)
 
 	for (count = 0; count < fcp->flt_region_entries; count++) {
 		region[count].code =
-		    le16toh((uint16_t) (ISP28XX_FLT_REG_CODE(flt_data, count)));
+		    le16toh((uint16_t) (ISP2XXX_FLT_REG_CODE(flt_data, count)));
 		region[count].attribute =
-		    (uint8_t) (ISP28XX_FLT_REG_ATTR(flt_data, count));
+		    (uint8_t) (ISP2XXX_FLT_REG_ATTR(flt_data, count));
 		region[count].reserved =
-		    (uint8_t) (ISP28XX_FLT_REG_RES(flt_data, count));
+		    (uint8_t) (ISP2XXX_FLT_REG_RES(flt_data, count));
 		region[count].size =
-		    le32toh((uint32_t) (ISP28XX_FLT_REG_SIZE(flt_data, count)) >> 2);
+		    le32toh((uint32_t) (ISP2XXX_FLT_REG_SIZE(flt_data, count)) >> 2);
 		region[count].start =
-		    le32toh((uint32_t) (ISP28XX_FLT_REG_START(flt_data, count)) >> 2);
+		    le32toh((uint32_t) (ISP2XXX_FLT_REG_START(flt_data, count)) >> 2);
 		region[count].end =
-		    le32toh((uint32_t) (ISP28XX_FLT_REG_END(flt_data, count)) >> 2);
+		    le32toh((uint32_t) (ISP2XXX_FLT_REG_END(flt_data, count)) >> 2);
 
 		isp_prt(isp, ISP_LOGDEBUG0,
 		    "FLT[0x%x]: start=0x%x end=0x%x size=0x%x attribute=0x%x",
@@ -4642,10 +4548,14 @@ isp_parse_flt_28xx(ispsoftc_t *isp, uint8_t *flt_data)
 				fcp->flt_region_vpd = region[count].start;
 			break;
 		case FLT_REG_VPD_2:
+			if (!IS_27XX(isp)) 
+				break;
 			if (isp->isp_port == 2)
 				fcp->flt_region_vpd = region[count].start;
 			break;
 		case FLT_REG_VPD_3:
+			if (!IS_27XX(isp)) 
+				break;
 			if (isp->isp_port == 3)
 				fcp->flt_region_vpd = region[count].start;
 			break;
@@ -4658,10 +4568,14 @@ isp_parse_flt_28xx(ispsoftc_t *isp, uint8_t *flt_data)
 				fcp->flt_region_nvram = region[count].start;
 			break;
 		case FLT_REG_NVRAM_2:
+			if (!IS_27XX(isp)) 
+				break;
 			if (isp->isp_port == 2)
 				fcp->flt_region_nvram = region[count].start;
 			break;
 		case FLT_REG_NVRAM_3:
+			if (!IS_27XX(isp)) 
+				break;
 			if (isp->isp_port == 3)
 				fcp->flt_region_nvram = region[count].start;
 			break;
@@ -4690,48 +4604,79 @@ isp_parse_flt_28xx(ispsoftc_t *isp, uint8_t *flt_data)
 			if (isp->isp_port == 1)
 				fcp->flt_region_fcp_prio = region[count].start;
 			break;
+		case FLT_REG_IMG_PRI_27XX:
+			if (IS_27XX(isp)) 
+				fcp->flt_region_img_status_pri = region[count].start;
+			break;
+		case FLT_REG_IMG_SEC_27XX:
+			if (IS_27XX(isp)) 
+				fcp->flt_region_img_status_sec = region[count].start;
+			break;
+		case FLT_REG_FW_SEC_27XX:
+			if (IS_27XX(isp)) 
+				fcp->flt_region_fw_sec = region[count].start;
+			break;
+		case FLT_REG_BOOTLOAD_SEC_27XX:
+			if (IS_27XX(isp)) 
+				fcp->flt_region_boot_sec = region[count].start;
+			break;
 		case FLT_REG_AUX_IMG_PRI_28XX:
-			fcp->flt_region_aux_img_status_pri = region[count].start;
+			if (IS_27XX(isp)) 
+				fcp->flt_region_aux_img_status_pri = region[count].start;
 			break;
 		case FLT_REG_AUX_IMG_SEC_28XX:
-			fcp->flt_region_aux_img_status_sec = region[count].start;
+			if (IS_27XX(isp)) 
+				fcp->flt_region_aux_img_status_sec = region[count].start;
 			break;
 		case FLT_REG_NVRAM_SEC_28XX_0:
-			if (isp->isp_port == 0)
-				fcp->flt_region_nvram_sec = region[count].start;
+			if (IS_27XX(isp)) 
+				if (isp->isp_port == 0)
+					fcp->flt_region_nvram_sec = region[count].start;
 			break;
 		case FLT_REG_NVRAM_SEC_28XX_1:
-			if (isp->isp_port == 1)
-				fcp->flt_region_nvram_sec = region[count].start;
+			if (IS_27XX(isp)) 
+				if (isp->isp_port == 1)
+					fcp->flt_region_nvram_sec = region[count].start;
 			break;
 		case FLT_REG_NVRAM_SEC_28XX_2:
-			if (isp->isp_port == 2)
-				fcp->flt_region_nvram_sec = region[count].start;
+			if (IS_27XX(isp)) 
+				if (isp->isp_port == 2)
+					fcp->flt_region_nvram_sec = region[count].start;
 			break;
 		case FLT_REG_NVRAM_SEC_28XX_3:
-			if (isp->isp_port == 3)
-				fcp->flt_region_nvram_sec = region[count].start;
+			if (IS_27XX(isp)) 
+				if (isp->isp_port == 3)
+					fcp->flt_region_nvram_sec = region[count].start;
 			break;
+		case FLT_REG_VPD_SEC_27XX_0:
 		case FLT_REG_VPD_SEC_28XX_0:
-			fcp->flt_region_vpd_nvram_sec = region[count].start;
-			if (isp->isp_port == 0)
-				fcp->flt_region_vpd_sec = region[count].start;
+			if (IS_27XX(isp)) {
+				fcp->flt_region_vpd_nvram_sec = region[count].start;
+				if (isp->isp_port == 0)
+					fcp->flt_region_vpd_sec = region[count].start;
+			}
 			break;
+		case FLT_REG_VPD_SEC_27XX_1:
 		case FLT_REG_VPD_SEC_28XX_1:
-			if (isp->isp_port == 1)
-				fcp->flt_region_vpd_sec = region[count].start;
+			if (IS_27XX(isp)) 
+				if (isp->isp_port == 1)
+					fcp->flt_region_vpd_sec = region[count].start;
 			break;
+		case FLT_REG_VPD_SEC_27XX_2:
 		case FLT_REG_VPD_SEC_28XX_2:
-			if (isp->isp_port == 2)
-				fcp->flt_region_vpd_sec = region[count].start;
+			if (IS_27XX(isp)) 
+				if (isp->isp_port == 2)
+					fcp->flt_region_vpd_sec = region[count].start;
 			break;
+		case FLT_REG_VPD_SEC_27XX_3:
 		case FLT_REG_VPD_SEC_28XX_3:
-			if (isp->isp_port == 3)
-				fcp->flt_region_vpd_sec = region[count].start;
+			if (IS_27XX(isp)) 
+				if (isp->isp_port == 3)
+					fcp->flt_region_vpd_sec = region[count].start;
 			break;
 		}
 	}
-	isp_prt(isp, ISP_LOGDEBUG0,
+	isp_prt(isp, ISP_LOGCONFIG,
 	    "FLT[FLT]: boot=0x%x fw=0x%x vpd_nvram=0x%x vpd=0x%x nvram 0x%x "
 	    "fdt=0x%x flt=0x%x npiv=0x%x fcp_prif_cfg=0x%x",
 	    fcp->flt_region_boot, fcp->flt_region_fw, fcp->flt_region_vpd_nvram,
@@ -4741,3 +4686,113 @@ isp_parse_flt_28xx(ispsoftc_t *isp, uint8_t *flt_data)
 
 	return (0);
 }
+
+static int
+isp_read_nvram_2400(ispsoftc_t *isp)
+{
+	fcparam *fcp = FCPARAM(isp, 0);
+	int retval = 0;
+	uint32_t addr, csum, lwrds, *dptr;
+	uint8_t nvram_data[ISP2400_NVRAM_SIZE];
+
+	addr = fcp->flt_region_nvram;
+	dptr = (uint32_t *) nvram_data;
+	for (lwrds = 0; lwrds < ISP2400_NVRAM_SIZE >> 2; lwrds++) {
+		isp_rd_2400_nvram(isp, addr++, dptr++);
+	}
+	if (nvram_data[0] != 'I' || nvram_data[1] != 'S' ||
+	    nvram_data[2] != 'P') {
+		isp_prt(isp, ISP_LOGWARN, "invalid NVRAM header (%x %x %x)",
+		    nvram_data[0], nvram_data[1], nvram_data[2]);
+		retval = -1;
+		goto out;
+	}
+	dptr = (uint32_t *) nvram_data;
+	for (csum = 0, lwrds = 0; lwrds < ISP2400_NVRAM_SIZE >> 2; lwrds++) {
+		uint32_t tmp;
+		ISP_IOXGET_32(isp, &dptr[lwrds], tmp);
+		csum += tmp;
+	}
+	if (csum != 0) {
+		isp_prt(isp, ISP_LOGWARN, "invalid NVRAM checksum");
+		retval = -1;
+		goto out;
+	}
+	isp_parse_nvram_2400(isp, nvram_data);
+out:
+	return (retval);
+}
+
+static void
+isp_rd_2400_nvram(ispsoftc_t *isp, uint32_t addr, uint32_t *rp)
+{
+	fcparam *fcp = FCPARAM(isp, 0);
+	int loops = 0;
+	uint32_t base; // = 0x7ffe0000;
+	uint32_t tmp = 0;
+
+	base = fcp->flash_data_addr + addr;
+	addr = 0;
+
+	ISP_WRITE(isp, BIU2400_FLASH_ADDR, base | addr);
+	for (loops = 0; loops < 5000; loops++) {
+		ISP_DELAY(10);
+		tmp = ISP_READ(isp, BIU2400_FLASH_ADDR);
+		if ((tmp & (1U << 31)) != 0) {
+			break;
+		}
+	}
+	if (tmp & (1U << 31)) {
+		*rp = ISP_READ(isp, BIU2400_FLASH_DATA);
+		ISP_SWIZZLE_NVRAM_LONG(isp, rp);
+	} else {
+		*rp = 0xffffffff;
+	}
+}
+
+static void
+isp_parse_nvram_2400(ispsoftc_t *isp, uint8_t *nvram_data)
+{
+	fcparam *fcp = FCPARAM(isp, 0);
+	uint64_t wwn;
+
+	isp_prt(isp, ISP_LOGDEBUG0,
+	    "NVRAM 0x%08x%08x 0x%08x%08x maxframelen %d",
+	    (uint32_t) (ISP2400_NVRAM_NODE_NAME(nvram_data) >> 32),
+	    (uint32_t) (ISP2400_NVRAM_NODE_NAME(nvram_data)),
+	    (uint32_t) (ISP2400_NVRAM_PORT_NAME(nvram_data) >> 32),
+	    (uint32_t) (ISP2400_NVRAM_PORT_NAME(nvram_data)),
+	    ISP2400_NVRAM_MAXFRAMELENGTH(nvram_data));
+	isp_prt(isp, ISP_LOGDEBUG0,
+	    "NVRAM loopid %d fwopt1 0x%x fwopt2 0x%x fwopt3 0x%x",
+	    ISP2400_NVRAM_HARDLOOPID(nvram_data),
+	    ISP2400_NVRAM_FIRMWARE_OPTIONS1(nvram_data),
+	    ISP2400_NVRAM_FIRMWARE_OPTIONS2(nvram_data),
+	    ISP2400_NVRAM_FIRMWARE_OPTIONS3(nvram_data));
+
+	wwn = ISP2400_NVRAM_PORT_NAME(nvram_data);
+	fcp->isp_wwpn_nvram = wwn;
+
+	wwn = ISP2400_NVRAM_NODE_NAME(nvram_data);
+	if (wwn) {
+		if ((wwn >> 60) != 2 && (wwn >> 60) != 5) {
+			wwn = 0;
+		}
+	}
+	if (wwn == 0 && (fcp->isp_wwpn_nvram >> 60) == 2) {
+		wwn = fcp->isp_wwpn_nvram;
+		wwn &= ~((uint64_t) 0xfff << 48);
+	}
+	fcp->isp_wwnn_nvram = wwn;
+
+	if ((isp->isp_confopts & ISP_CFG_OWNFSZ) == 0) {
+		DEFAULT_FRAMESIZE(isp) =
+		    ISP2400_NVRAM_MAXFRAMELENGTH(nvram_data);
+	}
+	if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) {
+		fcp->isp_loopid = ISP2400_NVRAM_HARDLOOPID(nvram_data);
+	}
+	fcp->isp_fwoptions = ISP2400_NVRAM_FIRMWARE_OPTIONS1(nvram_data);
+	fcp->isp_xfwoptions = ISP2400_NVRAM_FIRMWARE_OPTIONS2(nvram_data);
+	fcp->isp_zfwoptions = ISP2400_NVRAM_FIRMWARE_OPTIONS3(nvram_data);
+}
diff --git a/sys/dev/isp/ispreg.h b/sys/dev/isp/ispreg.h
index 9d2594a97a99..eae841ce2b35 100644
--- a/sys/dev/isp/ispreg.h
+++ b/sys/dev/isp/ispreg.h
@@ -272,24 +272,24 @@ typedef struct {
 #define FLT_MAX_REGIONS		0xFF
 #define FLT_REGIONS_SIZE	(FLT_REGION_SIZE * FLT_MAX_REGIONS)
 
-#define ISP28XX_FLT_VERSION(c)		((c)[0] | ((c)[1] << 8))
-#define ISP28XX_FLT_LENGTH(c)		((c)[2] | ((c)[3] << 8))
-#define ISP28XX_FLT_CSUM(c)		((c)[4] | ((c)[5] << 8))
-#define ISP28XX_FLT_REG_CODE(c, o)	\
+#define ISP2XXX_FLT_VERSION(c)		((c)[0] | ((c)[1] << 8))
+#define ISP2XXX_FLT_LENGTH(c)		((c)[2] | ((c)[3] << 8))
+#define ISP2XXX_FLT_CSUM(c)		((c)[4] | ((c)[5] << 8))
+#define ISP2XXX_FLT_REG_CODE(c, o)	\
 	((c)[0 + FLT_REGION_SIZE * o] | ((c)[1 + FLT_REGION_SIZE * o] << 8))
-#define ISP28XX_FLT_REG_ATTR(c, o)	((c)[2 + FLT_REGION_SIZE * o])
-#define ISP28XX_FLT_REG_RES(c, o)	((c)[3 + FLT_REGION_SIZE * o])
-#define ISP28XX_FLT_REG_SIZE(c, o)	(\
+#define ISP2XXX_FLT_REG_ATTR(c, o)	((c)[2 + FLT_REGION_SIZE * o])
+#define ISP2XXX_FLT_REG_RES(c, o)	((c)[3 + FLT_REGION_SIZE * o])
+#define ISP2XXX_FLT_REG_SIZE(c, o)	(\
 		((uint32_t)(c)[4 + FLT_REGION_SIZE * o] << 0) | \
 		((uint32_t)(c)[5 + FLT_REGION_SIZE * o] << 8) | \
 		((uint32_t)(c)[6 + FLT_REGION_SIZE * o] << 16) | \
 		((uint32_t)(c)[7 + FLT_REGION_SIZE * o] << 24))
-#define ISP28XX_FLT_REG_START(c, o)	(\
+#define ISP2XXX_FLT_REG_START(c, o)	(\
 		((uint32_t)(c)[8 + FLT_REGION_SIZE * o] << 0) | \
 		((uint32_t)(c)[9 + FLT_REGION_SIZE * o] << 8) | \
 		((uint32_t)(c)[10 + FLT_REGION_SIZE * o] << 16) | \
 		((uint32_t)(c)[11 + FLT_REGION_SIZE * o] << 24))
-#define ISP28XX_FLT_REG_END(c, o)	(\
+#define ISP2XXX_FLT_REG_END(c, o)	(\
 		((uint32_t)(c)[12 + FLT_REGION_SIZE * o] << 0) | \
 		((uint32_t)(c)[13 + FLT_REGION_SIZE * o] << 8) | \
 		((uint32_t)(c)[14 + FLT_REGION_SIZE * o] << 16) | \
@@ -322,6 +322,17 @@ struct flt_region {
 #define FLT_REG_FCP_PRIO_0	0x87
 #define FLT_REG_FCP_PRIO_1	0x88
 
+/* 27xx */
+#define FLT_REG_IMG_PRI_27XX	0x95
+#define FLT_REG_IMG_SEC_27XX	0x96
+#define FLT_REG_FW_SEC_27XX	0x02
+#define FLT_REG_BOOTLOAD_SEC_27XX	0x9
+#define FLT_REG_VPD_SEC_27XX_0	0x50
+#define FLT_REG_VPD_SEC_27XX_1	0x52
+#define FLT_REG_VPD_SEC_27XX_2	0xd8
+#define FLT_REG_VPD_SEC_27XX_3	0xda
+
+/* 28xx */
 #define FLT_REG_AUX_IMG_PRI_28XX	0x125
 #define FLT_REG_AUX_IMG_SEC_28XX	0x126
 #define FLT_REG_NVRAM_SEC_28XX_0	0x10d
diff --git a/sys/dev/isp/ispvar.h b/sys/dev/isp/ispvar.h
index ae693c5c15e8..d1aba2ffa915 100644
--- a/sys/dev/isp/ispvar.h
+++ b/sys/dev/isp/ispvar.h
@@ -383,6 +383,10 @@ typedef struct {
 	uint32_t		flt_region_flt;
 	uint32_t		flt_region_fw;
 	uint32_t		flt_region_gold_fw;
+	uint32_t		flt_region_img_status_pri;
+	uint32_t		flt_region_img_status_sec;
+	uint32_t		flt_region_fw_sec;
+	uint32_t		flt_region_boot_sec;
 	uint32_t		flt_region_npiv_conf;
 	uint32_t		flt_region_nvram;
 	uint32_t		flt_region_nvram_sec;



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