isp(4): Rework firmware handling/loading

Correctly identify the active firmware in flash on adapters with
primary and secondary firmware region in flash.
Correctly identify the active NVRAM on adapters with primary
and secondary NVRAM region in flash.

Loading ispfw(4) moved from isp_pci_attach() to isp_reset().
Drop the reference to ispfw(4) after using it so one can kldunload(8) it.
New isp_load_ram() function to load either ispfw(4) or flash firmware
into RISC's RAM.
New functions to read data from flash. The old ones will be removed later.
A bunch of new helper functions to identify and validate active flash
regions for firmware, auxiliary and NVRAM.
Overhaul ISP_FW_* macros and make use of it when comparing firmware
versions. We can handle firmware versions up to 255.255.255.

Firmware load priority slightly changed:
For 27xx and newer adapters:
- load ispfw(4) firmware
- request (active) flash firmware information
- compare version numbers of ispfw(4) and flash firmware
- load firmware with highest version into RISC's RAM
- if loading ispfw(4) is disabled or failed - load firmware from flash
- if everything else fails use MBOX_LOAD_FLASH_FIRMWARE as fallback

For 26xx and older adapters nothing changed:
- load ispfw(4) firmware and load it into RISC's RAM
- if loading ispfw(4) is disabled or failed use MBOX_EXEC_FIRMWARE
- for 26xx a preceding MBOX_LOAD_FLASH_FIRMWARE is used

New read only sysctl(8)'s:
 dev.isp.N.fw_version_run: the firmware version actually running
 dev.isp.N.fw_version_ispfw: the firmware version provided by ispfw(4)
 dev.isp.N.fw_version_flash: the (active) firmware version in flash

While here:
  - firmware attribute handling/parsing reworked
    + renamed defines from ISP2400_FW_ATTR_* to ISP_FW_ATTR_*
    + changed values to match new handling/parsing
    + added some more attributes
  - enable FLT support on 26xx based adapters
  - log level adjustments
  - new function return status codes (some for now, some for later use)
  - some minor style changes

Tested and approved to work on real hardware with:
  - Qlogic ISP 2532 (QLogic QLE2560 8Gb FC Adapter)
  - Qlogic ISP 2031 (QLogic QLE2662 16Gbit 2Port FC Adapter)
  - Qlogic ISP 2722 (QLogic QLE2690 16Gb FC Adapter)
  - Qlogic ISP 2812 (QLogic QLE2772 32Gbit 2Port FC Adapter)

PR:		273263
Reviewed by:	mav
Pull Request:	https://github.com/freebsd/freebsd-src/pull/877
MFC after:	1 month
Sponsored by:	Technical University of Munich
This commit is contained in:
Joerg Pulz 2023-10-27 17:27:37 +02:00 committed by Mark Johnston
parent b0c6b06836
commit 10ed63fc06
8 changed files with 1005 additions and 261 deletions

View file

@ -24,7 +24,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd April 25, 2023
.Dd October 27, 2023
.Dt ISP 4
.Os
.Sh NAME
@ -80,12 +80,15 @@ FC-Tape is automatically enabled when connecting controller that supports
it to a target that supports it.
It may be disabled using configuration and hint options described below.
.Sh FIRMWARE
Firmware loading is supported if the
Firmware loading is supported and handled by
.Xr firmware 9 .
The correct firmware is either loaded automatically, if available for this
type of adapter, or by manually loading the
.Xr ispfw 4
module is loaded.
module.
It is strongly recommended that you use the firmware available from
.Xr ispfw 4
as it is the most likely to have been tested with this driver.
as it is the one that most likely has been tested with this driver.
.Sh HARDWARE
Cards supported by the
.Nm
@ -136,7 +139,7 @@ Limit on number of Message Signaled Interrupts (MSI) to be used.
.It Va hint.isp. Ns Ar N Ns Va .msix
Limit on number of Extended Message Signaled Interrupts (MSI-X) to be used.
.It Va hint.isp. Ns Ar N Ns Va .fwload_disable
A hint value to disable loading of firmware
A hint value to disable loading of firmware provided by
.Xr ispfw 4 .
.It Va hint.isp. Ns Ar N Ns Va .ignore_nvram
A hint value to ignore board NVRAM settings for.
@ -210,6 +213,14 @@ The default is 1 (enabled).
This is the readonly World Wide Node Name value for this port.
.It Va dev.isp. Ns Ar N Ns Va .wwpn
This is the readonly World Wide Port Name value for this port.
.It Va dev.isp. Ns Ar N Ns Va .fw_version_flash
The readonly flash firmware version value in the active region of the
controller.
.It Va dev.isp. Ns Ar N Ns Va .fw_version_ispfw
The readonly firmware version value provided by
.Xr ispfw 4 .
.It Va dev.isp. Ns Ar N Ns Va .fw_version_run
The readonly firmware version value currently executed on the controller.
.El
.Sh SEE ALSO
.Xr da 4 ,

