git: ad5d75d88448 - stable/12 - isp(4): Allow more than 2 ports to read WWNs from NVRAM.

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Tue, 21 Dec 2021 01:10:54 UTC
The branch stable/12 has been updated by mav:

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

commit ad5d75d884484f79f77711305ea36538531ca1bc
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2021-12-14 18:20:14 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2021-12-21 01:09:36 +0000

    isp(4): Allow more than 2 ports to read WWNs from NVRAM.
    
    It appears at least on QLE2694L cards 3rd and 4th ports follow the
    same NVRAM addressing logic as the first two.  In lack of proper
    documentation this guess is as good as it can be.
    
    MFC after:      1 week
    Sponsored by:   iXsystems, Inc.
    
    (cherry picked from commit 483e464ed4325a0710485925ecfbe0e1c8d6bb02)
---
 sys/dev/isp/isp.c    | 7 +------
 sys/dev/isp/ispreg.h | 3 +--
 sys/dev/isp/ispvar.h | 4 ++--
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/sys/dev/isp/isp.c b/sys/dev/isp/isp.c
index fe50aab77d43..931886a5162e 100644
--- a/sys/dev/isp/isp.c
+++ b/sys/dev/isp/isp.c
@@ -7672,12 +7672,7 @@ isp_read_nvram_2400(ispsoftc_t *isp, uint8_t *nvram_data)
 	int retval = 0;
 	uint32_t addr, csum, lwrds, *dptr;
 
-	if (isp->isp_port) {
-		addr = ISP2400_NVRAM_PORT1_ADDR;
-	} else {
-		addr = ISP2400_NVRAM_PORT0_ADDR;
-	}
-
+	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++);
diff --git a/sys/dev/isp/ispreg.h b/sys/dev/isp/ispreg.h
index 0d72b94f207c..689768209d06 100644
--- a/sys/dev/isp/ispreg.h
+++ b/sys/dev/isp/ispreg.h
@@ -1111,8 +1111,7 @@ typedef struct {
 /*
  * Qlogic 2400 NVRAM is an array of 512 bytes with a 32 bit checksum.
  */
-#define	ISP2400_NVRAM_PORT0_ADDR	0x80
-#define	ISP2400_NVRAM_PORT1_ADDR	0x180
+#define	ISP2400_NVRAM_PORT_ADDR(c)	(0x100 * (c) + 0x80)
 #define	ISP2400_NVRAM_SIZE		512
 
 #define	ISP2400_NVRAM_VERSION(c)		((c)[4] | ((c)[5] << 8))
diff --git a/sys/dev/isp/ispvar.h b/sys/dev/isp/ispvar.h
index 5ff34e829eb3..94d628c12c02 100644
--- a/sys/dev/isp/ispvar.h
+++ b/sys/dev/isp/ispvar.h
@@ -546,8 +546,8 @@ struct ispsoftc {
 	uint32_t		isp_maxluns;	/* maximum luns supported */
 
 	uint32_t		isp_clock	: 8,	/* input clock */
-						: 5,
-				isp_port	: 1,	/* 23XX/24XX only */
+						: 4,
+				isp_port	: 2,	/* 23XX/24XX only */
 				isp_bustype	: 1,	/* SBus or PCI */
 				isp_loaded_fw	: 1,	/* loaded firmware */
 				isp_dblev	: 16;	/* debug log mask */