File diff suppressed because it is too large Load diff

View file

@ -212,6 +212,15 @@ isp_attach_chan(ispsoftc_t *isp, struct cam_devq *devq, int chan)
SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
"use_gff_id", CTLFLAG_RWTUN, &fcp->isp_use_gff_id, 0,
"Use GFF_ID during fabric scan");
SYSCTL_ADD_STRING(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
"fw_version_flash", CTLFLAG_RD, fcp->fw_version_flash, 0,
"Firmware version in (active) flash region");
SYSCTL_ADD_STRING(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
"fw_version_ispfw", CTLFLAG_RD, fcp->fw_version_ispfw, 0,
"Firmware version loaded from ispfw(4)");
SYSCTL_ADD_STRING(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
"fw_version_run", CTLFLAG_RD, fcp->fw_version_run, 0,
"Firmware version currently running");
return (0);
}
@ -1500,7 +1509,7 @@ isp_handle_srr_start(ispsoftc_t *isp, atio_private_data_t *atp)
*/
isp_prt(isp, ISP_LOGWARN, "Got an FCP DATA IN SRR- dropping");
goto fail;
default:
isp_prt(isp, ISP_LOGWARN, "Got an unknown information (%x) SRR- dropping", inot->in_srr_iu);
goto fail;
@ -2847,9 +2856,9 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
lipp = ISP_READ(isp, OUTMAILBOX1);
fcp = FCPARAM(isp, bus);
isp_prt(isp, ISP_LOGINFO, "Chan %d LOOP Reset, LIP primitive %x", bus, lipp);
/*
/*
* Per FCP-4, a Reset LIP should result in a CRN reset. Other
* LIPs and loop up/down events should never reset the CRN. For
* an as of yet unknown reason, 24xx series cards (and
@ -2910,7 +2919,7 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
}
break;
case ISPASYNC_DEV_CHANGED:
case ISPASYNC_DEV_STAYED:
case ISPASYNC_DEV_STAYED:
{
int crn_reset_done;
@ -2925,7 +2934,7 @@ isp_async(ispsoftc_t *isp, ispasync_t cmd, ...)
if (cmd == ISPASYNC_DEV_CHANGED)
isp_prt(isp, ISP_LOGCONFIG, prom, bus, tgt, lp->port_wwn, lp->new_portid, lp->handle, buf, "changed");
else
isp_prt(isp, ISP_LOGCONFIG, prom, bus, tgt, lp->port_wwn, lp->portid, lp->handle, buf, "stayed");
isp_prt(isp, ISP_LOGCONFIG, prom, bus, tgt, lp->port_wwn, lp->portid, lp->handle, buf, "stayed");
if (lp->is_target !=
((FCPARAM(isp, bus)->role & ISP_ROLE_INITIATOR) &&
@ -3221,7 +3230,7 @@ isp_prt(ispsoftc_t *isp, int level, const char *fmt, ...)
snprintf(lbuf, sizeof (lbuf), "%s: ", device_get_nameunit(isp->isp_dev));
loc = strlen(lbuf);
va_start(ap, fmt);
vsnprintf(&lbuf[loc], sizeof (lbuf) - loc - 1, fmt, ap);
vsnprintf(&lbuf[loc], sizeof (lbuf) - loc - 1, fmt, ap);
va_end(ap);
printf("%s\n", lbuf);
}

View file

@ -244,7 +244,7 @@ struct isposinfo {
/*
* Firmware pointer
*/
const struct firmware * fw;
const struct firmware * ispfw;
/*
* DMA related stuff

View file

@ -36,7 +36,6 @@
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/linker.h>
#include <sys/firmware.h>
#include <sys/bus.h>
#include <sys/stdint.h>
#include <dev/pci/pcireg.h>
@ -463,9 +462,8 @@ isp_pci_attach(device_t dev)
struct isp_pcisoftc *pcs = device_get_softc(dev);
ispsoftc_t *isp = &pcs->pci_isp;
int i;
uint32_t data, cmd, linesz, did;
uint32_t data, cmd, linesz;
size_t psize, xsize;
char fwname[32];
isp->isp_dev = dev;
isp->isp_nchan = 1;
@ -485,23 +483,23 @@ isp_pci_attach(device_t dev)
switch (pci_get_devid(dev)) {
case PCI_QLOGIC_ISP2422:
case PCI_QLOGIC_ISP2432:
did = 0x2400;
isp->isp_did = 0x2400;
isp->isp_mdvec = &mdvec_2400;
isp->isp_type = ISP_HA_FC_2400;
break;
case PCI_QLOGIC_ISP2532:
did = 0x2500;
isp->isp_did = 0x2500;
isp->isp_mdvec = &mdvec_2500;
isp->isp_type = ISP_HA_FC_2500;
break;
case PCI_QLOGIC_ISP5432:
did = 0x2500;
isp->isp_did = 0x2500;
isp->isp_mdvec = &mdvec_2500;
isp->isp_type = ISP_HA_FC_2500;
break;
case PCI_QLOGIC_ISP2031:
case PCI_QLOGIC_ISP8031:
did = 0x2600;
isp->isp_did = 0x2600;
isp->isp_mdvec = &mdvec_2600;
isp->isp_type = ISP_HA_FC_2600;
break;
@ -509,13 +507,13 @@ isp_pci_attach(device_t dev)
case PCI_QLOGIC_ISP2692:
case PCI_QLOGIC_ISP2714:
case PCI_QLOGIC_ISP2722:
did = 0x2700;
isp->isp_did = 0x2700;
isp->isp_mdvec = &mdvec_2700;
isp->isp_type = ISP_HA_FC_2700;
break;
case PCI_QLOGIC_ISP2812:
case PCI_QLOGIC_ISP2814:
did = 0x2800;
isp->isp_did = 0x2800;
isp->isp_mdvec = &mdvec_2800;
isp->isp_type = ISP_HA_FC_2800;
break;
@ -582,16 +580,6 @@ isp_pci_attach(device_t dev)
isp_get_specific_options(dev, i, isp);
}
isp->isp_osinfo.fw = NULL;
if (isp->isp_osinfo.fw == NULL) {
snprintf(fwname, sizeof (fwname), "isp_%04x", did);
isp->isp_osinfo.fw = firmware_get(fwname);
}
if (isp->isp_osinfo.fw != NULL) {
isp_prt(isp, ISP_LOGCONFIG, "loaded firmware %s", fwname);
isp->isp_mdvec->dv_ispfw = isp->isp_osinfo.fw->data;
}
/*
* Make sure that SERR, PERR, WRITE INVALIDATE and BUSMASTER are set.
*/
@ -650,15 +638,6 @@ isp_pci_attach(device_t dev)
return (0);
bad:
if (isp->isp_osinfo.fw == NULL && !IS_26XX(isp)) {
/*
* Failure to attach at boot time might have been caused
* by a missing ispfw(4). Except for 16Gb adapters,
* there's no loadable firmware for them.
*/
isp_prt(isp, ISP_LOGWARN, "See the ispfw(4) man page on "
"how to load known good firmware at boot time");
}
for (i = 0; i < isp->isp_nirq; i++) {
(void) bus_teardown_intr(dev, pcs->irq[i].irq, pcs->irq[i].ih);
(void) bus_release_resource(dev, SYS_RES_IRQ, pcs->irq[i].iqd,

View file

@ -41,14 +41,15 @@
#define MBOX_NO_OP 0x0000
#define MBOX_LOAD_RAM 0x0001
#define MBOX_EXEC_FIRMWARE 0x0002
#define MBOX_DUMP_RAM 0x0003
#define MBOX_LOAD_FLASH_FIRMWARE 0x0003
#define MBOX_WRITE_RAM_WORD 0x0004
#define MBOX_READ_RAM_WORD 0x0005
#define MBOX_MAILBOX_REG_TEST 0x0006
#define MBOX_VERIFY_CHECKSUM 0x0007
#define MBOX_ABOUT_FIRMWARE 0x0008
#define MBOX_LOAD_RISC_RAM_2100 0x0009
/* a */
#define MBOX_DUMP_RISC_RAM_2100 0x000a
#define MBOX_SECURE_FLASH_UPDATE 0x000a /* Secure Flash Update(28xx) */
#define MBOX_LOAD_RISC_RAM 0x000b
#define MBOX_DUMP_RISC_RAM 0x000c
#define MBOX_WRITE_RAM_WORD_EXTENDED 0x000d
@ -124,7 +125,6 @@
#define MBOX_GET_TARGET_STATUS 0x0056
/* These are for the ISP2X00 FC cards */
#define MBOX_LOAD_FLASH_FIRMWARE 0x0003
#define MBOX_WRITE_FC_SERDES_REG 0x0003 /* FC only */
#define MBOX_READ_FC_SERDES_REG 0x0004 /* FC only */
#define MBOX_GET_IO_STATUS 0x0012
@ -554,39 +554,47 @@ typedef struct {
/*
* About Firmware returns an 'attribute' word.
*/
#define ISP2400_FW_ATTR_CLASS2 0x0001
#define ISP2400_FW_ATTR_IP 0x0002
#define ISP2400_FW_ATTR_MULTIID 0x0004
#define ISP2400_FW_ATTR_SB2 0x0008
#define ISP2400_FW_ATTR_T10CRC 0x0010
#define ISP2400_FW_ATTR_VI 0x0020
#define ISP2400_FW_ATTR_MQ 0x0040
#define ISP2400_FW_ATTR_MSIX 0x0080
#define ISP2400_FW_ATTR_FCOE 0x0800
#define ISP2400_FW_ATTR_VP0 0x1000
#define ISP2400_FW_ATTR_EXPFW 0x2000
#define ISP2400_FW_ATTR_HOTFW 0x4000
#define ISP2400_FW_ATTR_EXTNDED 0x8000
#define ISP2400_FW_ATTR_EXTVP 0x00010000
#define ISP2400_FW_ATTR_VN2VN 0x00040000
#define ISP2400_FW_ATTR_EXMOFF 0x00080000
#define ISP2400_FW_ATTR_NPMOFF 0x00100000
#define ISP2400_FW_ATTR_DIFCHOP 0x00400000
#define ISP2400_FW_ATTR_SRIOV 0x02000000
#define ISP2400_FW_ATTR_ASICTMP 0x0200000000
#define ISP2400_FW_ATTR_ATIOMQ 0x0400000000
#define ISP_FW_ATTR_CLASS2 0x0001
#define ISP_FW_ATTR_IP 0x0002
#define ISP_FW_ATTR_MULTIID 0x0004
#define ISP_FW_ATTR_SB2 0x0008
#define ISP_FW_ATTR_T10CRC 0x0010
#define ISP_FW_ATTR_VI 0x0020
#define ISP_FW_ATTR_MQ 0x0040
#define ISP_FW_ATTR_MSIX 0x0080
#define ISP_FW_ATTR_FCOE 0x0800
#define ISP_FW_ATTR_VP0 0x1000
#define ISP_FW_ATTR_EXPFW 0x2000
#define ISP_FW_ATTR_HOTFW 0x4000
#define ISP_FW_ATTR_EXTNDED 0x8000
#define ISP_FW_ATTR_H_EXTVP 0x0001
#define ISP_FW_ATTR_H_NVME_FB 0x0002 /* NVMe first burst */
#define ISP_FW_ATTR_H_VN2VN 0x0004 /* Extended login */
#define ISP_FW_ATTR_H_EXMOFF 0x0008 /* Exchange offload */
#define ISP_FW_ATTR_H_NPMOFF 0x0010
#define ISP_FW_ATTR_H_DIFCHOP 0x0040
#define ISP_FW_ATTR_H_SRIOV 0x0200
#define ISP_FW_ATTR_H_NVME 0x0400 /* FC-NVMe */
#define ISP_FW_ATTR_H_NVME_UP 0x4000 /* FC-NVMe updated */
#define ISP_FW_ATTR_E0_ASICTMP 0x0002
#define ISP_FW_ATTR_E0_ATIOMQ 0x0004
#define ISP_FW_ATTR_E0_EDIF 0x0020 /* Encryption of data in flight */
#define ISP_FW_ATTR_E0_SCM 0x1000 /* Simplified Configuration and Management */
#define ISP_FW_ATTR_E0_NVME2 0x2000 /* NVMe2 */
/*
* This is only true for 24XX cards with this f/w attribute
*/
#define ISP_CAP_MULTI_ID(isp) \
(isp->isp_fwattr & ISP2400_FW_ATTR_MULTIID)
(isp->isp_fwattr & ISP_FW_ATTR_MULTIID)
#define ISP_GET_VPIDX(isp, tag) \
(ISP_CAP_MULTI_ID(isp) ? tag : 0)
#define ISP_CAP_MSIX(isp) \
(isp->isp_fwattr & ISP2400_FW_ATTR_MSIX)
(isp->isp_fwattr & ISP_FW_ATTR_MSIX)
#define ISP_CAP_VP0(isp) \
(isp->isp_fwattr & ISP2400_FW_ATTR_VP0)
(isp->isp_fwattr & ISP_FW_ATTR_VP0)
#define ISP_FCTAPE_ENABLED(isp, chan) \
((FCPARAM(isp, chan)->isp_xfwoptions & ICB2400_OPT2_FCTAPE) != 0)

View file

@ -343,4 +343,15 @@ struct flt_region {
#define FLT_REG_VPD_SEC_28XX_2 0x110
#define FLT_REG_VPD_SEC_28XX_3 0x112
#define ISP27XX_IMG_STATUS_VER_MAJOR 0x01
#define ISP27XX_IMG_STATUS_VER_MINOR 0x00
#define ISP27XX_IMG_STATUS_SIGN 0xfacefade
#define ISP28XX_IMG_STATUS_SIGN 0xfacefadf
#define ISP28XX_AUX_IMG_STATUS_SIGN 0xfacefaed
#define ISP27XX_DEFAULT_IMAGE 0
#define ISP27XX_PRIMARY_IMAGE 1
#define ISP27XX_SECONDARY_IMAGE 2
#define ISP_RISC_CODE_SEGMENTS 2
#endif /* _ISPREG_H */

View file

@ -67,7 +67,7 @@ struct ispmdvec {
int (*dv_send_cmd) (ispsoftc_t *, void *, void *, uint32_t);
int (*dv_irqsetup) (ispsoftc_t *);
void (*dv_dregs) (ispsoftc_t *, const char *);
const void * dv_ispfw; /* ptr to f/w */
const void * dv_ispfw; /* ptr to f/w of ispfw(4)*/
};
/*
@ -369,30 +369,39 @@ typedef struct {
int isp_use_gff_id; /* Use GFF_ID */
uint32_t flash_data_addr;
uint32_t fw_flashrev[4]; /* Flash F/W revision */
uint32_t fw_ispfwrev[4]; /* ispfw(4) F/W revision */
char fw_version_flash[12];
char fw_version_ispfw[12];
char fw_version_run[12];
uint32_t fw_ability_mask;
uint16_t max_supported_speed;
/*
* FLT
*/
uint16_t flt_length;
uint32_t flt_region_entries;
uint32_t flt_region_aux_img_status_pri;
uint32_t flt_region_aux_img_status_sec;
uint32_t flt_region_boot;
uint32_t flt_region_fcp_prio;
uint32_t flt_region_fdt;
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_fdt;
uint32_t flt_region_boot;
uint32_t flt_region_boot_sec;
uint32_t flt_region_npiv_conf;
uint32_t flt_region_nvram;
uint32_t flt_region_nvram_sec;
uint32_t flt_region_vpd;
uint32_t flt_region_fw;
uint32_t flt_region_fw_sec;
uint32_t flt_region_vpd_nvram;
uint32_t flt_region_vpd_nvram_sec;
uint32_t flt_region_vpd;
uint32_t flt_region_vpd_sec;
uint32_t flt_region_nvram;
uint32_t flt_region_nvram_sec;
uint32_t flt_region_npiv_conf;
uint32_t flt_region_gold_fw;
uint32_t flt_region_fcp_prio;
uint32_t flt_region_bootload;
uint32_t flt_region_img_status_pri;
uint32_t flt_region_img_status_sec;
uint32_t flt_region_aux_img_status_pri;
uint32_t flt_region_aux_img_status_sec;
/*
* Current active WWNN/WWPN
@ -420,6 +429,41 @@ typedef struct {
uint8_t isp_scanscratch[ISP_FC_SCRLEN];
} fcparam;
/*
* Image status
*/
struct isp_image_status{
uint8_t image_status_mask;
uint16_t generation;
uint8_t ver_major;
uint8_t ver_minor;
uint8_t bitmap; /* 28xx only */
uint8_t reserved[2];
uint32_t checksum;
uint32_t signature;
} __packed;
/* 28xx aux image status bitmap values */
#define ISP28XX_AUX_IMG_BOARD_CONFIG 0x1
#define ISP28XX_AUX_IMG_VPD_NVRAM 0x2
#define ISP28XX_AUX_IMG_NPIV_CONFIG_0_1 0x4
#define ISP28XX_AUX_IMG_NPIV_CONFIG_2_3 0x8
#define ISP28XX_AUX_IMG_NVME_PARAMS 0x10
/*
* Active regions
*/
struct active_regions {
uint8_t global;
struct {
uint8_t board_config;
uint8_t vpd_nvram;
uint8_t npiv_config_0_1;
uint8_t npiv_config_2_3;
uint8_t nvme_params;
} aux;
};
#define FW_CONFIG_WAIT 0
#define FW_WAIT_LINK 1
#define FW_WAIT_LOGIN 2
@ -473,11 +517,14 @@ struct ispsoftc {
*/
fcparam *isp_param; /* Per-channel storage. */
uint64_t isp_fwattr; /* firmware attributes */
uint16_t isp_fwattr; /* firmware attributes */
uint16_t isp_fwattr_h; /* firmware attributes */
uint16_t isp_fwattr_ext[2]; /* firmware attributes */
uint16_t isp_fwrev[3]; /* Loaded F/W revision */
uint16_t isp_maxcmds; /* max possible I/O cmds */
uint16_t isp_nchan; /* number of channels */
uint16_t isp_dblev; /* debug log mask */
uint32_t isp_did; /* DID */
uint8_t isp_type; /* HBA Chip Type */
uint8_t isp_revision; /* HBA Chip H/W Revision */
uint8_t isp_nirq; /* number of IRQs */
@ -554,8 +601,8 @@ struct ispsoftc {
#define ISP_CFG_NPORT 0x08 /* prefer {N/F}-Port connection */
#define ISP_CFG_1GB 0x10 /* force 1Gb connection (23XX only) */
#define ISP_CFG_2GB 0x20 /* force 2Gb connection (23XX only) */
#define ISP_CFG_NORELOAD 0x80 /* don't download f/w */
#define ISP_CFG_NONVRAM 0x40 /* ignore NVRAM */
#define ISP_CFG_NORELOAD 0x80 /* don't download f/w */
#define ISP_CFG_NOFCTAPE 0x100 /* disable FC-Tape */
#define ISP_CFG_FCTAPE 0x200 /* enable FC-Tape */
#define ISP_CFG_OWNFSZ 0x400 /* override NVRAM frame size */
@ -613,18 +660,22 @@ struct ispsoftc {
#define ISP_CODE_ORG 0x1000 /* default f/w code start */
#define ISP_CODE_ORG_2300 0x0800 /* ..except for 2300s */
#define ISP_CODE_ORG_2400 0x100000 /* ..and 2400s */
#define ISP_FW_REV(maj, min, mic) ((maj << 24) | (min << 16) | mic)
#define ISP_FW_MAJOR(code) ((code >> 24) & 0xff)
#define ISP_FW_MINOR(code) ((code >> 16) & 0xff)
#define ISP_FW_MICRO(code) ((code >> 8) & 0xff)
#define ISP_FW_REVX(xp) ((xp[0]<<24) | (xp[1] << 16) | xp[2])
#define ISP_FW_REV(maj, min, mic) (((maj) << 16) | ((min) << 8) | (mic))
#define ISP_FW_MAJOR(code) (((code) >> 16) & 0xff)
#define ISP_FW_MINOR(code) (((code) >> 8) & 0xff)
#define ISP_FW_MICRO(code) ((code) & 0xff)
#define ISP_FW_REVX(xp) (((xp)[0] << 16) | ((xp)[1] << 8) | (xp)[2])
#define ISP_FW_MAJORX(xp) (xp[0])
#define ISP_FW_MINORX(xp) (xp[1])
#define ISP_FW_MICROX(xp) (xp[2])
#define ISP_FW_NEWER_THAN(i, major, minor, micro) \
(ISP_FW_REVX((i)->isp_fwrev) > ISP_FW_REV(major, minor, micro))
(ISP_FW_REVX(i) > ISP_FW_REV(major, minor, micro))
#define ISP_FW_OLDER_THAN(i, major, minor, micro) \
(ISP_FW_REVX((i)->isp_fwrev) < ISP_FW_REV(major, minor, micro))
(ISP_FW_REVX(i) < ISP_FW_REV(major, minor, micro))
#define ISP_FW_NEWER_THANX(i, j) \
(ISP_FW_REVX(i) > ISP_FW_REVX(j))
#define ISP_FW_OLDER_THANX(i, j) \
(ISP_FW_REVX(i) < ISP_FW_REVX(j))
/*
* Chip Types
@ -651,6 +702,36 @@ struct ispsoftc {
#define DMA_LO32(x) ((uint32_t) (x))
#define DMA_HI32(x) ((uint32_t)(((uint64_t)x) >> 32))
/*
* function return status codes
*/
#define MBS_MASK 0x3fff
#define ISP_SUCCESS (MBOX_COMMAND_COMPLETE & MBS_MASK)
#define ISP_INVALID_COMMAND (MBOX_INVALID_COMMAND & MBS_MASK)
#define ISP_INTERFACE_ERROR (MBOX_HOST_INTERFACE_ERROR & MBS_MASK)
#define ISP_TEST_FAILED (MBOX_TEST_FAILED & MBS_MASK)
#define ISP_COMMAND_ERROR (MBOX_COMMAND_ERROR & MBS_MASK)
#define ISP_PARAMETER_ERROR (MBOX_COMMAND_PARAMETER_ERROR & MBS_MASK)
#define ISP_PORT_ID_USED (MBOX_PORT_ID_USED & MBS_MASK)
#define ISP_LOOP_ID_USED (MBOX_LOOP_ID_USED & MBS_MASK)
#define ISP_ALL_IDS_IN_USE (MBOX_ALL_IDS_IN_USE & MBS_MASK)
#define ISP_NOT_LOGGED_IN (MBOX_NOT_LOGGED_IN & MBS_MASK)
#define ISP_FUNCTION_TIMEOUT 0x100
#define ISP_FUNCTION_PARAMETER_ERROR 0x101
#define ISP_FUNCTION_FAILED 0x102
#define ISP_MEMORY_ALLOC_FAILED 0x103
#define ISP_LOCK_TIMEOUT 0x104
#define ISP_ABORTED 0x105
#define ISP_SUSPENDED 0x106
#define ISP_BUSY 0x107
#define ISP_ALREADY_REGISTERED 0x109
#define ISP_OS_TIMER_EXPIRED 0x10a
#define ISP_ERR_NO_QPAIR 0x10b
#define ISP_ERR_NOT_FOUND 0x10c
#define ISP_ERR_FROM_FW 0x10d
/*
* Core System Function Prototypes
*/