diff options
author | mjacob <mjacob@cvs.openbsd.org> | 1999-11-22 12:50:54 +0000 |
---|---|---|
committer | mjacob <mjacob@cvs.openbsd.org> | 1999-11-22 12:50:54 +0000 |
commit | 0e036db71d0acfe88e0d4439c86cc0d46888019c (patch) | |
tree | 6490cc3212b9477bc86005b1135db1fd214ee709 /sys | |
parent | 1b4c77835069067086bba32e9b8719c7fbb7a518 (diff) |
Far too many things to note- a complete new revision coming in including
FABRIC support...
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ic/isp.c | 3009 | ||||
-rw-r--r-- | sys/dev/ic/isp_inline.h | 278 | ||||
-rw-r--r-- | sys/dev/ic/isp_openbsd.c | 586 | ||||
-rw-r--r-- | sys/dev/ic/isp_openbsd.h | 169 | ||||
-rw-r--r-- | sys/dev/ic/ispmbox.h | 644 | ||||
-rw-r--r-- | sys/dev/ic/ispreg.h | 137 | ||||
-rw-r--r-- | sys/dev/ic/ispvar.h | 396 |
7 files changed, 2914 insertions, 2305 deletions
diff --git a/sys/dev/ic/isp.c b/sys/dev/ic/isp.c index 2100541eb23..11c53052150 100644 --- a/sys/dev/ic/isp.c +++ b/sys/dev/ic/isp.c @@ -1,10 +1,9 @@ -/* $OpenBSD: isp.c,v 1.7 1999/03/26 00:34:59 mjacob Exp $ */ -/* release_03_25_99 */ +/* $OpenBSD: isp.c,v 1.8 1999/11/22 12:50:52 mjacob Exp $ */ /* * Machine and OS Independent (well, as best as possible) * code for the Qlogic ISP SCSI adapters. * - * Copyright (c) 1997, 1998 by Matthew Jacob + * Copyright (c) 1997, 1998, 1999 by Matthew Jacob * NASA/Ames Research Center * All rights reserved. * @@ -65,67 +64,42 @@ /* * Local static data */ -#ifdef ISP_TARGET_MODE -static const char tgtiqd[36] = { - 0x03, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x51, 0x4C, 0x4F, 0x47, 0x49, 0x43, 0x20, 0x20, -#ifdef __NetBSD__ - 0x4E, 0x45, 0x54, 0x42, 0x53, 0x44, 0x20, 0x20, -#else -# ifdef __FreeBSD__ - 0x46, 0x52, 0x45, 0x45, 0x42, 0x52, 0x44, 0x20, -# else -# ifdef __OpenBSD__ - 0x4F, 0x50, 0x45, 0x4E, 0x42, 0x52, 0x44, 0x20, -# else -# ifdef linux - 0x4C, 0x49, 0x4E, 0x55, 0x58, 0x20, 0x20, 0x20, -# else -# endif -# endif -# endif -#endif - 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x31 -}; -#endif - /* * Local function prototypes. */ static int isp_parse_async __P((struct ispsoftc *, int)); static int isp_handle_other_response -__P((struct ispsoftc *, ispstatusreq_t *, u_int8_t *)); -#ifdef ISP_TARGET_MODE -static int isp_modify_lun __P((struct ispsoftc *, int, int, int)); -static void isp_notify_ack __P((struct ispsoftc *, void *)); -static void isp_handle_atio __P((struct ispsoftc *, void *)); -static void isp_handle_atio2 __P((struct ispsoftc *, void *)); -static void isp_handle_ctio __P((struct ispsoftc *, void *)); -static void isp_handle_ctio2 __P((struct ispsoftc *, void *)); -#endif +__P((struct ispsoftc *, ispstatusreq_t *, u_int16_t *)); static void isp_parse_status __P((struct ispsoftc *, ispstatusreq_t *, ISP_SCSI_XFER_T *)); -static void isp_fastpost_complete __P((struct ispsoftc *, int)); +static void isp_fastpost_complete __P((struct ispsoftc *, u_int32_t)); +static void isp_scsi_init __P((struct ispsoftc *)); +static void isp_scsi_channel_init __P((struct ispsoftc *, int)); static void isp_fibre_init __P((struct ispsoftc *)); static void isp_mark_getpdb_all __P((struct ispsoftc *)); static int isp_getpdb __P((struct ispsoftc *, int, isp_pdb_t *)); +static u_int64_t isp_get_portname __P((struct ispsoftc *, int, int)); static int isp_fclink_test __P((struct ispsoftc *, int)); +static int isp_same_lportdb __P((struct lportdb *, struct lportdb *)); +static int isp_pdb_sync __P((struct ispsoftc *, int)); +#ifdef ISP2100_FABRIC +static int isp_scan_fabric __P((struct ispsoftc *)); +#endif static void isp_fw_state __P((struct ispsoftc *)); static void isp_dumpregs __P((struct ispsoftc *, const char *)); -static void isp_dumpxflist __P((struct ispsoftc *)); static void isp_mboxcmd __P((struct ispsoftc *, mbreg_t *)); -static void isp_update __P((struct ispsoftc *)); -static void isp_setdfltparm __P((struct ispsoftc *)); +static void isp_update __P((struct ispsoftc *)); +static void isp_update_bus __P((struct ispsoftc *, int)); +static void isp_setdfltparm __P((struct ispsoftc *, int)); static int isp_read_nvram __P((struct ispsoftc *)); static void isp_rdnvram_word __P((struct ispsoftc *, int, u_int16_t *)); /* * Reset Hardware. * - * Hit the chip over the head, download new f/w and set it running. + * Hit the chip over the head, download new f/w if available and set it running. * * Locking done elsewhere. */ @@ -159,38 +133,52 @@ isp_reset(isp) * case, we don't really use this yet, but we may in * the future. */ - if (isp->isp_used == 0) { + if (isp->isp_touched == 0) { /* * Just in case it was paused... */ ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE); mbs.param[0] = MBOX_ABOUT_FIRMWARE; isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - /* - * If this fails, it probably means we're running - * an old prom, if anything at all... - */ - isp->isp_romfw_rev = 0; - } else { - isp->isp_romfw_rev = - (((u_int16_t) mbs.param[1]) << 10) + mbs.param[2]; + /* + * If this fails, it probably means we're running + * an old prom, if anything at all... + */ + if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { + isp->isp_romfw_rev[0] = mbs.param[1]; + isp->isp_romfw_rev[1] = mbs.param[2]; + isp->isp_romfw_rev[2] = mbs.param[3]; } - isp->isp_used = 1; + isp->isp_touched = 1; } + DISABLE_INTS(isp); + /* - * Put it into PAUSE mode. + * Put the board into PAUSE mode. */ ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE); if (IS_FC(isp)) { - revname = "2100"; + revname = "2X00"; + switch (isp->isp_type) { + case ISP_HA_FC_2100: + revname[1] = '1'; + break; + case ISP_HA_FC_2200: + revname[1] = '2'; + break; + default: + break; + } + } else if (IS_12X0(isp)) { + revname = "12X0"; + isp->isp_clock = 60; } else if (IS_1080(isp)) { u_int16_t l; sdparam *sdp = isp->isp_param; revname = "1080"; - sdp->isp_clock = 100; + isp->isp_clock = 100; l = ISP_READ(isp, SXP_PINS_DIFF) & ISP1080_MODE_MASK; switch (l) { case ISP1080_LVD_MODE: @@ -225,7 +213,7 @@ isp_reset(isp) case 1: revname = "1020"; isp->isp_type = ISP_HA_SCSI_1020; - sdp->isp_clock = 40; + isp->isp_clock = 40; break; case 2: /* @@ -235,23 +223,28 @@ isp_reset(isp) */ revname = "1020A"; isp->isp_type = ISP_HA_SCSI_1020A; - sdp->isp_clock = 40; + isp->isp_clock = 40; break; case 3: revname = "1040"; isp->isp_type = ISP_HA_SCSI_1040; - sdp->isp_clock = 60; + isp->isp_clock = 60; break; case 4: revname = "1040A"; isp->isp_type = ISP_HA_SCSI_1040A; - sdp->isp_clock = 60; + isp->isp_clock = 60; break; case 5: revname = "1040B"; isp->isp_type = ISP_HA_SCSI_1040B; - sdp->isp_clock = 60; + isp->isp_clock = 60; break; + case 6: + revname = "1040C(?)"; + isp->isp_type = ISP_HA_SCSI_1040C; + isp->isp_clock = 60; + break; } /* * Now, while we're at it, gather info about ultra @@ -276,7 +269,7 @@ isp_reset(isp) * If we're in Ultra Mode, we have to be 60Mhz clock- * even for the SBus version. */ - sdp->isp_clock = 60; + isp->isp_clock = 60; } else { sdp->isp_ultramode = 0; /* @@ -289,8 +282,8 @@ isp_reset(isp) * our generic determinations. */ if (isp->isp_mdvec->dv_clock) { - if (isp->isp_mdvec->dv_clock < sdp->isp_clock) { - sdp->isp_clock = isp->isp_mdvec->dv_clock; + if (isp->isp_mdvec->dv_clock < isp->isp_clock) { + isp->isp_clock = isp->isp_mdvec->dv_clock; } } @@ -355,7 +348,7 @@ again: */ loops = MBOX_DELAY_COUNT; for (;;) { - if (isp->isp_type & ISP_HA_SCSI) { + if (IS_SCSI(isp)) { if (!(ISP_READ(isp, BIU_ICR) & BIU_ICR_SOFT_RESET)) break; } else { @@ -432,11 +425,6 @@ again: ISP_RESET1(isp); /* - * Enable interrupts - */ - ENABLE_INTS(isp); - - /* * Wait for everything to finish firing up... */ loops = MBOX_DELAY_COUNT; @@ -465,7 +453,7 @@ again: return; } - if (isp->isp_type & ISP_HA_SCSI) { + if (IS_SCSI(isp)) { mbs.param[0] = MBOX_MAILBOX_REG_TEST; mbs.param[1] = 0xdead; mbs.param[2] = 0xbeef; @@ -496,13 +484,16 @@ again: * whether we have f/w at all and whether a config flag * has disabled our download. */ - if ((isp->isp_mdvec->dv_fwlen == 0) || + if ((isp->isp_mdvec->dv_ispfw == NULL) || (isp->isp_confopts & ISP_CFG_NORELOAD)) { dodnld = 0; } - if (dodnld && isp->isp_mdvec->dv_fwlen) { - for (i = 0; i < isp->isp_mdvec->dv_fwlen; i++) { + if (dodnld) { + u_int16_t fwlen = isp->isp_mdvec->dv_fwlen; + if (fwlen == 0) + fwlen = isp->isp_mdvec->dv_ispfw[3]; /* usually here */ + for (i = 0; i < fwlen; i++) { mbs.param[0] = MBOX_WRITE_RAM_WORD; mbs.param[1] = isp->isp_mdvec->dv_codeorg + i; mbs.param[2] = isp->isp_mdvec->dv_ispfw[i]; @@ -543,44 +534,64 @@ again: mbs.param[1] = 0x1000; isp_mboxcmd(isp, &mbs); - if (isp->isp_type & ISP_HA_SCSI) { - sdparam *sdp = isp->isp_param; + if (IS_SCSI(isp)) { /* * Set CLOCK RATE, but only if asked to. */ - if (sdp->isp_clock) { + if (isp->isp_clock) { mbs.param[0] = MBOX_SET_CLOCK_RATE; - mbs.param[1] = sdp->isp_clock; + mbs.param[1] = isp->isp_clock; isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_dumpregs(isp, "failed to set CLOCKRATE"); + PRINTF("failed to set clockrate (0x%x)\n", + mbs.param[0]); /* but continue */ - } else { - IDPRINTF(3, ("%s: setting input clock to %d\n", - isp->isp_name, sdp->isp_clock)); } } } mbs.param[0] = MBOX_ABOUT_FIRMWARE; isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_dumpregs(isp, "ABOUT FIRMWARE command failed"); + PRINTF("could not get f/w started (0x%x)\n", mbs.param[0]); return; } - PRINTF("%s: Board Revision %s, %s F/W Revision %d.%d\n", - isp->isp_name, revname, dodnld? "loaded" : "resident", - mbs.param[1], mbs.param[2]); + CFGPRINTF("%s: Board Revision %s, %s F/W Revision %d.%d.%d\n", + isp->isp_name, revname, dodnld? "loaded" : "resident", + mbs.param[1], mbs.param[2], mbs.param[3]); if (IS_FC(isp)) { if (ISP_READ(isp, BIU2100_CSR) & BIU2100_PCI64) { - PRINTF("%s: in 64-Bit PCI slot\n", isp->isp_name); + CFGPRINTF("%s: in 64-Bit PCI slot\n", isp->isp_name); } } - isp->isp_fwrev = (((u_int16_t) mbs.param[1]) << 10) + mbs.param[2]; - if (isp->isp_romfw_rev && dodnld) { - PRINTF("%s: Last F/W revision was %d.%d\n", isp->isp_name, - isp->isp_romfw_rev >> 10, isp->isp_romfw_rev & 0x3ff); + + isp->isp_fwrev[0] = mbs.param[1]; + isp->isp_fwrev[1] = mbs.param[2]; + isp->isp_fwrev[2] = mbs.param[3]; + if (isp->isp_romfw_rev[0] || isp->isp_romfw_rev[1] || + isp->isp_romfw_rev[2]) { + CFGPRINTF("%s: Last F/W revision was %d.%d.%d\n", isp->isp_name, + isp->isp_romfw_rev[0], isp->isp_romfw_rev[1], + isp->isp_romfw_rev[2]); + } + + mbs.param[0] = MBOX_GET_FIRMWARE_STATUS; + isp_mboxcmd(isp, &mbs); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + PRINTF("%s: could not GET FIRMWARE STATUS\n", isp->isp_name); + return; } + isp->isp_maxcmds = mbs.param[2]; + CFGPRINTF("%s: %d max I/O commands supported\n", + isp->isp_name, mbs.param[2]); isp_fw_state(isp); + + /* + * Set up DMA for the request and result mailboxes. + */ + if (ISP_MBOXDMASETUP(isp) != 0) { + PRINTF("%s: can't setup dma mailboxes\n", isp->isp_name); + return; + } isp->isp_state = ISP_RESETSTATE; } @@ -594,108 +605,208 @@ void isp_init(isp) struct ispsoftc *isp; { - sdparam *sdp; - mbreg_t mbs; - int tgt; - - /* - * Must do first. - */ - isp_setdfltparm(isp); - /* - * Set up DMA for the request and result mailboxes. + * Must do this first to get defaults established. */ - if (ISP_MBOXDMASETUP(isp) != 0) { - PRINTF("%s: can't setup dma mailboxes\n", isp->isp_name); - return; + isp_setdfltparm(isp, 0); + if (IS_12X0(isp)) { + isp_setdfltparm(isp, 1); } - /* - * If we're fibre, we have a completely different - * initialization method. - */ if (IS_FC(isp)) { isp_fibre_init(isp); - return; + } else { + isp_scsi_init(isp); } - sdp = isp->isp_param; +} + +static void +isp_scsi_init(isp) + struct ispsoftc *isp; +{ + sdparam *sdp_chan0, *sdp_chan1; + mbreg_t mbs; + + sdp_chan0 = isp->isp_param; + sdp_chan1 = sdp_chan0; + if (IS_12X0(isp)) { + sdp_chan1++; + } + + /* First do overall per-card settings. */ /* * If we have fast memory timing enabled, turn it on. */ - if (sdp->isp_fast_mttr) { + if (isp->isp_fast_mttr) { ISP_WRITE(isp, RISC_MTR, 0x1313); } /* - * Set (possibly new) Initiator ID. + * Set Retry Delay and Count. + * You set both channels at the same time. */ - mbs.param[0] = MBOX_SET_INIT_SCSI_ID; - mbs.param[1] = sdp->isp_initiator_id; + mbs.param[0] = MBOX_SET_RETRY_COUNT; + mbs.param[1] = sdp_chan0->isp_retry_count; + mbs.param[2] = sdp_chan0->isp_retry_delay; + mbs.param[6] = sdp_chan1->isp_retry_count; + mbs.param[7] = sdp_chan1->isp_retry_delay; + isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_dumpregs(isp, "failed to set initiator id"); + PRINTF("%s: failed to set retry count and retry delay\n", + isp->isp_name); return; } /* - * Set Retry Delay and Count + * Set ASYNC DATA SETUP time. This is very important. */ - mbs.param[0] = MBOX_SET_RETRY_COUNT; - mbs.param[1] = sdp->isp_retry_count; - mbs.param[2] = sdp->isp_retry_delay; + mbs.param[0] = MBOX_SET_ASYNC_DATA_SETUP_TIME; + mbs.param[1] = sdp_chan0->isp_async_data_setup; + mbs.param[2] = sdp_chan1->isp_async_data_setup; isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_dumpregs(isp, "failed to set retry count and delay"); + PRINTF("%s: failed to set asynchronous data setup time\n", + isp->isp_name); return; } /* - * Set ASYNC DATA SETUP time. This is very important. + * Set ACTIVE Negation State. */ - mbs.param[0] = MBOX_SET_ASYNC_DATA_SETUP_TIME; - mbs.param[1] = sdp->isp_async_data_setup; + mbs.param[0] = MBOX_SET_ACT_NEG_STATE; + mbs.param[1] = + (sdp_chan0->isp_req_ack_active_neg << 4) | + (sdp_chan0->isp_data_line_active_neg << 5); + mbs.param[2] = + (sdp_chan1->isp_req_ack_active_neg << 4) | + (sdp_chan1->isp_data_line_active_neg << 5); + + isp_mboxcmd(isp, &mbs); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + PRINTF("%s: failed to set active negation state " + "(%d,%d),(%d,%d)\n", isp->isp_name, + sdp_chan0->isp_req_ack_active_neg, + sdp_chan0->isp_data_line_active_neg, + sdp_chan1->isp_req_ack_active_neg, + sdp_chan1->isp_data_line_active_neg); + /* + * But don't return. + */ + } + + /* + * Set the Tag Aging limit + */ + mbs.param[0] = MBOX_SET_TAG_AGE_LIMIT; + mbs.param[1] = sdp_chan0->isp_tag_aging; + mbs.param[2] = sdp_chan1->isp_tag_aging; isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_dumpregs(isp, "failed to set async data setup time"); + PRINTF("%s: failed to set tag age limit (%d,%d)\n", + isp->isp_name, sdp_chan0->isp_tag_aging, + sdp_chan1->isp_tag_aging); return; } /* - * Set ACTIVE Negation State. + * Set selection timeout. */ - mbs.param[0] = MBOX_SET_ACTIVE_NEG_STATE; - mbs.param[1] = - (sdp->isp_req_ack_active_neg << 4) | - (sdp->isp_data_line_active_neg << 5); + mbs.param[0] = MBOX_SET_SELECT_TIMEOUT; + mbs.param[1] = sdp_chan0->isp_selection_timeout; + mbs.param[2] = sdp_chan1->isp_selection_timeout; isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_dumpregs(isp, "failed to set active neg state"); + PRINTF("%s: failed to set selection timeout\n", isp->isp_name); return; } + /* now do per-channel settings */ + isp_scsi_channel_init(isp, 0); + if (IS_12X0(isp)) + isp_scsi_channel_init(isp, 1); + /* - * Set the Tag Aging limit + * Now enable request/response queues */ - mbs.param[0] = MBOX_SET_TAG_AGE_LIMIT; - mbs.param[1] = sdp->isp_tag_aging; + mbs.param[0] = MBOX_INIT_RES_QUEUE; + mbs.param[1] = RESULT_QUEUE_LEN; + mbs.param[2] = DMA_MSW(isp->isp_result_dma); + mbs.param[3] = DMA_LSW(isp->isp_result_dma); + mbs.param[4] = 0; + mbs.param[5] = 0; isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_dumpregs(isp, "failed to set tag age limit"); + PRINTF("%s: set of response queue failed\n", isp->isp_name); return; } + isp->isp_residx = 0; + + mbs.param[0] = MBOX_INIT_REQ_QUEUE; + mbs.param[1] = RQUEST_QUEUE_LEN; + mbs.param[2] = DMA_MSW(isp->isp_rquest_dma); + mbs.param[3] = DMA_LSW(isp->isp_rquest_dma); + mbs.param[4] = 0; + mbs.param[5] = 0; + isp_mboxcmd(isp, &mbs); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + PRINTF("%s: set of request queue failed\n", isp->isp_name); + return; + } + isp->isp_reqidx = isp->isp_reqodx = 0; /* - * Set selection timeout. + * Turn on Fast Posting, LVD transitions */ - mbs.param[0] = MBOX_SET_SELECT_TIMEOUT; - mbs.param[1] = sdp->isp_selection_timeout; + if (IS_1080(isp) || + ISP_FW_REVX(isp->isp_fwrev) >= ISP_FW_REV(7, 55, 0)) { + mbs.param[0] = MBOX_SET_FW_FEATURES; +#ifndef ISP_NO_FASTPOST_SCSI + mbs.param[1] |= FW_FEATURE_FAST_POST; +#else + mbs.param[1] = 0; +#endif + if (IS_1080(isp)) + mbs.param[1] |= FW_FEATURE_LVD_NOTIFY; + if (mbs.param[1] != 0) { + isp_mboxcmd(isp, &mbs); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + PRINTF("%s: unable enable FW features\n", + isp->isp_name); + } + } + } + + /* + * Let the outer layers decide whether to issue a SCSI bus reset. + */ + isp->isp_state = ISP_INITSTATE; +} + +static void +isp_scsi_channel_init(isp, channel) + struct ispsoftc *isp; + int channel; +{ + sdparam *sdp; + mbreg_t mbs; + int tgt; + + sdp = isp->isp_param; + sdp += channel; + + /* + * Set (possibly new) Initiator ID. + */ + mbs.param[0] = MBOX_SET_INIT_SCSI_ID; + mbs.param[1] = (channel << 7) | sdp->isp_initiator_id; isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_dumpregs(isp, "failed to set selection timeout"); + PRINTF("%s: cannot set initiator id on bus %d to %d\n", + isp->isp_name, channel, sdp->isp_initiator_id); return; } @@ -706,19 +817,31 @@ isp_init(isp) int maxlun, lun; u_int16_t sdf; - if (sdp->isp_devparam[tgt].dev_enable == 0) + if (sdp->isp_devparam[tgt].dev_enable == 0) { + IDPRINTF(1, ("%s: skipping target %d bus %d settings\n", + isp->isp_name, tgt, channel)); continue; + } - sdf = DPARM_SAFE_DFLT; /* - * It is not quite clear when this changed over so that - * we could force narrow and async, so assume >= 7.55. + * If we're in LVD mode, then we pretty much should + * only disable tagged queuing. */ - if (isp->isp_fwrev >= ISP_FW_REV(7, 55)) { - sdf |= DPARM_NARROW | DPARM_ASYNC; + if (IS_1080(isp) && sdp->isp_lvdmode) { + sdf = DPARM_DEFAULT & ~DPARM_TQING; + } else { + sdf = DPARM_SAFE_DFLT; + /* + * It is not quite clear when this changed over so that + * we could force narrow and async, so assume >= 7.55. + */ + if (ISP_FW_REVX(isp->isp_fwrev) >= + ISP_FW_REV(7, 55, 0)) { + sdf |= DPARM_NARROW | DPARM_ASYNC; + } } mbs.param[0] = MBOX_SET_TARGET_PARAMS; - mbs.param[1] = tgt << 8; + mbs.param[1] = (tgt << 8) | (channel << 15); mbs.param[2] = sdf; mbs.param[3] = (sdp->isp_devparam[tgt].sync_offset << 8) | @@ -727,7 +850,7 @@ isp_init(isp) if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { sdf = DPARM_SAFE_DFLT; mbs.param[0] = MBOX_SET_TARGET_PARAMS; - mbs.param[1] = tgt << 8; + mbs.param[1] = (tgt << 8) | (channel << 15); mbs.param[2] = sdf; mbs.param[3] = (sdp->isp_devparam[tgt].sync_offset << 8) | @@ -739,6 +862,8 @@ isp_init(isp) continue; } } + +#if 0 /* * We don't update dev_flags with what we've set * because that's not the ultimate goal setting. @@ -746,7 +871,7 @@ isp_init(isp) * cur_dflags by getting target parameters. */ mbs.param[0] = MBOX_GET_TARGET_PARAMS; - mbs.param[1] = (tgt << 8); + mbs.param[1] = (tgt << 8) | (channel << 15); isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { /* @@ -759,6 +884,15 @@ isp_init(isp) sdp->isp_devparam[tgt].cur_offset = mbs.param[3] >> 8; sdp->isp_devparam[tgt].cur_period = mbs.param[3] & 0xff; } + IDPRINTF(3, ("%s: set flags 0x%x got 0x%x back for target %d\n", + isp->isp_name, sdf, mbs.param[2], tgt)); +#else + /* + * We don't update any information because we need to run + * at least one command per target to cause a new state + * to be latched. + */ +#endif /* * Ensure that we don't believe tagged queuing is enabled yet. * It turns out that sometimes the ISP just ignores our @@ -766,11 +900,13 @@ isp_init(isp) * seen yet. */ sdp->isp_devparam[tgt].cur_dflags &= ~DPARM_TQING; - - maxlun = (isp->isp_fwrev >= ISP_FW_REV(7, 55))? 32 : 8; + if (ISP_FW_REVX(isp->isp_fwrev) >= ISP_FW_REV(7, 55, 0)) + maxlun = 32; + else + maxlun = 8; for (lun = 0; lun < maxlun; lun++) { mbs.param[0] = MBOX_SET_DEV_QUEUE_PARAMS; - mbs.param[1] = (tgt << 8) | lun; + mbs.param[1] = (channel << 15) | (tgt << 8) | lun; mbs.param[2] = sdp->isp_max_queue_depth; mbs.param[3] = sdp->isp_devparam[tgt].exc_throttle; isp_mboxcmd(isp, &mbs); @@ -781,81 +917,7 @@ isp_init(isp) break; } } - /* - * And mark this as an unannounced device - */ - sdp->isp_devparam[tgt].dev_announced = 0; - } - - mbs.param[0] = MBOX_INIT_RES_QUEUE; - mbs.param[1] = RESULT_QUEUE_LEN; - mbs.param[2] = (u_int16_t) (isp->isp_result_dma >> 16); - mbs.param[3] = (u_int16_t) (isp->isp_result_dma & 0xffff); - mbs.param[4] = 0; - mbs.param[5] = 0; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_dumpregs(isp, "set of response queue failed"); - return; } - isp->isp_residx = 0; - - mbs.param[0] = MBOX_INIT_REQ_QUEUE; - mbs.param[1] = RQUEST_QUEUE_LEN; - mbs.param[2] = (u_int16_t) (isp->isp_rquest_dma >> 16); - mbs.param[3] = (u_int16_t) (isp->isp_rquest_dma & 0xffff); - mbs.param[4] = 0; - mbs.param[5] = 0; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_dumpregs(isp, "set of request queue failed"); - return; - } - isp->isp_reqidx = isp->isp_reqodx = 0; - - /* - * Turn on Fast Posting, LVD transitions - */ - - if (IS_1080(isp) || isp->isp_fwrev >= ISP_FW_REV(7, 55)) { - mbs.param[0] = MBOX_SET_FW_FEATURES; -#ifndef ISP_NO_FASTPOST_SCSI - mbs.param[1] |= FW_FEATURE_FAST_POST; -#else - mbs.param[1] = 0; -#endif - if (IS_1080(isp)) - mbs.param[1] |= FW_FEATURE_LVD_NOTIFY; - if (mbs.param[1] != 0) { - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - PRINTF("%s: unable enable FW features\n", - isp->isp_name); - } - } - } - - /* - * Let the outer layers decide whether to issue a SCSI bus reset. - */ -#if 0 - /* - * XXX: See whether or not for 7.55 F/W or later we - * XXX: can do without this, and see whether we should - * XXX: honor the NVRAM SCSI_RESET_DISABLE token. - */ - mbs.param[0] = MBOX_BUS_RESET; - mbs.param[1] = 3; - isp_mboxcmd(isp, &mbs); - if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_dumpregs(isp, "SCSI bus reset failed"); - } - /* - * This is really important to have set after a bus reset. - */ - isp->isp_sendmarker = 1; -#endif - isp->isp_state = ISP_INITSTATE; } /* @@ -870,7 +932,7 @@ isp_fibre_init(isp) fcparam *fcp; isp_icb_t *icbp; mbreg_t mbs; - int count, loopid; + int loopid; fcp = isp->isp_param; @@ -883,42 +945,48 @@ isp_fibre_init(isp) * best way to figure this out XXX */ #ifndef __i386__ - loopid = DEFAULT_LOOPID; + loopid = DEFAULT_LOOPID(isp); #else loopid = fcp->isp_loopid; #endif -#if defined(ISP2100_FABRIC) && defined(ISP2100_SCCLUN) - PRINTF("%s: Fabric Support, Expanded Lun Support\n", isp->isp_name); -#endif -#if defined(ISP2100_FABRIC) && !defined(ISP2100_SCCLUN) - PRINTF("%s: Fabric Support\n", isp->isp_name); -#endif -#if !defined(ISP2100_FABRIC) && defined(ISP2100_SCCLUN) - PRINTF("%s: Expanded Lun Support\n", isp->isp_name); -#endif - icbp = (isp_icb_t *) fcp->isp_scratch; MEMZERO(icbp, sizeof (*icbp)); icbp->icb_version = ICB_VERSION1; #ifdef ISP_TARGET_MODE - fcp->isp_fwoptions = ICBOPT_TGT_ENABLE|ICBOPT_INI_TGTTYPE; + fcp->isp_fwoptions = ICBOPT_TGT_ENABLE; #else fcp->isp_fwoptions = 0; #endif - fcp->isp_fwoptions |= ICBOPT_INI_ADISC|ICBOPT_FAIRNESS; + + fcp->isp_fwoptions |= ICBOPT_FAIRNESS; + /* + * If this is a 2100 < revision 5, we have to turn off FAIRNESS. + */ + if ((isp->isp_type == ISP_HA_FC_2100) && isp->isp_revision < 5) { + fcp->isp_fwoptions &= ~ICBOPT_FAIRNESS; + } fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE; fcp->isp_fwoptions |= ICBOPT_HARD_ADDRESS; + /* + * We have to use FULL LOGIN even though it resets the loop too much + * because otherwise port database entries don't get updated after + * a LIP- this is a known f/w bug. + */ + if (ISP_FW_REVX(isp->isp_fwrev) < ISP_FW_REV(1, 17, 0)) { + fcp->isp_fwoptions |= ICBOPT_FULL_LOGIN; + } #ifndef ISP_NO_FASTPOST_FC fcp->isp_fwoptions |= ICBOPT_FAST_POST; #endif -#ifdef CHECKME - fcp->isp_fwoptions |= ICBOPT_USE_PORTNAME; -#endif -#ifdef ISP2100_FABRIC - fcp->isp_fwoptions |= ICBOPT_FULL_LOGIN; -#endif + if (isp->isp_confopts & ISP_CFG_FULL_DUPLEX) + fcp->isp_fwoptions |= ICBOPT_FULL_DUPLEX; + + /* + * We don't set ICBOPT_PORTNAME because we want our + * Node Name && Port Names to be distinct. + */ icbp->icb_fwoptions = fcp->isp_fwoptions; icbp->icb_maxfrmlen = fcp->isp_maxfrmlen; @@ -926,65 +994,87 @@ isp_fibre_init(isp) icbp->icb_maxfrmlen > ICB_MAX_FRMLEN) { PRINTF("%s: bad frame length (%d) from NVRAM- using %d\n", isp->isp_name, fcp->isp_maxfrmlen, ICB_DFLT_FRMLEN); + icbp->icb_maxfrmlen = ICB_DFLT_FRMLEN; } icbp->icb_maxalloc = fcp->isp_maxalloc; + if (icbp->icb_maxalloc < 1) { + PRINTF("%s: bad maximum allocation (%d)- using 16\n", + isp->isp_name, fcp->isp_maxalloc); + icbp->icb_maxalloc = 16; + } icbp->icb_execthrottle = fcp->isp_execthrottle; + if (icbp->icb_execthrottle < 1) { + PRINTF("%s: bad execution throttle of %d- using 16\n", + isp->isp_name, fcp->isp_execthrottle); + icbp->icb_execthrottle = ICB_DFLT_THROTTLE; + } icbp->icb_retry_delay = fcp->isp_retry_delay; icbp->icb_retry_count = fcp->isp_retry_count; icbp->icb_hardaddr = loopid; + icbp->icb_logintime = 30; /* 30 second login timeout */ - MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, fcp->isp_wwn); - if (icbp->icb_fwoptions & ICBOPT_USE_PORTNAME) { - u_int64_t portname = fcp->isp_wwn | (2LL << 56); - MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, portname); + if (fcp->isp_nodewwn) { + u_int64_t pn; + MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, fcp->isp_nodewwn); + if (fcp->isp_portwwn) { + pn = fcp->isp_portwwn; + } else { + pn = fcp->isp_nodewwn | + (((u_int64_t)(isp->isp_unit+1)) << 56); + } + /* + * If the top nibble is 2, we can construct a port name + * from the node name by setting a nonzero instance in + * bits 56..59. Otherwise, we need to make it identical + * to Node name... + */ + if ((fcp->isp_nodewwn >> 60) == 2) { + MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, pn); + } else { + MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, + fcp->isp_nodewwn); + } + } else { + fcp->isp_fwoptions &= ~(ICBOPT_USE_PORTNAME|ICBOPT_FULL_LOGIN); } icbp->icb_rqstqlen = RQUEST_QUEUE_LEN; icbp->icb_rsltqlen = RESULT_QUEUE_LEN; - icbp->icb_rqstaddr[RQRSP_ADDR0015] = - (u_int16_t) (isp->isp_rquest_dma & 0xffff); - icbp->icb_rqstaddr[RQRSP_ADDR1631] = - (u_int16_t) (isp->isp_rquest_dma >> 16); - icbp->icb_respaddr[RQRSP_ADDR0015] = - (u_int16_t) (isp->isp_result_dma & 0xffff); - icbp->icb_respaddr[RQRSP_ADDR1631] = - (u_int16_t) (isp->isp_result_dma >> 16); - MemoryBarrier(); + icbp->icb_rqstaddr[RQRSP_ADDR0015] = DMA_LSW(isp->isp_rquest_dma); + icbp->icb_rqstaddr[RQRSP_ADDR1631] = DMA_MSW(isp->isp_rquest_dma); + icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_LSW(isp->isp_result_dma); + icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_MSW(isp->isp_result_dma); + ISP_SWIZZLE_ICB(isp, icbp); + + /* + * Do this *before* initializing the firmware. + */ + isp_mark_getpdb_all(isp); + fcp->isp_fwstate = FW_CONFIG_WAIT; + fcp->isp_loopstate = LOOP_NIL; - for (count = 0; count < 10; count++) { + MemoryBarrier(); + for (;;) { mbs.param[0] = MBOX_INIT_FIRMWARE; mbs.param[1] = 0; - mbs.param[2] = (u_int16_t) (fcp->isp_scdma >> 16); - mbs.param[3] = (u_int16_t) (fcp->isp_scdma & 0xffff); + mbs.param[2] = DMA_MSW(fcp->isp_scdma); + mbs.param[3] = DMA_LSW(fcp->isp_scdma); mbs.param[4] = 0; mbs.param[5] = 0; mbs.param[6] = 0; mbs.param[7] = 0; - isp_mboxcmd(isp, &mbs); - - switch (mbs.param[0]) { - case MBOX_COMMAND_COMPLETE: - count = 10; - break; - case ASYNC_PDB_CHANGED: - isp_mark_getpdb_all(isp); - /* FALL THROUGH */ - case ASYNC_LIP_OCCURRED: - case ASYNC_LOOP_UP: - case ASYNC_LOOP_DOWN: - case ASYNC_LOOP_RESET: - case ASYNC_CHANGE_NOTIFY: - if (count > 9) { - PRINTF("%s: too many retries to get going- " - "giving up\n", isp->isp_name); - return; + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + PRINTF("%s: INIT FIRMWARE failed (code 0x%x)\n", + isp->isp_name, mbs.param[0]); + if (mbs.param[0] & 0x8000) { + SYS_DELAY(1000); + continue; } - break; - default: - isp_dumpregs(isp, "INIT FIRMWARE failed"); return; } + break; } + isp->isp_reqidx = isp->isp_reqodx = 0; isp->isp_residx = 0; isp->isp_sendmarker = 1; @@ -993,15 +1083,6 @@ isp_fibre_init(isp) * Whatever happens, we're now committed to being here. */ isp->isp_state = ISP_INITSTATE; - fcp->isp_fwstate = FW_CONFIG_WAIT; - - isp_mark_getpdb_all(isp); - -#ifdef ISP_TARGET_MODE - if (isp_modify_lun(isp, 0, 1, 1)) { - PRINTF("%s: failed to enable target mode\n", isp->isp_name); - } -#endif } /* @@ -1015,10 +1096,10 @@ static void isp_mark_getpdb_all(isp) struct ispsoftc *isp; { - isp_pdb_t *p; fcparam *fcp = (fcparam *) isp->isp_param; - for (p = &fcp->isp_pdb[0]; p < &fcp->isp_pdb[MAX_FC_TARG]; p++) { - p->pdb_options = INVALID_PDB_OPTIONS; + int i; + for (i = 0; i < MAX_FC_TARG; i++) { + fcp->portdb[i].valid = 0; } } @@ -1030,10 +1111,11 @@ isp_getpdb(isp, id, pdbp) { fcparam *fcp = (fcparam *) isp->isp_param; mbreg_t mbs; + mbs.param[0] = MBOX_GET_PORT_DB; mbs.param[1] = id << 8; - mbs.param[2] = (u_int16_t) (fcp->isp_scdma >> 16); - mbs.param[3] = (u_int16_t) (fcp->isp_scdma & 0xffff); + mbs.param[2] = DMA_MSW(fcp->isp_scdma); + mbs.param[3] = DMA_LSW(fcp->isp_scdma); /* * Unneeded. For the 2100, except for initializing f/w, registers * 4/5 have to not be written to. @@ -1047,15 +1129,15 @@ isp_getpdb(isp, id, pdbp) switch (mbs.param[0]) { case MBOX_COMMAND_COMPLETE: MemoryBarrier(); - MEMCPY(pdbp, fcp->isp_scratch, sizeof (isp_pdb_t)); + ISP_UNSWIZZLE_AND_COPY_PDBP(isp, pdbp, fcp->isp_scratch); break; case MBOX_HOST_INTERFACE_ERROR: PRINTF("%s: DMA error getting port database\n", isp->isp_name); return (-1); case MBOX_COMMAND_PARAM_ERROR: /* Not Logged In */ - IDPRINTF(3, ("%s: Comand Param Error on Get Port Database\n", - isp->isp_name)); + IDPRINTF(3, ("%s: Param Error on Get Port Database for id %d\n", + isp->isp_name, id)); return (-1); default: PRINTF("%s: error 0x%x getting port database for ID %d\n", @@ -1065,6 +1147,34 @@ isp_getpdb(isp, id, pdbp) return (0); } +static u_int64_t +isp_get_portname(isp, loopid, nodename) + struct ispsoftc *isp; + int loopid; + int nodename; +{ + u_int64_t wwn = 0; + mbreg_t mbs; + + mbs.param[0] = MBOX_GET_PORT_NAME; + mbs.param[1] = loopid << 8; + if (nodename) + mbs.param[1] |= 1; + isp_mboxcmd(isp, &mbs); + if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { + wwn = + (((u_int64_t)(mbs.param[2] & 0xff)) << 56) | + (((u_int64_t)(mbs.param[2] >> 8)) << 48) | + (((u_int64_t)(mbs.param[3] & 0xff)) << 40) | + (((u_int64_t)(mbs.param[3] >> 8)) << 32) | + (((u_int64_t)(mbs.param[6] & 0xff)) << 24) | + (((u_int64_t)(mbs.param[6] >> 8)) << 16) | + (((u_int64_t)(mbs.param[7] & 0xff)) << 8) | + (((u_int64_t)(mbs.param[7] >> 8))); + } + return (wwn); +} + /* * Make sure we have good FC link and know our Loop ID. */ @@ -1074,11 +1184,20 @@ isp_fclink_test(isp, waitdelay) struct ispsoftc *isp; int waitdelay; { + static char *toponames[] = { + "Private Loop", + "FL Port", + "N-Port to N-Port", + "F Port" + }; + char *tname; mbreg_t mbs; - int count; + int count, topo = -1; u_int8_t lwfs; fcparam *fcp; - +#if defined(ISP2100_FABRIC) + isp_pdb_t pdb; +#endif fcp = isp->isp_param; /* @@ -1116,14 +1235,544 @@ isp_fclink_test(isp, waitdelay) return (-1); } fcp->isp_loopid = mbs.param[1]; + if (isp->isp_type == ISP_HA_FC_2200) { + if (ISP_FW_REVX(isp->isp_fwrev) >= ISP_FW_REV(2, 0, 14)) { + topo = (int) mbs.param[6]; + } + } else if (isp->isp_type == ISP_HA_FC_2100) { + if (ISP_FW_REVX(isp->isp_fwrev) >= ISP_FW_REV(1, 17, 26)) { + topo = (int) mbs.param[6]; + } + } + if (topo < 0 || topo > 3) + tname = "unknown"; + else + tname = toponames[topo]; + + /* + * If we're not on a fabric, the low 8 bits will be our AL_PA. + * If we're on a fabric, the low 8 bits will still be our AL_PA. + */ fcp->isp_alpa = mbs.param[2]; - PRINTF("%s: Loop ID %d, ALPA 0x%x\n", isp->isp_name, - fcp->isp_loopid, fcp->isp_alpa); +#if defined(ISP2100_FABRIC) + fcp->isp_onfabric = 0; + if (isp_getpdb(isp, FL_PORT_ID, &pdb) == 0) { + fcp->isp_portid = mbs.param[2] | (((int)mbs.param[3]) << 16); + fcp->isp_onfabric = 1; + CFGPRINTF("%s: Loop ID %d, AL_PA 0x%x, Port ID 0x%x Loop State " + "0x%x topology %s\n", isp->isp_name, fcp->isp_loopid, + fcp->isp_alpa, fcp->isp_portid, fcp->isp_loopstate, tname); + + /* + * Make sure we're logged out of all fabric devices. + */ + for (count = FC_SNS_ID+1; count < MAX_FC_TARG; count++) { + struct lportdb *lp = &fcp->portdb[count]; + if (lp->valid == 0 || lp->fabdev == 0) + continue; + PRINTF("%s: logging out target %d at Loop ID %d " + "(port id 0x%x)\n", isp->isp_name, count, + lp->loopid, lp->portid); + mbs.param[0] = MBOX_FABRIC_LOGOUT; + mbs.param[1] = lp->loopid << 8; + mbs.param[2] = 0; + mbs.param[3] = 0; + isp_mboxcmd(isp, &mbs); + } + } else +#endif + CFGPRINTF("%s: Loop ID %d, ALPA 0x%x Loop State 0x%x topology %s\n", + isp->isp_name, fcp->isp_loopid, fcp->isp_alpa, fcp->isp_loopstate, + tname); + fcp->loop_seen_once = 1; return (0); +} + +/* + * Compare two local port db entities and return 1 if they're the same, else 0. + */ + +static int +isp_same_lportdb(a, b) + struct lportdb *a, *b; +{ + /* + * We decide two lports are the same if they have non-zero and + * identical port WWNs and identical loop IDs. + */ + if (a->port_wwn == 0 || a->port_wwn != b->port_wwn || + a->loopid != b->loopid) { + return (0); + } else { + return (1); + } } /* + * Synchronize our soft copy of the port database with what the f/w thinks + * (with a view toward possibly for a specific target....) + */ + +static int +isp_pdb_sync(isp, target) + struct ispsoftc *isp; + int target; +{ + struct lportdb *lp, *tport; + fcparam *fcp = isp->isp_param; + isp_pdb_t pdb; + int loopid, lim; + +#ifdef ISP2100_FABRIC + /* + * XXX: If we do this *after* building up our local port database, + * XXX: the commands simply don't work. + */ + /* + * (Re)discover all fabric devices + */ + if (fcp->isp_onfabric) + (void) isp_scan_fabric(isp); +#endif + + + /* + * Run through the local loop ports and get port database info + * for each loop ID. + * + * There's a somewhat unexplained situation where the f/w passes back + * the wrong database entity- if that happens, just restart (up to + * FL_PORT_ID times). + */ + tport = fcp->tport; + /* + * make sure the temp port database is clean... + */ + MEMZERO((void *) tport, sizeof (tport)); + for (lim = loopid = 0; loopid < FL_PORT_ID; loopid++) { + lp = &tport[loopid]; + lp->node_wwn = isp_get_portname(isp, loopid, 1); + if (lp->node_wwn == 0) + continue; + lp->port_wwn = isp_get_portname(isp, loopid, 0); + if (lp->port_wwn == 0) { + lp->node_wwn = 0; + continue; + } + + /* + * Get an entry.... + */ + if (isp_getpdb(isp, loopid, &pdb) != 0) { + continue; + } + + /* + * If the returned database element doesn't match what we + * asked for, restart the process entirely (up to a point...). + */ + if (pdb.pdb_loopid != loopid) { + IDPRINTF(1, ("%s: wankage (%d != %d)\n", + isp->isp_name, pdb.pdb_loopid, loopid)); + loopid = 0; + if (lim++ < FL_PORT_ID) { + continue; + } + PRINTF("%s: giving up on synchronizing the port " + "database\n", isp->isp_name); + return (-1); + } + + /* + * Save the pertinent info locally. + */ + lp->node_wwn = + (((u_int64_t)pdb.pdb_nodename[0]) << 56) | + (((u_int64_t)pdb.pdb_nodename[1]) << 48) | + (((u_int64_t)pdb.pdb_nodename[2]) << 40) | + (((u_int64_t)pdb.pdb_nodename[3]) << 32) | + (((u_int64_t)pdb.pdb_nodename[4]) << 24) | + (((u_int64_t)pdb.pdb_nodename[5]) << 16) | + (((u_int64_t)pdb.pdb_nodename[6]) << 8) | + (((u_int64_t)pdb.pdb_nodename[7])); + lp->port_wwn = + (((u_int64_t)pdb.pdb_portname[0]) << 56) | + (((u_int64_t)pdb.pdb_portname[1]) << 48) | + (((u_int64_t)pdb.pdb_portname[2]) << 40) | + (((u_int64_t)pdb.pdb_portname[3]) << 32) | + (((u_int64_t)pdb.pdb_portname[4]) << 24) | + (((u_int64_t)pdb.pdb_portname[5]) << 16) | + (((u_int64_t)pdb.pdb_portname[6]) << 8) | + (((u_int64_t)pdb.pdb_portname[7])); + lp->roles = + (pdb.pdb_prli_svc3 & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT; + lp->portid = BITS2WORD(pdb.pdb_portid_bits); + lp->loopid = pdb.pdb_loopid; + /* + * Do a quick check to see whether this matches the saved port + * database for the same loopid. We do this here to save + * searching later (if possible). Note that this fails over + * time as things shuffle on the loop- we get the current + * loop state (where loop id as an index matches loop id in + * use) and then compare it to our saved database which + * never shifts. + */ + if (isp_same_lportdb(lp, &fcp->portdb[target])) { + lp->valid = 1; + } + } + + /* + * If we get this far, we've settled our differences with the f/w + * and we can say that the loop state is ready. + */ + fcp->isp_loopstate = LOOP_READY; + + /* + * Mark all of the permanent local loop database entries as invalid. + */ + for (loopid = 0; loopid < FL_PORT_ID; loopid++) { + fcp->portdb[loopid].valid = 0; + } + + /* + * Now merge our local copy of the port database into our saved copy. + * Notify the outer layers of new devices arriving. + */ + for (loopid = 0; loopid < FL_PORT_ID; loopid++) { + int i; + + /* + * If we don't have a non-zero Port WWN, we're not here. + */ + if (tport[loopid].port_wwn == 0) { + continue; + } + + /* + * If we've already marked our tmp copy as valid, + * this means that we've decided that it's the + * same as our saved data base. This didn't include + * the 'valid' marking so we have set that here. + */ + if (tport[loopid].valid) { + fcp->portdb[loopid].valid = 1; + continue; + } + + /* + * For the purposes of deciding whether this is the + * 'same' device or not, we only search for an identical + * Port WWN. Node WWNs may or may not be the same as + * the Port WWN, and there may be multiple different + * Port WWNs with the same Node WWN. It would be chaos + * to have multiple identical Port WWNs, so we don't + * allow that. + */ + + for (i = 0; i < FL_PORT_ID; i++) { + int j; + if (fcp->portdb[i].port_wwn == 0) + continue; + if (fcp->portdb[i].port_wwn != tport[loopid].port_wwn) + continue; + /* + * We found this WWN elsewhere- it's changed + * loopids then. We don't change it's actual + * position in our cached port database- we + * just change the actual loop ID we'd use. + */ + if (fcp->portdb[i].loopid != loopid) { + PRINTF("%s: Target ID %d Loop 0x%x (Port 0x%x) " + "=> Loop 0x%x (Port 0x%x) \n", + isp->isp_name, i, fcp->portdb[i].loopid, + fcp->portdb[i].portid, loopid, + tport[loopid].portid); + } + fcp->portdb[i].portid = tport[loopid].portid; + fcp->portdb[i].loopid = loopid; + fcp->portdb[i].valid = 1; + /* + * XXX: Should we also propagate roles in case they + * XXX: changed? + */ + + /* + * Now make sure this Port WWN doesn't exist elsewhere + * in the port database. + */ + for (j = i+1; j < FL_PORT_ID; j++) { + if (fcp->portdb[i].port_wwn != + fcp->portdb[j].port_wwn) { + continue; + } + PRINTF("%s: Target ID %d Duplicates Target ID " + "%d- killing off both\n", + isp->isp_name, j, i); + /* + * Invalidate the 'old' *and* 'new' ones. + * This is really harsh and not quite right, + * but if this happens, we really don't know + * who is what at this point. + */ + fcp->portdb[i].valid = 0; + fcp->portdb[j].valid = 0; + } + break; + } + + /* + * If we didn't traverse the entire port database, + * then we found (and remapped) an existing entry. + * No need to notify anyone- go for the next one. + */ + if (i < FL_PORT_ID) { + continue; + } + + /* + * We've not found this Port WWN anywhere. It's a new entry. + * See if we can leave it where it is (with target == loopid). + */ + if (fcp->portdb[loopid].port_wwn != 0) { + for (lim = 0; lim < FL_PORT_ID; lim++) { + if (fcp->portdb[lim].port_wwn == 0) + break; + } + /* "Cannot Happen" */ + if (lim == FL_PORT_ID) { + PRINTF("%s: remap overflow?\n", isp->isp_name); + continue; + } + i = lim; + } else { + i = loopid; + } + + /* + * NB: The actual loopid we use here is loopid- we may + * in fact be at a completely different index (target). + */ + fcp->portdb[i].loopid = loopid; + fcp->portdb[i].port_wwn = tport[loopid].port_wwn; + fcp->portdb[i].node_wwn = tport[loopid].node_wwn; + fcp->portdb[i].roles = tport[loopid].roles; + fcp->portdb[i].portid = tport[loopid].portid; + fcp->portdb[i].valid = 1; + + /* + * Tell the outside world we've arrived. + */ + (void) isp_async(isp, ISPASYNC_PDB_CHANGED, &i); + } + + /* + * Now find all previously used targets that are now invalid and + * notify the outer layers that they're gone. + */ + for (lp = fcp->portdb; lp < &fcp->portdb[FL_PORT_ID]; lp++) { + if (lp->valid || lp->port_wwn == 0) + continue; + + /* + * Tell the outside world we've gone away. + */ + loopid = lp - fcp->portdb; + (void) isp_async(isp, ISPASYNC_PDB_CHANGED, &loopid); + MEMZERO((void *) lp, sizeof (*lp)); + } + +#ifdef ISP2100_FABRIC + /* + * Now log in any fabric devices + */ + for (lp = &fcp->portdb[FC_SNS_ID+1]; + lp < &fcp->portdb[MAX_FC_TARG]; lp++) { + mbreg_t mbs; + + /* + * Nothing here? + */ + if (lp->port_wwn == 0) + continue; + /* + * Don't try to log into yourself. + */ + if (lp->portid == fcp->isp_portid) + continue; + + /* + * Force a logout. + */ + lp->loopid = loopid = lp - fcp->portdb; + mbs.param[0] = MBOX_FABRIC_LOGOUT; + mbs.param[1] = lp->loopid << 8; + mbs.param[2] = 0; + mbs.param[3] = 0; + isp_mboxcmd(isp, &mbs); + + /* + * And log in.... + */ + mbs.param[0] = MBOX_FABRIC_LOGIN; + mbs.param[1] = lp->loopid << 8; + mbs.param[2] = lp->portid >> 16; + mbs.param[3] = lp->portid & 0xffff; + isp_mboxcmd(isp, &mbs); + switch (mbs.param[0]) { + case MBOX_COMMAND_COMPLETE: + break; + case MBOX_COMMAND_ERROR: + switch (mbs.param[1]) { + case 1: + PRINTF("%s: no loop\n", isp->isp_name); + break; + case 2: + PRINTF("%s: IOCB buffer could not be alloced\n", + isp->isp_name); + break; + case 3: + PRINTF("%s: could not alloc xchange resource\n", + isp->isp_name); + break; + case 4: + PRINTF("%s: ELS timeout\n", isp->isp_name); + break; + case 5: + PRINTF("%s: no fabric port\n", isp->isp_name); + break; + case 6: + PRINTF("%s: remote device cannot be a target\n", + isp->isp_name); + break; + default: + break; + } + continue; + default: + continue; + } + + lp->valid = 1; + lp->fabdev = 1; + if (isp_getpdb(isp, loopid, &pdb) != 0) { + /* + * Be kind... + */ + lp->roles = (SVC3_TGT_ROLE >> SVC3_ROLE_SHIFT); + PRINTF("%s: Faked PortID 0x%x into LoopID %d\n", + isp->isp_name, lp->portid, lp->loopid); + continue; + } + if (pdb.pdb_loopid != lp->loopid) { + lp->roles = (SVC3_TGT_ROLE >> SVC3_ROLE_SHIFT); + PRINTF("%s: Wanked PortID 0x%x to LoopID %d\n", + isp->isp_name, lp->portid, lp->loopid); + continue; + } + lp->roles = + (pdb.pdb_prli_svc3 & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT; + lp->portid = BITS2WORD(pdb.pdb_portid_bits); + lp->loopid = loopid; + lp->node_wwn = + (((u_int64_t)pdb.pdb_nodename[0]) << 56) | + (((u_int64_t)pdb.pdb_nodename[1]) << 48) | + (((u_int64_t)pdb.pdb_nodename[2]) << 40) | + (((u_int64_t)pdb.pdb_nodename[3]) << 32) | + (((u_int64_t)pdb.pdb_nodename[4]) << 24) | + (((u_int64_t)pdb.pdb_nodename[5]) << 16) | + (((u_int64_t)pdb.pdb_nodename[6]) << 8) | + (((u_int64_t)pdb.pdb_nodename[7])); + lp->port_wwn = + (((u_int64_t)pdb.pdb_portname[0]) << 56) | + (((u_int64_t)pdb.pdb_portname[1]) << 48) | + (((u_int64_t)pdb.pdb_portname[2]) << 40) | + (((u_int64_t)pdb.pdb_portname[3]) << 32) | + (((u_int64_t)pdb.pdb_portname[4]) << 24) | + (((u_int64_t)pdb.pdb_portname[5]) << 16) | + (((u_int64_t)pdb.pdb_portname[6]) << 8) | + (((u_int64_t)pdb.pdb_portname[7])); + /* + * Check to make sure this all makes sense. + */ + if (lp->node_wwn && lp->port_wwn) { + (void) isp_async(isp, ISPASYNC_PDB_CHANGED, &loopid); + continue; + } + lp->fabdev = lp->valid = 0; + PRINTF("%s: Target %d (Loop 0x%x) Port ID 0x%x lost its WWN\n", + isp->isp_name, loopid, lp->loopid, lp->portid); + mbs.param[0] = MBOX_FABRIC_LOGOUT; + mbs.param[1] = lp->loopid << 8; + mbs.param[2] = 0; + mbs.param[3] = 0; + isp_mboxcmd(isp, &mbs); + } +#endif + return (0); +} + +#ifdef ISP2100_FABRIC +static int +isp_scan_fabric(isp) + struct ispsoftc *isp; +{ + fcparam *fcp = isp->isp_param; + u_int32_t portid, first_nz_portid; + sns_screq_t *reqp; + sns_scrsp_t *resp; + mbreg_t mbs; + int hicap; + + reqp = (sns_screq_t *) fcp->isp_scratch; + resp = (sns_scrsp_t *) (&((char *)fcp->isp_scratch)[0x100]); + first_nz_portid = portid = fcp->isp_portid; + + for (hicap = 0; hicap < 1024; hicap++) { + MEMZERO((void *) reqp, SNS_GAN_REQ_SIZE); + reqp->snscb_rblen = SNS_GAN_RESP_SIZE >> 1; + reqp->snscb_addr[RQRSP_ADDR0015] = + DMA_LSW(fcp->isp_scdma + 0x100); + reqp->snscb_addr[RQRSP_ADDR1631] = + DMA_MSW(fcp->isp_scdma + 0x100); + reqp->snscb_sblen = 6; + reqp->snscb_data[0] = SNS_GAN; + reqp->snscb_data[4] = portid & 0xffff; + reqp->snscb_data[5] = (portid >> 16) & 0xff; + ISP_SWIZZLE_SNS_REQ(isp, reqp); + mbs.param[0] = MBOX_SEND_SNS; + mbs.param[1] = SNS_GAN_REQ_SIZE >> 1; + mbs.param[2] = DMA_MSW(fcp->isp_scdma); + mbs.param[3] = DMA_LSW(fcp->isp_scdma); + mbs.param[6] = 0; + mbs.param[7] = 0; + MemoryBarrier(); + isp_mboxcmd(isp, &mbs); + if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + return (-1); + } + ISP_UNSWIZZLE_SNS_RSP(isp, resp, SNS_GAN_RESP_SIZE >> 1); + portid = (((u_int32_t) resp->snscb_port_id[0]) << 16) | + (((u_int32_t) resp->snscb_port_id[1]) << 8) | + (((u_int32_t) resp->snscb_port_id[2])); + if (isp_async(isp, ISPASYNC_FABRIC_DEV, resp)) { + return (-1); + } + if (first_nz_portid == 0 && portid) { + first_nz_portid = portid; + } + if (first_nz_portid == portid) { + return (0); + } + } + /* + * We either have a broken name server or a huge fabric if we get here. + */ + return (0); +} +#endif +/* * Start a command. Locking is assumed done in the caller. */ @@ -1132,7 +1781,7 @@ ispscsicmd(xs) ISP_SCSI_XFER_T *xs; { struct ispsoftc *isp; - u_int8_t iptr, optr; + u_int16_t iptr, optr; union { ispreq_t *_reqp; ispreqt2_t *_t2reqp; @@ -1140,7 +1789,7 @@ ispscsicmd(xs) #define reqp _u._reqp #define t2reqp _u._t2reqp #define UZSIZE max(sizeof (ispreq_t), sizeof (ispreqt2_t)) - int i, rqidx; + int target, i; XS_INITERR(xs); isp = XS_ISP(xs); @@ -1156,9 +1805,9 @@ ispscsicmd(xs) * to the whole Queue Entry for the command... */ - if (XS_CDBLEN(xs) > ((isp->isp_type & ISP_HA_FC)? 16 : 12)) { - PRINTF("%s: unsupported cdb length (%d)\n", - isp->isp_name, XS_CDBLEN(xs)); + if (XS_CDBLEN(xs) > (IS_FC(isp) ? 16 : 12) || XS_CDBLEN(xs) == 0) { + PRINTF("%s: unsupported cdb length (%d, CDB[0]=0x%x)\n", + isp->isp_name, XS_CDBLEN(xs), XS_CDBP(xs)[0]); XS_SETERR(xs, HBA_BOTCH); return (CMD_COMPLETE); } @@ -1167,104 +1816,146 @@ ispscsicmd(xs) * Check to see whether we have good firmware state still or * need to refresh our port database for this target. */ + target = XS_TGT(xs); if (IS_FC(isp)) { fcparam *fcp = isp->isp_param; - isp_pdb_t *pdbp = &fcp->isp_pdb[XS_TGT(xs)]; - + struct lportdb *lp; +#if defined(ISP2100_FABRIC) + if (target >= FL_PORT_ID) { + /* + * If we're not on a Fabric, we can't have a target + * above FL_PORT_ID-1. If we're on a fabric, we + * can't have a target less than FC_SNS_ID+1. + */ + if (fcp->isp_onfabric == 0 || target <= FC_SNS_ID) { + XS_SETERR(xs, HBA_SELTIMEOUT); + return (CMD_COMPLETE); + } + } +#endif /* - * Check for f/w being in ready state. Well, okay, - * our cached copy of it... + * Check for f/w being in ready state. If the f/w + * isn't in ready state, then we don't know our + * loop ID and the f/w hasn't completed logging + * into all targets on the loop. If this is the + * case, then bounce the command. We pretend this is + * a SELECTION TIMEOUT error if we've never gone to + * FW_READY state at all- in this case we may not + * be hooked to a loop at all and we shouldn't hang + * the machine for this. Otherwise, defer this command + * until later. */ if (fcp->isp_fwstate != FW_READY) { if (isp_fclink_test(isp, FC_FW_READY_DELAY)) { XS_SETERR(xs, HBA_SELTIMEOUT); - return (CMD_COMPLETE); + if (fcp->loop_seen_once) { + return (CMD_RQLATER); + } else { + return (CMD_COMPLETE); + } } } + + /* + * If our loop state is such that we haven't yet received + * a "Port Database Changed" notification (after a LIP or + * a Loop Reset or firmware initialization), then defer + * sending commands for a little while. + */ + if (fcp->isp_loopstate < LOOP_PDB_RCVD) { + XS_SETERR(xs, HBA_SELTIMEOUT); + return (CMD_RQLATER); + } + /* - * Refresh our port database if needed. + * If our loop state is now such that we've just now + * received a Port Database Change notification, then + * we have to go off and (re)synchronize our port + * database. */ - if (pdbp->pdb_options == INVALID_PDB_OPTIONS) { - if (isp_getpdb(isp, XS_TGT(xs), pdbp) == 0) { - isp_async(isp, ISPASYNC_PDB_CHANGE_COMPLETE, - (void *) (long) XS_TGT(xs)); + if (fcp->isp_loopstate == LOOP_PDB_RCVD) { + if (isp_pdb_sync(isp, target)) { + XS_SETERR(xs, HBA_SELTIMEOUT); + return (CMD_COMPLETE); } } + + /* + * Now check whether we should even think about pursuing this. + */ + lp = &fcp->portdb[target]; + if (lp->valid == 0) { + XS_SETERR(xs, HBA_SELTIMEOUT); + return (CMD_COMPLETE); + } + if ((lp->roles & (SVC3_TGT_ROLE >> SVC3_ROLE_SHIFT)) == 0) { + IDPRINTF(3, ("%s: target %d is not a target\n", + isp->isp_name, target)); + XS_SETERR(xs, HBA_SELTIMEOUT); + return (CMD_COMPLETE); + } + /* + * Now turn target into what the actual loop ID is. + */ + target = lp->loopid; } /* * Next check to see if any HBA or Device * parameters need to be updated. */ - if (isp->isp_update) { + if (isp->isp_update != 0) { isp_update(isp); } - optr = isp->isp_reqodx = ISP_READ(isp, OUTMAILBOX4); - iptr = isp->isp_reqidx; - - reqp = (ispreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, iptr); - iptr = ISP_NXT_QENTRY(iptr, RQUEST_QUEUE_LEN); - if (iptr == optr) { - IDPRINTF(2, ("%s: Request Queue Overflow\n", isp->isp_name)); + if (isp_getrqentry(isp, &iptr, &optr, (void **) &reqp)) { + IDPRINTF(1, ("%s: Request Queue Overflow\n", isp->isp_name)); XS_SETERR(xs, HBA_BOTCH); return (CMD_EAGAIN); } + /* + * Now see if we need to synchronize the ISP with respect to anything. + * We do dual duty here (cough) for synchronizing for busses other + * than which we got here to send a command to. + */ if (isp->isp_sendmarker) { - u_int8_t niptr; - ispmarkreq_t *marker = (ispmarkreq_t *) reqp; - - MEMZERO((void *) marker, sizeof (*marker)); - marker->req_header.rqs_entry_count = 1; - marker->req_header.rqs_entry_type = RQSTYPE_MARKER; - marker->req_modifier = SYNC_ALL; - + u_int8_t n = (IS_12X0(isp)? 2: 1); /* - * Unconditionally update the input pointer anyway. + * Check ports to send markers for... */ - ISP_WRITE(isp, INMAILBOX4, iptr); - isp->isp_reqidx = iptr; - - niptr = ISP_NXT_QENTRY(iptr, RQUEST_QUEUE_LEN); - if (niptr == optr) { - IDPRINTF(2, ("%s: Request Queue Overflow+\n", - isp->isp_name)); - XS_SETERR(xs, HBA_BOTCH); - return (CMD_EAGAIN); + for (i = 0; i < n; i++) { + if ((isp->isp_sendmarker & (1 << i)) == 0) { + continue; + } + MEMZERO((void *) reqp, sizeof (*reqp)); + reqp->req_header.rqs_entry_count = 1; + reqp->req_header.rqs_entry_type = RQSTYPE_MARKER; + reqp->req_modifier = SYNC_ALL; + reqp->req_target = i << 7; /* insert bus number */ + ISP_SWIZZLE_REQUEST(isp, reqp); + MemoryBarrier(); + ISP_ADD_REQUEST(isp, iptr); + + if (isp_getrqentry(isp, &iptr, &optr, (void **)&reqp)) { + IDPRINTF(1, ("%s: Request Queue Overflow+\n", + isp->isp_name)); + XS_SETERR(xs, HBA_BOTCH); + return (CMD_EAGAIN); + } } - reqp = (ispreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, iptr); - iptr = niptr; } MEMZERO((void *) reqp, UZSIZE); reqp->req_header.rqs_entry_count = 1; - if (isp->isp_type & ISP_HA_FC) { + if (IS_FC(isp)) { reqp->req_header.rqs_entry_type = RQSTYPE_T2RQS; } else { reqp->req_header.rqs_entry_type = RQSTYPE_REQUEST; } reqp->req_header.rqs_flags = 0; - reqp->req_header.rqs_seqno = isp->isp_seqno++; - - for (rqidx = 0; rqidx < RQUEST_QUEUE_LEN; rqidx++) { - if (isp->isp_xflist[rqidx] == NULL) - break; - } - if (rqidx == RQUEST_QUEUE_LEN) { - IDPRINTF(2, ("%s: out of xflist pointers\n", isp->isp_name)); - XS_SETERR(xs, HBA_BOTCH); - return (CMD_EAGAIN); - } else { - /* - * Never have a handle that is zero, so - * set req_handle off by one. - */ - isp->isp_xflist[rqidx] = xs; - reqp->req_handle = rqidx+1; - } - - if (isp->isp_type & ISP_HA_FC) { + reqp->req_header.rqs_seqno = 0; + if (IS_FC(isp)) { /* * See comment in isp_intr */ @@ -1272,59 +1963,60 @@ ispscsicmd(xs) /* * Fibre Channel always requires some kind of tag. - * If we're marked as "Can't Tag", just do simple - * instead of ordered tags. It's pretty clear to me - * that we shouldn't do head of queue tagging in - * this case. + * The Qlogic drivers seem be happy not to use a tag, + * but this breaks for some devices (IBM drives). */ if (XS_CANTAG(xs)) { t2reqp->req_flags = XS_KINDOF_TAG(xs); } else { - t2reqp->req_flags = REQFLAG_STAG; + if (XS_CDBP(xs)[0] == 0x3) /* REQUEST SENSE */ + t2reqp->req_flags = REQFLAG_HTAG; + else + t2reqp->req_flags = REQFLAG_OTAG; } } else { sdparam *sdp = (sdparam *)isp->isp_param; - if ((sdp->isp_devparam[XS_TGT(xs)].cur_dflags & DPARM_TQING) && + if ((sdp->isp_devparam[target].cur_dflags & DPARM_TQING) && XS_CANTAG(xs)) { reqp->req_flags = XS_KINDOF_TAG(xs); - } else { - reqp->req_flags = 0; } } - reqp->req_target = XS_TGT(xs); - if (isp->isp_type & ISP_HA_SCSI) { + reqp->req_target = target | (XS_CHANNEL(xs) << 7); + if (IS_SCSI(isp)) { reqp->req_lun_trn = XS_LUN(xs); reqp->req_cdblen = XS_CDBLEN(xs); } else { #ifdef ISP2100_SCCLUN - reqp->req_scclun = XS_LUN(xs); + t2reqp->req_scclun = XS_LUN(xs); #else - reqp->req_lun_trn = XS_LUN(xs); + t2reqp->req_lun_trn = XS_LUN(xs); #endif - } MEMCPY(reqp->req_cdb, XS_CDBP(xs), XS_CDBLEN(xs)); - IDPRINTF(5, ("%s(%d.%d): START%d cmd 0x%x datalen %d\n", isp->isp_name, - XS_TGT(xs), XS_LUN(xs), reqp->req_header.rqs_seqno, - reqp->req_cdb[0], XS_XFRLEN(xs))); - reqp->req_time = XS_TIME(xs) / 1000; if (reqp->req_time == 0 && XS_TIME(xs)) reqp->req_time = 1; /* * Always give a bit more leeway to commands after a bus reset. + * XXX: DOES NOT DISTINGUISH WHICH PORT MAY HAVE BEEN SYNCED */ - if (isp->isp_sendmarker && reqp->req_time < 5) + if (isp->isp_sendmarker && reqp->req_time < 5) { reqp->req_time = 5; - + } + if (isp_save_xs(isp, xs, &reqp->req_handle)) { + IDPRINTF(2, ("%s: out of xflist pointers\n", isp->isp_name)); + XS_SETERR(xs, HBA_BOTCH); + return (CMD_EAGAIN); + } + /* + * Set up DMA and/or do any bus swizzling of the request entry + * so that the Qlogic F/W understands what is being asked of it. + */ i = ISP_DMASETUP(isp, xs, reqp, &iptr, optr); if (i != CMD_QUEUED) { - /* - * Take memory of it away... - */ - isp->isp_xflist[rqidx] = NULL; + isp_destroy_handle(isp, reqp->req_handle); /* * dmasetup sets actual error in packet, and * return what we were given to return. @@ -1332,9 +2024,11 @@ ispscsicmd(xs) return (i); } XS_SETERR(xs, HBA_NOERROR); + IDPRINTF(5, ("%s(%d.%d.%d): START cmd 0x%x datalen %d\n", + isp->isp_name, XS_CHANNEL(xs), target, XS_LUN(xs), + reqp->req_cdb[0], XS_XFRLEN(xs))); MemoryBarrier(); - ISP_WRITE(isp, INMAILBOX4, iptr); - isp->isp_reqidx = iptr; + ISP_ADD_REQUEST(isp, iptr); isp->isp_nactive++; if (isp->isp_sendmarker) isp->isp_sendmarker = 0; @@ -1356,7 +2050,8 @@ isp_control(isp, ctl, arg) { ISP_SCSI_XFER_T *xs; mbreg_t mbs; - int i; + int bus, tgt; + u_int32_t handle; switch (ctl) { default: @@ -1366,74 +2061,73 @@ isp_control(isp, ctl, arg) case ISPCTL_RESET_BUS: /* - * This is really important to have set after a bus reset. - */ - isp->isp_sendmarker = 1; - - /* * Issue a bus reset. */ mbs.param[0] = MBOX_BUS_RESET; - if (isp->isp_type & ISP_HA_SCSI) { + if (IS_SCSI(isp)) { mbs.param[1] = ((sdparam *) isp->isp_param)->isp_bus_reset_delay; if (mbs.param[1] < 2) mbs.param[1] = 2; + bus = *((int *) arg); + mbs.param[2] = bus; } else { - /* - * Unparameterized. - */ - mbs.param[1] = 5; + mbs.param[1] = 10; + mbs.param[2] = 0; + bus = 0; } + isp->isp_sendmarker = 1 << bus; isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { isp_dumpregs(isp, "isp_control SCSI bus reset failed"); break; } - PRINTF("%s: driver initiated bus reset\n", isp->isp_name); + PRINTF("%s: driver initiated bus reset of bus %d\n", + isp->isp_name, bus); return (0); case ISPCTL_RESET_DEV: + tgt = (*((int *) arg)) & 0xffff; + bus = (*((int *) arg)) >> 16; mbs.param[0] = MBOX_ABORT_TARGET; - mbs.param[1] = ((long)arg) << 8; + mbs.param[1] = (tgt << 8) | (bus << 15); mbs.param[2] = 3; /* 'delay', in seconds */ isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_dumpregs(isp, "Target Reset Failed"); + PRINTF("%s: isp_control MBOX_RESET_DEV failure (code " + "%x)\n", isp->isp_name, mbs.param[0]); break; } - PRINTF("%s: Target %d Reset Succeeded\n", isp->isp_name, - (int) ((long) arg)); - isp->isp_sendmarker = 1; + PRINTF("%s: Target %d on Bus %d Reset Succeeded\n", + isp->isp_name, tgt, bus); + isp->isp_sendmarker = 1 << bus; return (0); case ISPCTL_ABORT_CMD: xs = (ISP_SCSI_XFER_T *) arg; - for (i = 0; i < RQUEST_QUEUE_LEN; i++) { - if (xs == isp->isp_xflist[i]) { - break; - } - } - if (i == RQUEST_QUEUE_LEN) { + handle = isp_find_handle(isp, xs); + if (handle == 0) { PRINTF("%s: isp_control- cannot find command to abort " "in active list\n", isp->isp_name); break; } + bus = XS_CHANNEL(xs); mbs.param[0] = MBOX_ABORT; + if (IS_FC(isp)) { #ifdef ISP2100_SCCLUN - if (isp->isp_type & ISP_HA_FC) { mbs.param[1] = XS_TGT(xs) << 8; mbs.param[4] = 0; mbs.param[5] = 0; mbs.param[6] = XS_LUN(xs); - } else { - mbs.param[1] = XS_TGT(xs) << 8 | XS_LUN(xs); - } #else - mbs.param[1] = XS_TGT(xs) << 8 | XS_LUN(xs); + mbs.param[1] = XS_TGT(xs) << 8 | XS_LUN(xs); #endif - mbs.param[2] = (i+1) >> 16; - mbs.param[3] = (i+1) & 0xffff; + } else { + mbs.param[1] = + (bus << 15) | (XS_TGT(xs) << 8) | XS_LUN(xs); + } + mbs.param[2] = handle >> 16; + mbs.param[3] = handle & 0xffff; isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { PRINTF("%s: isp_control MBOX_ABORT failure (code %x)\n", @@ -1450,6 +2144,13 @@ isp_control(isp, ctl, arg) case ISPCTL_FCLINK_TEST: return (isp_fclink_test(isp, FC_FW_READY_DELAY)); +#ifdef ISP_TARGET_MODE + case ISPCTL_ENABLE_LUN: + return (isp_modify_lun, 1, arg)); + + case ISPCTL_MODIFY_LUN: + return (isp_modify_lun, 0, arg)); +#endif } return (-1); } @@ -1467,73 +2168,70 @@ isp_intr(arg) { ISP_SCSI_XFER_T *complist[RESULT_QUEUE_LEN], *xs; struct ispsoftc *isp = arg; - u_int8_t iptr, optr; - u_int16_t isr; + u_int16_t iptr, optr; + u_int16_t isr, isrb, sema; int i, nlooked = 0, ndone = 0; - isr = ISP_READ(isp, BIU_ISR); - if (isp->isp_type & ISP_HA_FC) { - if (isr == 0 || (isr & BIU2100_ISR_RISC_INT) == 0) { - if (isr) { - IDPRINTF(4, ("%s: isp_intr isr=%x\n", - isp->isp_name, isr)); - } - return (0); - } - } else { - if (isr == 0 || (isr & BIU_ISR_RISC_INT) == 0) { - if (isr) { - IDPRINTF(4, ("%s: isp_intr isr=%x\n", - isp->isp_name, isr)); - } - return (0); - } + /* + * Well, if we've disabled interrupts, we may get a case where + * isr isn't set, but sema is. In any case, debounce isr reads. + */ + do { + isr = ISP_READ(isp, BIU_ISR); + isrb = ISP_READ(isp, BIU_ISR); + } while (isr != isrb); + sema = ISP_READ(isp, BIU_SEMA) & 0x1; + IDPRINTF(5, ("%s: isp_intr isr %x sem %x\n", isp->isp_name, isr, sema)); + if (isr == 0) { + return (0); + } + if (!INT_PENDING(isp, isr)) { + IDPRINTF(4, ("%s: isp_intr isr=%x\n", isp->isp_name, isr)); + return (0); + } + if (isp->isp_state != ISP_RUNSTATE) { + IDPRINTF(3, ("%s: interrupt (isr=%x,sema=%x) when not ready\n", + isp->isp_name, isr, sema)); + ISP_WRITE(isp, INMAILBOX5, ISP_READ(isp, OUTMAILBOX5)); + ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); + ISP_WRITE(isp, BIU_SEMA, 0); + ENABLE_INTS(isp); + return (1); } - if (ISP_READ(isp, BIU_SEMA) & 1) { + if (sema) { u_int16_t mbox = ISP_READ(isp, OUTMAILBOX0); if (mbox & 0x4000) { - IDPRINTF(3, ("%s: isp_intr sees 0x%x\n", + IDPRINTF(3, ("%s: Command Mbox 0x%x\n", isp->isp_name, mbox)); - ISP_WRITE(isp, BIU_SEMA, 0); } else { u_int32_t fhandle = isp_parse_async(isp, (int) mbox); - ISP_WRITE(isp, BIU_SEMA, 0); - if (fhandle < 0) { - return (1); - } else if (fhandle > 0) { - xs = (void *)isp->isp_xflist[fhandle - 1]; - isp->isp_xflist[fhandle - 1] = NULL; - /* - * Since we don't have a result queue entry - * item, we must believe that SCSI status is - * zero and that all data transferred. - */ - XS_RESID(xs) = 0; - XS_STS(xs) = 0; - if (XS_XFRLEN(xs)) { - ISP_DMAFREE(isp, xs, fhandle - 1); - } - if (isp->isp_nactive > 0) - isp->isp_nactive--; - complist[ndone++] = xs; + IDPRINTF(3, ("%s: Async Mbox 0x%x\n", + isp->isp_name, mbox)); + if (fhandle > 0) { + isp_fastpost_complete(isp, fhandle); } } + ISP_WRITE(isp, BIU_SEMA, 0); + ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); + ENABLE_INTS(isp); + return (1); } - ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); + /* + * You *must* read OUTMAILBOX5 prior to clearing the RISC interrupt. + */ optr = isp->isp_residx; iptr = ISP_READ(isp, OUTMAILBOX5); - + ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); if (optr == iptr) { IDPRINTF(4, ("why intr? isr %x iptr %x optr %x\n", isr, optr, iptr)); } - ENABLE_INTS(isp); while (optr != iptr) { ispstatusreq_t *sp; - u_int8_t oop; + u_int16_t oop; int buddaboom = 0; sp = (ispstatusreq_t *) ISP_QUEUE_ENTRY(isp->isp_result, optr); @@ -1541,6 +2239,11 @@ isp_intr(arg) optr = ISP_NXT_QENTRY(optr, RESULT_QUEUE_LEN); nlooked++; MemoryBarrier(); + /* + * Do any appropriate unswizzling of what the Qlogic f/w has + * written into memory so it makes sense to us. + */ + ISP_UNSWIZZLE_RESPONSE(isp, sp); if (sp->req_header.rqs_entry_type != RQSTYPE_RESPONSE) { if (isp_handle_other_response(isp, sp, &optr) == 0) { ISP_WRITE(isp, INMAILBOX5, optr); @@ -1548,31 +2251,35 @@ isp_intr(arg) } /* * It really has to be a bounced request just copied - * from the request queue to the response queue. + * from the request queue to the response queue. If + * not, something bad has happened. */ - if (sp->req_header.rqs_entry_type != RQSTYPE_REQUEST) { ISP_WRITE(isp, INMAILBOX5, optr); + PRINTF("%s: not RESPONSE in RESPONSE Queue " + "(type 0x%x) @ idx %d (next %d)\n", + isp->isp_name, + sp->req_header.rqs_entry_type, oop, optr); continue; } - PRINTF("%s: not RESPONSE in RESPONSE Queue " - "(type 0x%x) @ idx %d (next %d)\n", isp->isp_name, - sp->req_header.rqs_entry_type, oop, optr); buddaboom = 1; } if (sp->req_header.rqs_flags & 0xf) { +#define _RQS_OFLAGS \ + ~(RQSFLAG_CONTINUATION|RQSFLAG_FULL|RQSFLAG_BADHEADER|RQSFLAG_BADPACKET) if (sp->req_header.rqs_flags & RQSFLAG_CONTINUATION) { + IDPRINTF(3, ("%s: continuation segment\n", + isp->isp_name)); ISP_WRITE(isp, INMAILBOX5, optr); continue; } - PRINTF("%s: rqs_flags=%x", isp->isp_name, - sp->req_header.rqs_flags & 0xf); if (sp->req_header.rqs_flags & RQSFLAG_FULL) { - PRINTF("%s: internal queues full\n", - isp->isp_name); - /* XXXX: this command *could* get restarted */ - buddaboom++; + IDPRINTF(2, ("%s: internal queues full\n", + isp->isp_name)); + /* + * We'll synthesize a QUEUE FULL message below. + */ } if (sp->req_header.rqs_flags & RQSFLAG_BADHEADER) { PRINTF("%s: bad header\n", isp->isp_name); @@ -1583,30 +2290,35 @@ isp_intr(arg) isp->isp_name); buddaboom++; } + if (sp->req_header.rqs_flags & _RQS_OFLAGS) { + PRINTF("%s: unknown flags in response (0x%x)\n", + isp->isp_name, sp->req_header.rqs_flags); + buddaboom++; + } +#undef _RQS_OFLAGS } - if (sp->req_handle > RQUEST_QUEUE_LEN || sp->req_handle < 1) { + if (sp->req_handle > isp->isp_maxcmds || sp->req_handle < 1) { PRINTF("%s: bad request handle %d\n", isp->isp_name, - sp->req_handle); + sp->req_handle); ISP_WRITE(isp, INMAILBOX5, optr); continue; } - xs = (void *) isp->isp_xflist[sp->req_handle - 1]; + xs = isp_find_xs(isp, sp->req_handle); if (xs == NULL) { - PRINTF("%s: NULL xs in xflist (handle %x)\n", + PRINTF("%s: NULL xs in xflist (handle 0x%x)\n", isp->isp_name, sp->req_handle); - isp_dumpxflist(isp); ISP_WRITE(isp, INMAILBOX5, optr); continue; } - isp->isp_xflist[sp->req_handle - 1] = NULL; + isp_destroy_handle(isp, sp->req_handle); if (sp->req_status_flags & RQSTF_BUS_RESET) { - isp->isp_sendmarker = 1; + isp->isp_sendmarker |= (1 << XS_CHANNEL(xs)); } if (buddaboom) { XS_SETERR(xs, HBA_BOTCH); } XS_STS(xs) = sp->req_scsi_status & 0xff; - if (isp->isp_type & ISP_HA_SCSI) { + if (IS_SCSI(isp)) { if (sp->req_state_flags & RQSF_GOT_SENSE) { MEMCPY(XS_SNSP(xs), sp->req_sense_data, XS_SNSLEN(xs)); @@ -1619,8 +2331,9 @@ isp_intr(arg) */ if (sp->req_status_flags & RQSTF_NEGOTIATION) { sdparam *sdp = isp->isp_param; - isp->isp_update = 1; + sdp += XS_CHANNEL(xs); sdp->isp_devparam[XS_TGT(xs)].dev_refresh = 1; + isp->isp_update |= (1 << XS_CHANNEL(xs)); } } else { if (XS_STS(xs) == SCSI_CHECK) { @@ -1642,14 +2355,24 @@ isp_intr(arg) XS_SETERR(xs, HBA_NOERROR); } } + } else if (sp->req_header.rqs_entry_type == RQSTYPE_REQUEST) { + if (sp->req_header.rqs_flags & RQSFLAG_FULL) { + /* + * Force Queue Full status. + */ + XS_STS(xs) = SCSI_QFULL; + XS_SETERR(xs, HBA_NOERROR); + } else if (XS_NOERR(xs)) { + XS_SETERR(xs, HBA_BOTCH); + } } else { - PRINTF("%s: unknown return %x\n", isp->isp_name, - sp->req_header.rqs_entry_type); + PRINTF("%s: unhandled respose queue type 0x%x\n", + isp->isp_name, sp->req_header.rqs_entry_type); if (XS_NOERR(xs)) { XS_SETERR(xs, HBA_BOTCH); } } - if (isp->isp_type & ISP_HA_SCSI) { + if (IS_SCSI(isp)) { XS_RESID(xs) = sp->req_resid; } else if (sp->req_scsi_status & RQCS_RU) { XS_RESID(xs) = sp->req_resid; @@ -1657,7 +2380,7 @@ isp_intr(arg) XS_XFRLEN(xs), sp->req_resid)); } if (XS_XFRLEN(xs)) { - ISP_DMAFREE(isp, xs, sp->req_handle - 1); + ISP_DMAFREE(isp, xs, sp->req_handle); } /* * XXX: If we have a check condition, but no Sense Data, @@ -1674,10 +2397,9 @@ isp_intr(arg) } if ((isp->isp_dblev >= 5) || (isp->isp_dblev > 2 && !XS_NOERR(xs))) { - PRINTF("%s(%d.%d): FIN%d dl%d resid%d STS %x", + PRINTF("%s(%d.%d): FIN dl%d resid%d STS %x", isp->isp_name, XS_TGT(xs), XS_LUN(xs), - sp->req_header.rqs_seqno, XS_XFRLEN(xs), - XS_RESID(xs), XS_STS(xs)); + XS_XFRLEN(xs), XS_RESID(xs), XS_STS(xs)); if (sp->req_state_flags & RQSF_GOT_SENSE) { PRINTF(" Skey: %x", XS_SNSKEY(xs)); if (!(XS_IS_SNS_VALID(xs))) { @@ -1708,6 +2430,7 @@ isp_intr(arg) XS_CMD_DONE(xs); } } + ENABLE_INTS(isp); return (1); } @@ -1720,19 +2443,30 @@ isp_parse_async(isp, mbox) struct ispsoftc *isp; int mbox; { + int bus; u_int32_t fast_post_handle = 0; + /* + * It is not documented anywhere that bus is always in OUTMAILBOX6 + * for dual bus cards- and we don't have the h/w to prove it either, + * So we'll just assume...... + */ + if (IS_1080(isp) || IS_12X0(isp)) { + bus = ISP_READ(isp, OUTMAILBOX6); + } else { + bus = 0; + } + switch (mbox) { case MBOX_COMMAND_COMPLETE: /* sometimes these show up */ break; case ASYNC_BUS_RESET: - isp_async(isp, ISPASYNC_BUS_RESET, NULL); - isp->isp_sendmarker = 1; + isp->isp_sendmarker = (1 << bus); #ifdef ISP_TARGET_MODE - isp_notify_ack(isp, NULL); + isp_target_async(isp, bus, ASYNC_BUS_RESET); #endif + isp_async(isp, ISPASYNC_BUS_RESET, &bus); break; - case ASYNC_SYSTEM_ERROR: mbox = ISP_READ(isp, OUTMAILBOX1); PRINTF("%s: Internal FW Error @ RISC Addr 0x%x\n", @@ -1750,23 +2484,28 @@ isp_parse_async(isp, mbox) break; case ASYNC_QWAKEUP: - /* don't need to be chatty */ + /* + * We've just been notified that the Queue has woken up. + * We don't need to be chatty about this- just unlatch things + * and move on. + */ mbox = ISP_READ(isp, OUTMAILBOX4); break; case ASYNC_TIMEOUT_RESET: - PRINTF("%s: timeout initiated SCSI bus reset\n", isp->isp_name); - isp->isp_sendmarker = 1; + PRINTF("%s: timeout initiated SCSI bus reset of bus %d\n", + isp->isp_name, bus); + isp->isp_sendmarker = (1 << bus); #ifdef ISP_TARGET_MODE - isp_notify_ack(isp, NULL); + isp_target_async(isp, bus, ASYNC_TIMEOUT_RESET); #endif break; case ASYNC_DEVICE_RESET: - isp->isp_sendmarker = 1; - PRINTF("%s: device reset\n", isp->isp_name); + PRINTF("%s: device reset on bus %d\n", isp->isp_name, bus); + isp->isp_sendmarker = 1 << bus; #ifdef ISP_TARGET_MODE - isp_notify_ack(isp, NULL); + isp_target_async(isp, bus, ASYNC_DEVICE_RESET); #endif break; @@ -1820,7 +2559,8 @@ isp_parse_async(isp, mbox) /* * XXX: Set up to renegotiate again! */ - isp->isp_sendmarker = 1; + /* Can only be for a 1080... */ + isp->isp_sendmarker = (1 << bus); break; case ASYNC_CMD_CMPLT: @@ -1836,34 +2576,56 @@ isp_parse_async(isp, mbox) break; case ASYNC_LIP_OCCURRED: + ((fcparam *) isp->isp_param)->isp_lipseq = + ISP_READ(isp, OUTMAILBOX1); + ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT; + ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_LIP_RCVD; isp->isp_sendmarker = 1; - PRINTF("%s: LIP occurred\n", isp->isp_name); + isp_mark_getpdb_all(isp); + IDPRINTF(1, ("%s: LIP occurred\n", isp->isp_name)); break; case ASYNC_LOOP_UP: isp->isp_sendmarker = 1; + ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT; + ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_LIP_RCVD; + isp_mark_getpdb_all(isp); isp_async(isp, ISPASYNC_LOOP_UP, NULL); break; case ASYNC_LOOP_DOWN: + isp->isp_sendmarker = 1; + ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT; + ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_NIL; + isp_mark_getpdb_all(isp); isp_async(isp, ISPASYNC_LOOP_DOWN, NULL); break; case ASYNC_LOOP_RESET: - isp->isp_sendmarker = 1; + isp->isp_sendmarker = 1 << bus; + ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT; + ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_NIL; + isp_mark_getpdb_all(isp); PRINTF("%s: Loop RESET\n", isp->isp_name); #ifdef ISP_TARGET_MODE - isp_notify_ack(isp, NULL); + isp_target_async(isp, bus, ASYNC_LOOP_RESET); #endif break; case ASYNC_PDB_CHANGED: isp->isp_sendmarker = 1; + ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_PDB_RCVD; isp_mark_getpdb_all(isp); - PRINTF("%s: Port Database Changed\n", isp->isp_name); + IDPRINTF(2, ("%s: Port Database Changed\n", isp->isp_name)); break; case ASYNC_CHANGE_NOTIFY: + isp_mark_getpdb_all(isp); + /* + * Not correct, but it will force us to rescan the loop. + */ + ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_PDB_RCVD; + isp_async(isp, ISPASYNC_CHANGE_NOTIFY, NULL); break; default: @@ -1873,635 +2635,42 @@ isp_parse_async(isp, mbox) return (fast_post_handle); } +/* + * Handle other response entries. A pointer to the request queue output + * index is here in case we want to eat several entries at once, although + * this is not used currently. + */ + static int isp_handle_other_response(isp, sp, optrp) struct ispsoftc *isp; ispstatusreq_t *sp; - u_int8_t *optrp; + u_int16_t *optrp; { - u_int8_t iptr, optr; - int reqsize = 0; - void *ireqp = NULL; -#ifdef ISP_TARGET_MODE - union { - at_entry_t *atio; - at2_entry_t *at2io; - ct_entry_t *ctio; - ct2_entry_t *ct2io; - lun_entry_t *lunen; - in_entry_t *inot; - in_fcentry_t *inot_fc; - na_entry_t *nack; - na_fcentry_t *nack_fc; - void *voidp; -#define atio un.atio -#define at2io un.at2io -#define ctio un.ctio -#define ct2io un.ct2io -#define lunen un.lunen -#define inot un.inot -#define inot_fc un.inot_fc -#define nack un.nack -#define nack_fc un.nack_fc - } un; - - un.voidp = sp; -#endif - - switch (sp->req_header.rqs_entry_type) { - case RQSTYPE_REQUEST: - return (-1); -#ifdef ISP_TARGET_MODE - case RQSTYPE_NOTIFY_ACK: - { - static const char *f = - "%s: Notify Ack Status 0x%x Sequence Id 0x%x\n" - /* - * The ISP is acknowleding our ack of an Immediate Notify. - */ - if (isp->isp_type & ISP_HA_FC) { - PRINTF(f, isp->isp_name, - nack_fc->na-status, nack_fc->na_seqid); - } else { - PRINTF(f, isp->isp_name, - nack->na_status, nack->na_seqid); - } - break; - } - case RQSTYPE_NOTIFY: - { - u_int16_t seqid, status; - - /* - * Either the ISP received a SCSI message it cannot handle - * or some other out of band condition (e.g., Port Logout) - * or it is returning an Immediate Notify entry we sent. - */ - if (isp->isp_type & ISP_HA_FC) { - status = inot_fc->status; - seqid = inot_fc->in_seqid; - } else { - status = inot->status; - seqid = inot->seqid & 0xff; - } - PRINTF("%s: Immediate Notify Status 0x%x Sequence Id 0x%x\n", - isp->isp_name, status, seqid); - - switch (status) { - case IN_MSG_RECEIVED: - case IN_IDE_RECEIVED: - ptisp_got_msg(ptp, &inot); - break; - case IN_RSRC_UNAVAIL: - PRINTF("%s: Firmware out of ATIOs\n", isp->isp_name); - break; - case IN_ABORT_TASK: - PRINTF("%s: Abort Task iid %d rx_id 0x%x\n", - inot_fc->in_iid, seqid); - break; - case IN_PORT_LOGOUT: - PRINTF("%s: Port Logout for Initiator %d\n", - isp->isp_name, inot_fc->in_iid); - break; - default: - PRINTF("%s: bad status (0x%x) in Immediate Notify\n", - isp->isp_name, status); - break; - - } - isp_notify_ack(isp, un.voidp); - reqsize = 0; - break; - } + case RQSTYPE_ATIO: + case RQSTYPE_CTIO0: case RQSTYPE_ENABLE_LUN: case RQSTYPE_MODIFY_LUN: - if (lunen->req_status != 1) { - PRINTF("%s: ENABLE/MODIFY LUN returned status 0x%x\n", - isp->isp_name, lunen->req_status); - } - break; + case RQSTYPE_NOTIFY: + case RQSTYPE_NOTIFY_ACK: + case RQSTYPE_CTIO1: case RQSTYPE_ATIO2: - { - fcparam *fcp = isp->isp_param; - ispctiot2_t local, *ct2 = NULL; - ispatiot2_t *at2 = (ispatiot2_t *) sp; - int s, lun; - -#ifdef ISP2100_SCCLUN - lun = at2->req_scclun; -#else - lun = at2->req_lun; -#endif - PRINTF("%s: atio2 loopid %d for lun %d rxid 0x%x flags0x%x " - "tflags0x%x ecodes0x%x rqstatus0x%x\n", isp->isp_name, - at2->req_initiator, lun, at2->req_rxid, - at2->req_flags, at2->req_taskflags, at2->req_execodes, - at2->req_status); - - switch (at2->req_status & ~ATIO_SENSEVALID) { - case ATIO_PATH_INVALID: - PRINTF("%s: ATIO2 Path Invalid\n", isp->isp_name); - break; - case ATIO_NOCAP: - PRINTF("%s: ATIO2 No Cap\n", isp->isp_name); - break; - case ATIO_BDR_MSG: - PRINTF("%s: ATIO2 BDR Received\n", isp->isp_name); - break; - case ATIO_CDB_RECEIVED: - ct2 = &local; - break; - default: - PRINTF("%s: unknown req_status 0x%x\n", isp->isp_name, - at2->req_status); - break; - } - if (ct2 == NULL) { - /* - * Just do an ACCEPT on this fellow. - */ - at2->req_header.rqs_entry_type = RQSTYPE_ATIO2; - at2->req_header.rqs_flags = 0; - at2->req_flags = 1; - ireqp = at2; - reqsize = sizeof (*at2); - break; - } - PRINTF("%s: datalen %d cdb0=0x%x\n", isp->isp_name, - at2->req_datalen, at2->req_cdb[0]); - MEMZERO((void *) ct2, sizeof (*ct2)); - ct2->req_header.rqs_entry_type = RQSTYPE_CTIO2; - ct2->req_header.rqs_entry_count = 1; - ct2->req_header.rqs_flags = 0; - ct2->req_header.rqs_seqno = isp->isp_seqno++; - ct2->req_handle = (at2->req_initiator << 16) | lun; -#ifndef ISP2100_SCCLUN - ct2->req_lun = lun; -#endif - ct2->req_initiator = at2->req_initiator; - ct2->req_rxid = at2->req_rxid; - - ct2->req_flags = CTIO_SEND_STATUS; - switch (at2->req_cdb[0]) { - case 0x0: /* TUR */ - ct2->req_flags |= CTIO_NODATA | CTIO2_SMODE0; - ct2->req_m.mode0.req_scsi_status = CTIO2_STATUS_VALID; - break; - - case 0x3: /* REQUEST SENSE */ - case 0x12: /* INQUIRE */ - ct2->req_flags |= CTIO_SEND_DATA | CTIO2_SMODE0; - ct2->req_m.mode0.req_scsi_status = CTIO2_STATUS_VALID; - ct2->req_seg_count = 1; - if (at2->req_cdb[0] == 0x12) { - s = sizeof (tgtiqd); - MEMCPY(fcp->isp_scratch, tgtiqd, s); - } else { - s = at2->req_datalen; - MEMZERO(fcp->isp_scratch, s); - } - ct2->req_m.mode0.req_dataseg[0].ds_base = - fcp->isp_scdma; - ct2->req_m.mode0.req_dataseg[0].ds_count = s; - ct2->req_m.mode0.req_datalen = s; -#if 1 - if (at2->req_datalen < s) { - ct2->req_m.mode1.req_scsi_status |= - CTIO2_RESP_VALID|CTIO2_RSPOVERUN; - } else if (at2->req_datalen > s) { - ct2->req_m.mode1.req_scsi_status |= - CTIO2_RESP_VALID|CTIO2_RSPUNDERUN; - } -#endif - break; - - default: /* ALL OTHERS */ - ct2->req_flags |= CTIO_NODATA | CTIO2_SMODE1; - ct2->req_m.mode1.req_scsi_status = 0; -#if 1 - if (at2->req_datalen) { - ct2->req_m.mode1.req_scsi_status |= - CTIO2_RSPUNDERUN; -#if BYTE_ORDER == BIG_ENDIAN - ct2->req_resid[1] = at2->req_datalen & 0xff; - ct2->req_resid[0] = - (at2->req_datalen >> 8) & 0xff; - ct2->req_resid[3] = - (at2->req_datalen >> 16) & 0xff; - ct2->req_resid[2] = - (at2->req_datalen >> 24) & 0xff; -#else - ct2->req_resid[0] = at2->req_datalen & 0xff; - ct2->req_resid[1] = - (at2->req_datalen >> 8) & 0xff; - ct2->req_resid[2] = - (at2->req_datalen >> 16) & 0xff; - ct2->req_resid[3] = - (at2->req_datalen >> 24) & 0xff; -#endif - } -#endif - if ((at2->req_status & ATIO_SENSEVALID) == 0) { - ct2->req_m.mode1.req_sense_len = 18; - ct2->req_m.mode1.req_scsi_status |= 2; - ct2->req_m.mode1.req_response[0] = 0x70; - ct2->req_m.mode1.req_response[2] = 0x2; - } else { - ct2->req_m.mode1.req_sense_len = 18; - ct2->req_m.mode1.req_scsi_status |= - at2->req_scsi_status; - MEMCPY(ct2->req_m.mode1.req_response, - at2->req_sense, sizeof (at2->req_sense)); - } - break; - } - reqsize = sizeof (*ct2); - ireqp = ct2; - break; - } case RQSTYPE_CTIO2: - { - ispatiot2_t *at2; - ispctiot2_t *ct2 = (ispctiot2_t *) sp; - PRINTF("%s: CTIO2 returned status 0x%x\n", isp->isp_name, - ct2->req_status); - /* - * Return the ATIO to the board. - */ - at2 = (ispatiot2_t *) sp; - at2->req_header.rqs_entry_type = RQSTYPE_ATIO2; - at2->req_header.rqs_entry_count = 1; - at2->req_header.rqs_flags = 0; - at2->req_header.rqs_seqno = isp->isp_seqno++; - at2->req_status = 1; - reqsize = sizeof (*at2); - ireqp = at2; - break; - } -#undef atio -#undef at2io -#undef ctio -#undef ct2io -#undef lunen -#undef inot -#undef inot_fc -#undef nack -#undef nack_fc + case RQSTYPE_CTIO3: +#ifdef ISP_TARGET_MODE + return (isp_target_entry(isp, sp)); +#else + /* FALLTHROUGH */ #endif + case RQSTYPE_REQUEST: default: - PRINTF("%s: other response type %x\n", isp->isp_name, + PRINTF("%s: unhandled response type 0x%x\n", isp->isp_name, sp->req_header.rqs_entry_type); - break; - } - if (reqsize) { - void *reqp; - optr = isp->isp_reqodx = ISP_READ(isp, OUTMAILBOX4); - iptr = isp->isp_reqidx; - reqp = (void *) ISP_QUEUE_ENTRY(isp->isp_rquest, iptr); - iptr = ISP_NXT_QENTRY(iptr, RQUEST_QUEUE_LEN); - if (iptr == optr) { - PRINTF("%s: Request Queue Overflow other response\n", - isp->isp_name); - } else { - MEMCPY(reqp, ireqp, reqsize); - ISP_WRITE(isp, INMAILBOX4, iptr); - isp->isp_reqidx = iptr; - } - } - return (0); -} - -#ifdef ISP_TARGET_MODE - -static void isp_tmd_newcmd_dflt __P((void *, tmd_cmd_t *)); -static void isp_tmd_event_dflt __P((void *, int)); -static void isp_tmd_notify_dflt __P((void *, tmd_notify_t *)); - -static void isp_tgt_data_xfer __P ((tmd_cmd_t *)); -static void isp_tgt_endcmd __P ((tmd_cmd_t *, u_int8_t)); -static void isp_tgt_done __P ((tmd_cmd_t *)); - -static void -isp_tmd_newcmd_dflt(arg0, cmdp) - void *arg0; - tmd_cmd_t *cmdp; -{ -} - -static void -isp_tmd_event_dflt(arg0, event) - void *arg0; - int event; -{ -} - -static void -isp_tmd_notify_dflt(arg0, npt) - void *arg0; - tmd_notify_t *npt; -{ -} - -/* - * Locks held, and ints disabled (if FC). - * - * XXX: SETUP ONLY FOR INITIAL ENABLING RIGHT NOW - */ -static int -isp_modify_lun(isp, lun, icnt, ccnt) - struct ispsoftc *isp; - int lun; /* logical unit to enable, modify, or disable */ - int icnt; /* immediate notify count */ - int ccnt; /* command count */ -{ - isplun_t *ip = NULL; - u_int8_t iptr, optr; - - optr = isp->isp_reqodx = ISP_READ(isp, OUTMAILBOX4); - iptr = isp->isp_reqidx; - ip = (isplun_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, iptr); - iptr = ISP_NXT_QENTRY(iptr, RQUEST_QUEUE_LEN); - if (iptr == optr) { - PRINTF("%s: Request Queue Overflow in isp_modify_lun\n", - isp->isp_name); return (-1); } - - MEMZERO((void *) ip, sizeof (*ip)); - ip->req_header.rqs_entry_type = RQSTYPE_ENABLE_LUN; - ip->req_header.rqs_entry_count = 1; - ip->req_header.rqs_seqno = isp->isp_seqno++; - ip->req_handle = RQSTYPE_ENABLE_LUN; - if (isp->isp_type & ISP_HA_SCSI) { - ip->req_lun = lun; - } - ip->req_cmdcount = ccnt; - ip->req_imcount = icnt; - ip->req_timeout = 0; /* default 30 seconds */ - ISP_WRITE(isp, INMAILBOX4, iptr); - isp->isp_reqidx = iptr; - return (0); -} - -static void -isp_notify_ack(isp, ptrp) - struct ispsoftc *isp; - void *ptrp; -{ - void *reqp; - u_int8_t iptr, optr; - union { - na_fcentry_t _naf; - na_entry_t _nas; - } un; - - MEMZERO((caddr_t)&un, sizeof (un)); - un._nas.na_header.rqs_entry_type = RQSTYPE_NOTIFY_ACK; - un._nas.na_header.rqs_entry_count = 1; - - if (isp->isp_type & ISP_HA_FC) { - na_fcentry_t *na = &un._nas; - if (ptrp) { - in_fcentry_t *inp = ptrp; - na->na_iid = inp->in_iid; - na->na_lun = inp->in_lun; - na->na_task_flags = inp->in_task_flags; - na->na_seqid = inp->in_seqid; - na->na_status = inp->in_status; - } else { - na->na_flags = NAFC_RST_CLRD; - } - } else { - na_entry_t *na = &un._nas; - if (ptrp) { - in_entry_t *inp = ptrp; - na->na_iid = inp->in_iid; - na->na_lun = inp->in_lun; - na->na_tgt = inp->in_tgt; - na->na_seqid = inp->in_seqid; - } else { - na->na_flags = NA_RST_CLRD; - } - } - optr = isp->isp_reqodx = ISP_READ(isp, OUTMAILBOX4); - iptr = isp->isp_reqidx; - reqp = (void *) ISP_QUEUE_ENTRY(isp->isp_rquest, iptr); - iptr = ISP_NXT_QENTRY(iptr, RQUEST_QUEUE_LEN); - if (iptr == optr) { - PRINTF("%s: Request Queue Overflow For isp_notify_ack\n", - isp->isp_name); - } else { - MEMCPY(reqp, ireqp, sizeof (un)); - ISP_WRITE(isp, INMAILBOX4, iptr); - isp->isp_reqidx = iptr; - } } -/* - * These are dummy stubs for now until the outside framework is plugged in. - */ - -static void -isp_handle_atio (isp, aep) - struct ispsoftc *isp; - at_entry_t *aep; -{ - int status, connected; - tmd_cmd_t local, *cdp = &local; - - /* - * Get the ATIO status and see if we're still connected. - */ - status = aep->at_status; - connected = ((aep->at_flags & AT_NODISC) != 0); - - PRINTF("%s: ATIO status=0x%x, connected=%d\n", isp->isp_name, - status, connected); - - /* - * The firmware status (except for the SenseValid bit) indicates - * why this ATIO was sent to us. - * If SenseValid is set, the firware has recommended Sense Data. - * If the Disconnects Disabled bit is set in the flags field, - * we're still connected on the SCSI bus - i.e. the initiator - * did not set DiscPriv in the identify message. We don't care - * about this so it's ignored. - */ - switch (status & ~TGTSVALID) { - case AT_PATH_INVALID: - /* - * ATIO rejected by the firmware due to disabled lun. - */ - PRINTF("%s: Firmware rejected ATIO for disabled lun %d\n", - isp->isp_name, aep->at_lun); - break; - - case AT_PHASE_ERROR: - /* - * Bus Pase Sequence error. - * - * The firmware should have filled in the correct - * sense data. - */ - - - if (status & TGTSVALID) { - MEMCPY(&cdp->cd_sensedata, aep->at_sense, - sizeof (cdp->cd_sensedata)); - PRINTF("%s: Bus Phase Sequence error key 0x%x\n", - isp->isp_name, cdp->cd_sensedata[2] & 0xf); - } else { - PRINTF("%s: Bus Phase Sequence With No Sense\n", - isp->isp_name); - } - (*isp->isp_tmd_newcmd)(isp, cdp); - break; - - case AT_NOCAP: - /* - * Requested Capability not available - * We sent an ATIO that overflowed the firmware's - * command resource count. - */ - PRINTF("%s: Firmware rejected ATIO, command count overflow\n", - isp->isp_name); - break; - - case AT_BDR_MSG: - /* - * If we send an ATIO to the firmware to increment - * its command resource count, and the firmware is - * recovering from a Bus Device Reset, it returns - * the ATIO with this status. - */ - PRINTF("%s: ATIO returned with BDR received\n", isp->isp_name); - break; - - case AT_CDB: - /* - * New CDB - */ - cdp->cd_hba = isp; - cdp->cd_iid = aep->at_iid; - cdp->cd_tgt = aep->at_tgt; - cdp->cd_lun = aep->at_lun; - cdp->cd_tagtype = aep->at_tag_type; - cdp->cd_tagval = aep->at_tag_val; - MEMCPY(cdp->cd_cdb, aep->at_cdb, 16); - PRINTF("%s: CDB 0x%x itl %d/%d/%d\n", isp->isp_name, - cdp->cd_cdb[0], cdp->cd_iid, cdp->cd_tgt, cdp->cd_lun); - (*isp->isp_tmd_newcmd)(isp, cdp); - break; - - default: - PRINTF("%s: Unknown status (0x%x) in ATIO\n", - isp->isp_name, status); - cdp->cd_hba = isp; - cdp->cd_iid = aep->at_iid; - cdp->cd_tgt = aep->at_tgt; - cdp->cd_lun = aep->at_lun; - cdp->cd_tagtype = aep->at_tag_type; - cdp->cd_tagval = aep->at_tag_val; - isp_tgtcmd_done(cdp); - break; - } -} - -static void -isp_handle_atio2(isp, aep) - struct ispsoftc *isp; - at2_entry_t *aep; -{ - int status; - tmd_cmd_t local, *cdp = &local; - - /* - * Get the ATIO2 status. - */ - status = aep->at_status; - PRINTD("%s: ATIO2 status=0x%x\n", status); - - /* - * The firmware status (except for the SenseValid bit) indicates - * why this ATIO was sent to us. - * If SenseValid is set, the firware has recommended Sense Data. - */ - switch (status & ~TGTSVALID) { - case AT_PATH_INVALID: - /* - * ATIO rejected by the firmware due to disabled lun. - */ - PRINTF("%s: Firmware rejected ATIO2 for disabled lun %d\n", - isp->isp_name, aep->at_lun); - break; - - case AT_NOCAP: - /* - * Requested Capability not available - * We sent an ATIO that overflowed the firmware's - * command resource count. - */ - PRINTF("%s: Firmware rejected ATIO2, command count overflow\n", - isp->isp_name); - break; - - case AT_BDR_MSG: - /* - * If we send an ATIO to the firmware to increment - * its command resource count, and the firmware is - * recovering from a Bus Device Reset, it returns - * the ATIO with this status. - */ - PRINTF("%s: ATIO2 returned with BDR rcvd\n", isp->isp_name); - break; - - case AT_CDB: - /* - * New CDB - */ - cdp->cd_hba = isp; - cdp->cd_iid = aep->at_iid; - cdp->cd_tgt = 0; - cdp->cd_lun = aep->at_lun; - MEMCPY(cdp->cd_cdb, aep->at_cdb, 16); - cdp->cd_rxid = aep->at_rxid; - cdp->cp_origdlen = aep->at_datalen; - cdp->cp_totbytes = 0; - PRINTF("%s: CDB 0x%x rx_id 0x%x itl %d/%d/%d dlen %d\n", - isp->isp_name, cdp->cd_cdb[0], cdp->cd_tagval, cdp->cd_iid, - cdp->cd_tgt, cdp->cd_lun, aep->at_datalen); - (*isp->isp_tmd_newcmd)(isp, cdp); - break; - - default: - PRINTF("%s: Unknown status (0x%x) in ATIO2\n", - isp->isp_name, status); - cdp->cd_hba = isp; - cdp->cd_iid = aep->at_iid; - cdp->cd_tgt = aep->at_tgt; - cdp->cd_lun = aep->at_lun; - cdp->cp_rxid = aep->at_rxid; - isp_tgtcmd_done(cdp); - break; - } -} - -static void -isp_handle_ctio(isp, cep) - struct ispsoftc *isp; - ct_entry_t *aep; -{ -} - -static void -isp_handle_ctio2(isp, cep) - struct ispsoftc *isp; - at2_entry_t *aep; -{ -} -#endif - static void isp_parse_status(isp, sp, xs) struct ispsoftc *isp; @@ -2538,14 +2707,20 @@ isp_parse_status(isp, sp, xs) case RQCS_RESET_OCCURRED: IDPRINTF(2, ("%s: bus reset destroyed command for target %d " "lun %d\n", isp->isp_name, XS_TGT(xs), XS_LUN(xs))); - isp->isp_sendmarker = 1; + /* + * XXX: Get port number for bus + */ + isp->isp_sendmarker = 3; XS_SETERR(xs, HBA_BUSRESET); return; case RQCS_ABORTED: PRINTF("%s: command aborted for target %d lun %d\n", isp->isp_name, XS_TGT(xs), XS_LUN(xs)); - isp->isp_sendmarker = 1; + /* + * XXX: Get port number for bus + */ + isp->isp_sendmarker = 3; XS_SETERR(xs, HBA_ABORTED); return; @@ -2556,7 +2731,7 @@ isp_parse_status(isp, sp, xs) return; case RQCS_DATA_OVERRUN: - if (isp->isp_type & ISP_HA_FC) { + if (IS_FC(isp)) { XS_RESID(xs) = sp->req_resid; break; } @@ -2631,7 +2806,7 @@ isp_parse_status(isp, sp, xs) break; case RQCS_DATA_UNDERRUN: - if (isp->isp_type & ISP_HA_FC) { + if (IS_FC(isp)) { XS_RESID(xs) = sp->req_resid; /* an UNDERRUN is not a botch ??? */ } @@ -2661,9 +2836,9 @@ isp_parse_status(isp, sp, xs) break; case RQCS_QUEUE_FULL: - PRINTF("%s: internal queues full for target %d lun %d " + IDPRINTF(3, ("%s: internal queues full for target %d lun %d " "status 0x%x\n", isp->isp_name, XS_TGT(xs), XS_LUN(xs), - XS_STS(xs)); + XS_STS(xs))); /* * If QFULL or some other status byte is set, then this * isn't an error, per se. @@ -2689,11 +2864,12 @@ isp_parse_status(isp, sp, xs) case RQCS_WIDE_FAILED: PRINTF("%s: Wide Negotiation failed for target %d lun %d\n", isp->isp_name, XS_TGT(xs), XS_LUN(xs)); - if (isp->isp_type & ISP_HA_SCSI) { + if (IS_SCSI(isp)) { sdparam *sdp = isp->isp_param; - isp->isp_update = 1; + sdp += XS_CHANNEL(xs); sdp->isp_devparam[XS_TGT(xs)].dev_flags &= ~DPARM_WIDE; sdp->isp_devparam[XS_TGT(xs)].dev_update = 1; + isp->isp_update = XS_CHANNEL(xs)+1; } XS_SETERR(xs, HBA_NOERROR); return; @@ -2701,11 +2877,12 @@ isp_parse_status(isp, sp, xs) case RQCS_SYNCXFER_FAILED: PRINTF("%s: SDTR Message failed for target %d lun %d\n", isp->isp_name, XS_TGT(xs), XS_LUN(xs)); - if (isp->isp_type & ISP_HA_SCSI) { + if (IS_SCSI(isp)) { sdparam *sdp = isp->isp_param; - isp->isp_update = 1; + sdp += XS_CHANNEL(xs); sdp->isp_devparam[XS_TGT(xs)].dev_flags &= ~DPARM_SYNC; sdp->isp_devparam[XS_TGT(xs)].dev_update = 1; + isp->isp_update = XS_CHANNEL(xs)+1; } break; @@ -2727,8 +2904,8 @@ isp_parse_status(isp, sp, xs) /* * It was there (maybe)- treat as a selection timeout. */ - PRINTF("%s: port logout for target %d\n", - isp->isp_name, XS_TGT(xs)); + IDPRINTF(2, ("%s: port logout for target %d\n", + isp->isp_name, XS_TGT(xs))); XS_SETERR(xs, HBA_SELTIMEOUT); return; @@ -2754,19 +2931,21 @@ isp_parse_status(isp, sp, xs) static void isp_fastpost_complete(isp, fph) struct ispsoftc *isp; - int fph; + u_int32_t fph; { ISP_SCSI_XFER_T *xs; - if (fph < 1) + if (fph < 1) { return; - xs = (ISP_SCSI_XFER_T *) isp->isp_xflist[fph - 1]; - isp->isp_xflist[fph - 1] = NULL; + } + xs = isp_find_xs(isp, fph); if (xs == NULL) { - PRINTF("%s: fast posting handle 0x%x not found\n", - isp->isp_name, fph - 1); + PRINTF("%s: command for fast posting handle 0x%x not found\n", + isp->isp_name, fph); return; } + isp_destroy_handle(isp, fph); + /* * Since we don't have a result queue entry item, * we must believe that SCSI status is zero and @@ -2775,9 +2954,11 @@ isp_fastpost_complete(isp, fph) XS_RESID(xs) = 0; XS_STS(xs) = 0; if (XS_XFRLEN(xs)) { - ISP_DMAFREE(isp, xs, fph - 1); + ISP_DMAFREE(isp, xs, fph); } XS_CMD_DONE(xs); + if (isp->isp_nactive) + isp->isp_nactive--; } #define HINIB(x) ((x) >> 0x4) @@ -2792,7 +2973,7 @@ static u_int8_t mbpcnt[] = { MAKNIB(2, 3), /* 0x05: MBOX_READ_RAM_WORD */ MAKNIB(6, 6), /* 0x06: MBOX_MAILBOX_REG_TEST */ MAKNIB(2, 3), /* 0x07: MBOX_VERIFY_CHECKSUM */ - MAKNIB(1, 3), /* 0x08: MBOX_ABOUT_FIRMWARE */ + MAKNIB(1, 4), /* 0x08: MBOX_ABOUT_FIRMWARE */ MAKNIB(0, 0), /* 0x09: */ MAKNIB(0, 0), /* 0x0a: */ MAKNIB(0, 0), /* 0x0b: */ @@ -2816,8 +2997,8 @@ static u_int8_t mbpcnt[] = { MAKNIB(2, 4), /* 0x1d: MBOX_GET_DEV_QUEUE_STATUS */ MAKNIB(0, 0), /* 0x1e: */ MAKNIB(1, 3), /* 0x1f: MBOX_GET_FIRMWARE_STATUS */ - MAKNIB(1, 3), /* 0x20: MBOX_GET_INIT_SCSI_ID, MBOX_GET_LOOP_ID */ - MAKNIB(1, 2), /* 0x21: MBOX_GET_SELECT_TIMEOUT */ + MAKNIB(1, 4), /* 0x20: MBOX_GET_INIT_SCSI_ID, MBOX_GET_LOOP_ID */ + MAKNIB(1, 3), /* 0x21: MBOX_GET_SELECT_TIMEOUT */ MAKNIB(1, 3), /* 0x22: MBOX_GET_RETRY_COUNT */ MAKNIB(1, 2), /* 0x23: MBOX_GET_TAG_AGE_LIMIT */ MAKNIB(1, 2), /* 0x24: MBOX_GET_CLOCK_RATE */ @@ -2826,23 +3007,23 @@ static u_int8_t mbpcnt[] = { MAKNIB(1, 3), /* 0x27: MBOX_GET_PCI_PARAMS */ MAKNIB(2, 4), /* 0x28: MBOX_GET_TARGET_PARAMS */ MAKNIB(2, 4), /* 0x29: MBOX_GET_DEV_QUEUE_PARAMS */ - MAKNIB(0, 0), /* 0x2a: */ + MAKNIB(1, 2), /* 0x2a: MBOX_GET_RESET_DELAY_PARAMS */ MAKNIB(0, 0), /* 0x2b: */ MAKNIB(0, 0), /* 0x2c: */ MAKNIB(0, 0), /* 0x2d: */ MAKNIB(0, 0), /* 0x2e: */ MAKNIB(0, 0), /* 0x2f: */ MAKNIB(2, 2), /* 0x30: MBOX_SET_INIT_SCSI_ID */ - MAKNIB(2, 2), /* 0x31: MBOX_SET_SELECT_TIMEOUT */ + MAKNIB(2, 3), /* 0x31: MBOX_SET_SELECT_TIMEOUT */ MAKNIB(3, 3), /* 0x32: MBOX_SET_RETRY_COUNT */ MAKNIB(2, 2), /* 0x33: MBOX_SET_TAG_AGE_LIMIT */ MAKNIB(2, 2), /* 0x34: MBOX_SET_CLOCK_RATE */ - MAKNIB(2, 2), /* 0x35: MBOX_SET_ACTIVE_NEG_STATE */ + MAKNIB(2, 2), /* 0x35: MBOX_SET_ACT_NEG_STATE */ MAKNIB(2, 2), /* 0x36: MBOX_SET_ASYNC_DATA_SETUP_TIME */ MAKNIB(3, 3), /* 0x37: MBOX_SET_PCI_CONTROL_PARAMS */ MAKNIB(4, 4), /* 0x38: MBOX_SET_TARGET_PARAMS */ MAKNIB(4, 4), /* 0x39: MBOX_SET_DEV_QUEUE_PARAMS */ - MAKNIB(0, 0), /* 0x3a: */ + MAKNIB(1, 2), /* 0x3a: MBOX_SET_RESET_DELAY_PARAMS */ MAKNIB(0, 0), /* 0x3b: */ MAKNIB(0, 0), /* 0x3c: */ MAKNIB(0, 0), /* 0x3d: */ @@ -2881,7 +3062,7 @@ static u_int8_t mbpcnt[] = { MAKNIB(0, 0), /* 0x5e: */ MAKNIB(0, 0), /* 0x5f: */ MAKNIB(8, 6), /* 0x60: MBOX_INIT_FIRMWARE */ - MAKNIB(0, 0), /* 0x60: MBOX_GET_INIT_CONTROL_BLOCK (FORMAT?) */ + MAKNIB(0, 0), /* 0x61: */ MAKNIB(2, 1), /* 0x62: MBOX_INIT_LIP */ MAKNIB(8, 1), /* 0x63: MBOX_GET_FC_AL_POSITION_MAP */ MAKNIB(8, 1), /* 0x64: MBOX_GET_PORT_DB */ @@ -2894,10 +3075,10 @@ static u_int8_t mbpcnt[] = { MAKNIB(8, 1), /* 0x6b: MBOX_GET_LINK_STATUS */ MAKNIB(4, 4), /* 0x6c: MBOX_INIT_LIP_RESET */ MAKNIB(0, 0), /* 0x6d: */ - MAKNIB(0, 0), /* 0x6e: */ - MAKNIB(0, 0), /* 0x6f: */ - MAKNIB(0, 0), /* 0x70: */ - MAKNIB(0, 0), /* 0x71: */ + MAKNIB(8, 2), /* 0x6e: MBOX_SEND_SNS */ + MAKNIB(4, 3), /* 0x6f: MBOX_FABRIC_LOGIN */ + MAKNIB(2, 1), /* 0x70: MBOX_SEND_CHANGE_REQUEST */ + MAKNIB(2, 1), /* 0x71: MBOX_FABRIC_LOGOUT */ MAKNIB(4, 1) /* 0x72: MBOX_INIT_LIP_LOGIN */ }; #define NMBCOM (sizeof (mbpcnt) / sizeof (mbpcnt[0])) @@ -2936,7 +3117,7 @@ isp_mboxcmd(isp, mbp) * Check for variants */ #ifdef ISP2100_SCCLUN - if (isp->isp_type & ISP_HA_FC) { + if (IS_FC(isp)) { switch (mbp->param[0]) { case MBOX_ABORT: inparam = 7; @@ -2949,6 +3130,9 @@ isp_mboxcmd(isp, mbp) case MBOX_GET_DEV_QUEUE_STATUS: inparam = 3; break; + case MBOX_BUS_RESET: + inparam = 2; + break; default: break; } @@ -2963,13 +3147,18 @@ command_known: ISP_WRITE(isp, BIU_SEMA, 1); /* - * Make sure we can send some words. Check to see id there's - * an async mbox event pending. + * Qlogic Errata for the ISP2100 says that there is a necessary + * debounce between between writing the semaphore register + * and reading a mailbox register. I believe we're okay here. + */ + + /* + * Make sure we can send some words. + * Check to see if there's an async mbox event pending. */ loops = MBOX_DELAY_COUNT; while ((ISP_READ(isp, HCCR) & HCCR_HOST_INT) != 0) { - SYS_DELAY(100); if (ISP_READ(isp, BIU_SEMA) & 1) { int fph; u_int16_t mbox = ISP_READ(isp, OUTMAILBOX0); @@ -2978,6 +3167,8 @@ command_known: */ if (mbox & 0x8000) { fph = isp_parse_async(isp, (int) mbox); + IDPRINTF(5, ("%s: line %d, fph %d\n", + isp->isp_name, __LINE__, fph)); ISP_WRITE(isp, BIU_SEMA, 0); ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); if (fph < 0) { @@ -2994,13 +3185,16 @@ command_known: * just clear HOST INTERRUPT, so we'll just silently * eat this here. */ - if (mbox == MBOX_COMMAND_COMPLETE) { + if (mbox & 0x4000) { + IDPRINTF(5, ("%s: line %d, mbox 0x%x\n", + isp->isp_name, __LINE__, mbox)); ISP_WRITE(isp, BIU_SEMA, 0); ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT); SYS_DELAY(100); goto command_known; } } + SYS_DELAY(100); if (--loops < 0) { if (dld++ > 10) { PRINTF("%s: isp_mboxcmd could not get command " @@ -3014,23 +3208,31 @@ command_known: } /* - * If we're a 1080 or a 1240, make sure that for a couple of commands - * the port parameter is set. This is sort of a temporary solution - * to do it here rather than every place a mailbox command is formed. + * Write input parameters. + * + * Special case some of the setups for the dual port SCSI cards. + * XXX Eventually will be fixed by converting register write/read + * XXX counts to bitmasks. */ - if (IS_1080(isp) || IS_12X0(isp)) { - switch (mbp->param[0]) { - case MBOX_BUS_RESET: - mbp->param[2] = isp->isp_port; + if (IS_12X0(isp)) { + switch (opcode) { + case MBOX_GET_RETRY_COUNT: + case MBOX_SET_RETRY_COUNT: + ISP_WRITE(isp, INMAILBOX7, mbp->param[7]); + mbp->param[7] = 0; + ISP_WRITE(isp, INMAILBOX6, mbp->param[6]); + mbp->param[6] = 0; break; - default: + case MBOX_SET_ASYNC_DATA_SETUP_TIME: + case MBOX_SET_ACT_NEG_STATE: + case MBOX_SET_TAG_AGE_LIMIT: + case MBOX_SET_SELECT_TIMEOUT: + ISP_WRITE(isp, INMAILBOX2, mbp->param[2]); + mbp->param[2] = 0; break; } } - /* - * Write input parameters. - */ switch (inparam) { case 8: ISP_WRITE(isp, INMAILBOX7, mbp->param[7]); mbp->param[7] = 0; case 7: ISP_WRITE(isp, INMAILBOX6, mbp->param[6]); mbp->param[6] = 0; @@ -3063,7 +3265,6 @@ command_known: */ ISP_WRITE(isp, BIU_SEMA, 0); - ENABLE_INTS(isp); /* * Set Host Interrupt condition so that RISC will pick up mailbox regs. */ @@ -3135,8 +3336,29 @@ command_known: } /* - * Pick up output parameters. + * Pick up output parameters. Special case some of the readbacks + * for the dual port SCSI cards. */ + if (IS_12X0(isp)) { + switch (opcode) { + case MBOX_GET_RETRY_COUNT: + case MBOX_SET_RETRY_COUNT: + mbp->param[7] = ISP_READ(isp, OUTMAILBOX7); + mbp->param[6] = ISP_READ(isp, OUTMAILBOX6); + break; + case MBOX_GET_TAG_AGE_LIMIT: + case MBOX_SET_TAG_AGE_LIMIT: + case MBOX_GET_ACT_NEG_STATE: + case MBOX_SET_ACT_NEG_STATE: + case MBOX_SET_ASYNC_DATA_SETUP_TIME: + case MBOX_GET_ASYNC_DATA_SETUP_TIME: + case MBOX_GET_RESET_DELAY_PARAMS: + case MBOX_SET_RESET_DELAY_PARAMS: + mbp->param[2] = ISP_READ(isp, OUTMAILBOX2); + break; + } + } + switch (outparam) { case 8: mbp->param[7] = ISP_READ(isp, OUTMAILBOX7); case 7: mbp->param[6] = ISP_READ(isp, OUTMAILBOX6); @@ -3177,8 +3399,9 @@ command_known: isp->isp_name, opcode); break; case MBOX_COMMAND_ERROR: - PRINTF("%s: mbox cmd %x failed with COMMAND_ERROR\n", - isp->isp_name, opcode); + if (opcode != MBOX_ABOUT_FIRMWARE) + PRINTF("%s: mbox cmd %x failed with COMMAND_ERROR\n", + isp->isp_name, opcode); break; case MBOX_COMMAND_PARAM_ERROR: switch (opcode) { @@ -3195,16 +3418,25 @@ command_known: /* * Be silent about these... */ + case ASYNC_PDB_CHANGED: + ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_PDB_RCVD; + break; case ASYNC_LIP_OCCURRED: + ((fcparam *) isp->isp_param)->isp_lipseq = mbp->param[1]; + /* FALLTHROUGH */ case ASYNC_LOOP_UP: + ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT; + ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_LIP_RCVD; + break; + case ASYNC_LOOP_DOWN: case ASYNC_LOOP_RESET: + ((fcparam *) isp->isp_param)->isp_fwstate = FW_CONFIG_WAIT; + ((fcparam *) isp->isp_param)->isp_loopstate = LOOP_NIL; + /* FALLTHROUGH */ case ASYNC_CHANGE_NOTIFY: break; - case ASYNC_PDB_CHANGED: - isp_mark_getpdb_all(isp); - break; default: /* @@ -3240,7 +3472,7 @@ isp_lostcmd(isp, xs) return; mbs.param[0] = MBOX_GET_DEV_QUEUE_STATUS; - mbs.param[1] = (XS_TGT(xs) << 8) | XS_LUN(xs); + mbs.param[1] = (XS_TGT(xs) << 8) | XS_LUN(xs); /* XXX: WHICH BUS? */ isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { isp_dumpregs(isp, "couldn't GET DEVICE QUEUE STATUS"); @@ -3262,7 +3494,7 @@ isp_dumpregs(isp, msg) const char *msg; { PRINTF("%s: %s\n", isp->isp_name, msg); - if (isp->isp_type & ISP_HA_SCSI) + if (IS_SCSI(isp)) PRINTF(" biu_conf1=%x", ISP_READ(isp, BIU_CONF1)); else PRINTF(" biu_csr=%x", ISP_READ(isp, BIU2100_CSR)); @@ -3271,7 +3503,7 @@ isp_dumpregs(isp, msg) PRINTF("risc_hccr=%x\n", ISP_READ(isp, HCCR)); - if (isp->isp_type & ISP_HA_SCSI) { + if (IS_SCSI(isp)) { ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE); PRINTF(" cdma_conf=%x cdma_sts=%x cdma_fifostat=%x\n", ISP_READ(isp, CDMA_CONF), ISP_READ(isp, CDMA_STATUS), @@ -3293,53 +3525,50 @@ isp_dumpregs(isp, msg) } static void -isp_dumpxflist(isp) - struct ispsoftc *isp; -{ - volatile ISP_SCSI_XFER_T *xs; - int i, hdp; - - for (hdp = i = 0; i < RQUEST_QUEUE_LEN; i++) { - xs = isp->isp_xflist[i]; - if (xs == NULL) { - continue; - } - if (hdp == 0) { - PRINTF("%s: active requests\n", isp->isp_name); - hdp++; - } - PRINTF(" Active Handle %d: tgt %d lun %d dlen %d\n", - i+1, XS_TGT(xs), XS_LUN(xs), XS_XFRLEN(xs)); - } -} - -static void isp_fw_state(isp) struct ispsoftc *isp; { mbreg_t mbs; - if (isp->isp_type & ISP_HA_FC) { + if (IS_FC(isp)) { int once = 0; fcparam *fcp = isp->isp_param; again: mbs.param[0] = MBOX_GET_FW_STATE; isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { + IDPRINTF(1, ("%s: isp_fw_state 0x%x\n", isp->isp_name, + mbs.param[0])); switch (mbs.param[0]) { case ASYNC_PDB_CHANGED: - isp_mark_getpdb_all(isp); - /* FALL THROUGH */ + if (once++ < 10) { + goto again; + } + fcp->isp_fwstate = FW_CONFIG_WAIT; + fcp->isp_loopstate = LOOP_PDB_RCVD; + goto again; case ASYNC_LIP_OCCURRED: + fcp->isp_lipseq = mbs.param[1]; + /* FALLTHROUGH */ case ASYNC_LOOP_UP: - case ASYNC_LOOP_DOWN: + fcp->isp_fwstate = FW_CONFIG_WAIT; + fcp->isp_loopstate = LOOP_LIP_RCVD; + if (once++ < 10) { + goto again; + } + break; case ASYNC_LOOP_RESET: + case ASYNC_LOOP_DOWN: + fcp->isp_fwstate = FW_CONFIG_WAIT; + fcp->isp_loopstate = LOOP_NIL; + /* FALLTHROUGH */ case ASYNC_CHANGE_NOTIFY: - if (once++ < 2) { + if (once++ < 10) { goto again; } break; } - isp_dumpregs(isp, "GET FIRMWARE STATE failed"); + PRINTF("%s: GET FIRMWARE STATE failed (0x%x)\n", + isp->isp_name, mbs.param[0]); return; } fcp->isp_fwstate = mbs.param[1]; @@ -3350,22 +3579,39 @@ static void isp_update(isp) struct ispsoftc *isp; { + int bus; + + for (bus = 0; isp->isp_update != 0; bus++) { + if (isp->isp_update & (1 << bus)) { + isp_update_bus(isp, bus); + isp->isp_update ^= (1 << bus); + } + } +} + +static void +isp_update_bus(isp, bus) + struct ispsoftc *isp; + int bus; +{ int tgt; mbreg_t mbs; sdparam *sdp; - isp->isp_update = 0; - - if (isp->isp_type & ISP_HA_FC) { + if (IS_FC(isp)) { return; } sdp = isp->isp_param; + sdp += bus; + for (tgt = 0; tgt < MAX_TARGETS; tgt++) { - u_int16_t flags, period, offset, changed; + u_int16_t flags, period, offset; int get; if (sdp->isp_devparam[tgt].dev_enable == 0) { + IDPRINTF(1, ("%s: skipping target %d bus %d update\n", + isp->isp_name, tgt, bus)); continue; } @@ -3378,6 +3624,13 @@ isp_update(isp) if (sdp->isp_devparam[tgt].dev_update) { mbs.param[0] = MBOX_SET_TARGET_PARAMS; mbs.param[2] = sdp->isp_devparam[tgt].dev_flags; + /* + * Insist that PARITY must be enabled if SYNC + * is enabled. + */ + if (mbs.param[2] & DPARM_SYNC) { + mbs.param[2] |= DPARM_PARITY; + } mbs.param[3] = (sdp->isp_devparam[tgt].sync_offset << 8) | (sdp->isp_devparam[tgt].sync_period); @@ -3396,6 +3649,11 @@ isp_update(isp) sdp->isp_devparam[tgt].cur_dflags &= ~DPARM_TQING; sdp->isp_devparam[tgt].cur_dflags |= (sdp->isp_devparam[tgt].dev_flags & DPARM_TQING); + sdp->isp_devparam[tgt].dev_refresh = 1; + IDPRINTF(3, ("%s: bus %d set tgt %d flags 0x%x off 0x%x" + " period 0x%x\n", isp->isp_name, bus, tgt, + mbs.param[2], mbs.param[3] >> 8, + mbs.param[3] & 0xff)); get = 0; } else if (sdp->isp_devparam[tgt].dev_refresh) { mbs.param[0] = MBOX_GET_TARGET_PARAMS; @@ -3404,7 +3662,7 @@ isp_update(isp) } else { continue; } - mbs.param[1] = tgt << 8; + mbs.param[1] = (bus << 15) | (tgt << 8) ; isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { PRINTF("%s: failed to %cet SCSI parameters for " @@ -3412,55 +3670,69 @@ isp_update(isp) tgt); continue; } - if (get == 0) { - /* - * XXX: Need a SYNC_TARGET for efficiency... - */ - isp->isp_sendmarker = 1; + isp->isp_sendmarker |= (1 << bus); continue; } flags = mbs.param[2]; period = mbs.param[3] & 0xff; offset = mbs.param[3] >> 8; - if (sdp->isp_devparam[tgt].cur_dflags != flags || - sdp->isp_devparam[tgt].cur_period != period || - sdp->isp_devparam[tgt].cur_offset != offset) { - IDPRINTF(3, ("%s: tgt %d flags 0x%x period %d " - "off %d\n", isp->isp_name, tgt, flags, - period, offset)); - changed = 1; - } else { - changed = 0; - } sdp->isp_devparam[tgt].cur_dflags = flags; sdp->isp_devparam[tgt].cur_period = period; sdp->isp_devparam[tgt].cur_offset = offset; - if (sdp->isp_devparam[tgt].dev_announced == 0 || changed) { - if (isp_async(isp, ISPASYNC_NEW_TGT_PARAMS, &tgt)) - sdp->isp_devparam[tgt].dev_announced = 0; - else - sdp->isp_devparam[tgt].dev_announced = 1; - } + get = (bus << 16) | tgt; + (void) isp_async(isp, ISPASYNC_NEW_TGT_PARAMS, &get); } } static void -isp_setdfltparm(isp) +isp_setdfltparm(isp, channel) struct ispsoftc *isp; + int channel; { int tgt; mbreg_t mbs; - sdparam *sdp; + sdparam *sdp, *sdp_chan0, *sdp_chan1; + + if (IS_FC(isp)) { + fcparam *fcp = (fcparam *) isp->isp_param; + fcp += channel; + if (fcp->isp_gotdparms) { + return; + } + fcp->isp_gotdparms = 1; + fcp->isp_maxfrmlen = ICB_DFLT_FRMLEN; + fcp->isp_maxalloc = ICB_DFLT_ALLOC; + fcp->isp_execthrottle = ICB_DFLT_THROTTLE; + fcp->isp_retry_delay = ICB_DFLT_RDELAY; + fcp->isp_retry_count = ICB_DFLT_RCOUNT; + /* Platform specific.... */ + fcp->isp_loopid = DEFAULT_LOOPID(isp); + fcp->isp_nodewwn = DEFAULT_WWN(isp); + fcp->isp_portwwn = 0; + /* + * Now try and read NVRAM + */ + if ((isp->isp_confopts & (ISP_CFG_NONVRAM|ISP_CFG_OWNWWN)) || + (isp_read_nvram(isp))) { + PRINTF("%s: using Node WWN 0x%08x%08x\n", + isp->isp_name, (u_int32_t)(fcp->isp_nodewwn >> 32), + (u_int32_t)(fcp->isp_nodewwn & 0xffffffff)); + } + return; + } + + sdp_chan0 = (sdparam *) isp->isp_param; + sdp_chan1 = sdp_chan0 + 1; + sdp = sdp_chan0 + channel; /* * Been there, done that, got the T-shirt... */ - if (isp->isp_gotdparms) { - IDPRINTF(3, ("%s: already have dparms\n", isp->isp_name)); + if (sdp->isp_gotdparms) { return; } - isp->isp_gotdparms = 1; + sdp->isp_gotdparms = 1; /* * If we've not been told to avoid reading NVRAM, try and read it. @@ -3468,39 +3740,34 @@ isp_setdfltparm(isp) * tell us the right thing to do. Otherwise, establish some reasonable * defaults. */ - if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) { if (isp_read_nvram(isp) == 0) { return; } } - if (IS_FC(isp)) { - fcparam *fcp = (fcparam *) isp->isp_param; - fcp->isp_maxfrmlen = ICB_DFLT_FRMLEN; - fcp->isp_maxalloc = 256; - fcp->isp_execthrottle = 16; - fcp->isp_retry_delay = 5; - fcp->isp_retry_count = 0; - /* - * It would be nice to fake up a WWN in case we don't - * get one out of NVRAM. Solaris does this for SOCAL - * cards that don't have SBus properties- it sets up - * a WWN based upon the system MAC Address. - */ - fcp->isp_wwn = 0; - return; - } - sdp = (sdparam *) isp->isp_param; + /* + * Now try and see whether we have specific values for them. + */ mbs.param[0] = MBOX_GET_ACT_NEG_STATE; isp_mboxcmd(isp, &mbs); if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { IDPRINTF(2, ("could not GET ACT NEG STATE\n")); - sdp->isp_req_ack_active_neg = 1; - sdp->isp_data_line_active_neg = 1; + sdp_chan0->isp_req_ack_active_neg = 1; + sdp_chan0->isp_data_line_active_neg = 1; + if (IS_12X0(isp)) { + sdp_chan1->isp_req_ack_active_neg = 1; + sdp_chan1->isp_data_line_active_neg = 1; + } } else { - sdp->isp_req_ack_active_neg = (mbs.param[1] >> 4) & 0x1; - sdp->isp_data_line_active_neg = (mbs.param[1] >> 5) & 0x1; + sdp_chan0->isp_req_ack_active_neg = (mbs.param[1] >> 4) & 0x1; + sdp_chan0->isp_data_line_active_neg = (mbs.param[1] >> 5) & 0x1; + if (IS_12X0(isp)) { + sdp_chan1->isp_req_ack_active_neg = + (mbs.param[2] >> 4) & 0x1; + sdp_chan1->isp_data_line_active_neg = + (mbs.param[2] >> 5) & 0x1; + } } /* @@ -3515,7 +3782,7 @@ isp_setdfltparm(isp) sdp->isp_devparam[tgt].dev_flags = DPARM_DEFAULT; sdp->isp_devparam[tgt].cur_dflags = 0; if (isp->isp_type < ISP_HA_SCSI_1040 || - (sdp->isp_clock && sdp->isp_clock < 60)) { + (isp->isp_clock && isp->isp_clock < 60)) { sdp->isp_devparam[tgt].sync_offset = ISP_10M_SYNCPARMS >> 8; sdp->isp_devparam[tgt].sync_period = @@ -3568,7 +3835,7 @@ isp_setdfltparm(isp) /* * It is not safe to run Ultra Mode with a clock < 60. */ - if (((sdp->isp_clock && sdp->isp_clock < 60) || + if (((isp->isp_clock && isp->isp_clock < 60) || (isp->isp_type < ISP_HA_SCSI_1020A)) && (sdp->isp_devparam[tgt].sync_period <= (ISP_20M_SYNCPARMS & 0xff))) { @@ -3580,23 +3847,24 @@ isp_setdfltparm(isp) } /* - * Set Default Host Adapter Parameters + * Establish default some more default parameters. */ sdp->isp_cmd_dma_burst_enable = 1; sdp->isp_data_dma_burst_enabl = 1; sdp->isp_fifo_threshold = 0; sdp->isp_initiator_id = 7; + /* XXXX This is probably based upon clock XXXX */ if (isp->isp_type >= ISP_HA_SCSI_1040) { sdp->isp_async_data_setup = 9; } else { sdp->isp_async_data_setup = 6; } sdp->isp_selection_timeout = 250; - sdp->isp_max_queue_depth = 128; + sdp->isp_max_queue_depth = MAXISPREQUEST; sdp->isp_tag_aging = 8; sdp->isp_bus_reset_delay = 3; - sdp->isp_retry_count = 0; - sdp->isp_retry_delay = 1; + sdp->isp_retry_count = 2; + sdp->isp_retry_delay = 2; for (tgt = 0; tgt < MAX_TARGETS; tgt++) { sdp->isp_devparam[tgt].exc_throttle = 16; @@ -3606,7 +3874,8 @@ isp_setdfltparm(isp) /* * Re-initialize the ISP and complete all orphaned commands - * with a 'botched' notice. + * with a 'botched' notice. The reset/init routines should + * not disturb an already active list of commands. * * Locks held prior to coming here. */ @@ -3615,13 +3884,12 @@ void isp_restart(isp) struct ispsoftc *isp; { - ISP_SCSI_XFER_T *tlist[RQUEST_QUEUE_LEN], *xs; - int i; + ISP_SCSI_XFER_T *xs; + u_int32_t handle; - for (i = 0; i < RQUEST_QUEUE_LEN; i++) { - tlist[i] = (ISP_SCSI_XFER_T *) isp->isp_xflist[i]; - isp->isp_xflist[i] = NULL; - } +#if 0 + isp->isp_gotdparms = 0; +#endif isp_reset(isp); if (isp->isp_state == ISP_RESETSTATE) { isp_init(isp); @@ -3632,15 +3900,20 @@ isp_restart(isp) if (isp->isp_state != ISP_RUNSTATE) { PRINTF("%s: isp_restart cannot restart ISP\n", isp->isp_name); } + isp->isp_nactive = 0; - for (i = 0; i < RQUEST_QUEUE_LEN; i++) { - xs = tlist[i]; - if (XS_NULL(xs)) { + for (handle = 1; handle <= (int) isp->isp_maxcmds; handle++) { + xs = isp_find_xs(isp, handle); + if (xs == NULL) { continue; } - if (isp->isp_nactive > 0) - isp->isp_nactive--; - XS_RESID(xs) = XS_XFRLEN(xs); + isp_destroy_handle(isp, handle); + if (XS_XFRLEN(xs)) { + ISP_DMAFREE(isp, xs, handle); + XS_RESID(xs) = XS_XFRLEN(xs); + } else { + XS_RESID(xs) = 0; + } XS_SETERR(xs, HBA_BUSRESET); XS_CMD_DONE(xs); } @@ -3654,6 +3927,8 @@ static int isp_read_nvram(isp) struct ispsoftc *isp; { + static char *tru = "true"; + static char *not = "false"; int i, amt; u_int8_t csum, minversion; union { @@ -3666,6 +3941,9 @@ isp_read_nvram(isp) if (IS_FC(isp)) { amt = ISP2100_NVRAM_SIZE; minversion = 1; + } else if (IS_1080(isp) || IS_12X0(isp)) { + amt = ISP1080_NVRAM_SIZE; + minversion = 0; } else { amt = ISP_NVRAM_SIZE; minversion = 2; @@ -3681,7 +3959,9 @@ isp_read_nvram(isp) if (nvram_data[0] != 'I' || nvram_data[1] != 'S' || nvram_data[2] != 'P') { if (isp->isp_bustype != ISP_BT_SBUS) { - PRINTF("%s: invalid NVRAM header\n", isp->isp_name); + PRINTF("%s: invalid NVRAM header (%x,%x,%x,%x)\n", + isp->isp_name, nvram_data[0], nvram_data[1], + nvram_data[2], nvram_data[3]); } return (-1); } @@ -3701,7 +3981,124 @@ isp_read_nvram(isp) return (-1); } - if (isp->isp_type & ISP_HA_SCSI) { + if (IS_1080(isp) || IS_12X0(isp)) { + int bus; + sdparam *sdp = (sdparam *) isp->isp_param; + for (bus = 0; bus < (IS_1080(isp)? 1 : 2); bus++, sdp++) { + sdp->isp_fifo_threshold = + ISP1080_NVRAM_FIFO_THRESHOLD(nvram_data); + + sdp->isp_initiator_id = + ISP1080_NVRAM_INITIATOR_ID(nvram_data, bus); + + sdp->isp_bus_reset_delay = + ISP1080_NVRAM_BUS_RESET_DELAY(nvram_data, bus); + + sdp->isp_retry_count = + ISP1080_NVRAM_BUS_RETRY_COUNT(nvram_data, bus); + + sdp->isp_retry_delay = + ISP1080_NVRAM_BUS_RETRY_DELAY(nvram_data, bus); + + sdp->isp_async_data_setup = + ISP1080_NVRAM_ASYNC_DATA_SETUP_TIME(nvram_data, + bus); + + sdp->isp_req_ack_active_neg = + ISP1080_NVRAM_REQ_ACK_ACTIVE_NEGATION(nvram_data, + bus); + + sdp->isp_data_line_active_neg = + ISP1080_NVRAM_DATA_LINE_ACTIVE_NEGATION(nvram_data, + bus); + + sdp->isp_data_dma_burst_enabl = + ISP1080_NVRAM_BURST_ENABLE(nvram_data); + + sdp->isp_cmd_dma_burst_enable = + ISP1080_NVRAM_BURST_ENABLE(nvram_data); + + sdp->isp_selection_timeout = + ISP1080_NVRAM_SELECTION_TIMEOUT(nvram_data, bus); + + sdp->isp_max_queue_depth = + ISP1080_NVRAM_MAX_QUEUE_DEPTH(nvram_data, bus); + + if (isp->isp_dblev >= 3) { + PRINTF("%s: ISP1080 bus %d NVRAM values:\n", + isp->isp_name, bus); + PRINTF(" Initiator ID = %d\n", + sdp->isp_initiator_id); + PRINTF(" Fifo Threshold = 0x%x\n", + sdp->isp_fifo_threshold); + PRINTF(" Bus Reset Delay = %d\n", + sdp->isp_bus_reset_delay); + PRINTF(" Retry Count = %d\n", + sdp->isp_retry_count); + PRINTF(" Retry Delay = %d\n", + sdp->isp_retry_delay); + PRINTF(" Tag Age Limit = %d\n", + sdp->isp_tag_aging); + PRINTF(" Selection Timeout = %d\n", + sdp->isp_selection_timeout); + PRINTF(" Max Queue Depth = %d\n", + sdp->isp_max_queue_depth); + PRINTF(" Async Data Setup = 0x%x\n", + sdp->isp_async_data_setup); + PRINTF(" REQ/ACK Active Negation = %s\n", + sdp->isp_req_ack_active_neg? tru : not); + PRINTF(" Data Line Active Negation = %s\n", + sdp->isp_data_line_active_neg? tru : not); + PRINTF(" Cmd DMA Burst Enable = %s\n", + sdp->isp_cmd_dma_burst_enable? tru : not); + } + for (i = 0; i < MAX_TARGETS; i++) { + sdp->isp_devparam[i].dev_enable = + ISP1080_NVRAM_TGT_DEVICE_ENABLE(nvram_data, i, bus); + sdp->isp_devparam[i].exc_throttle = + ISP1080_NVRAM_TGT_EXEC_THROTTLE(nvram_data, i, bus); + sdp->isp_devparam[i].sync_offset = + ISP1080_NVRAM_TGT_SYNC_OFFSET(nvram_data, i, bus); + sdp->isp_devparam[i].sync_period = + ISP1080_NVRAM_TGT_SYNC_PERIOD(nvram_data, i, bus); + sdp->isp_devparam[i].dev_flags = 0; + if (ISP1080_NVRAM_TGT_RENEG(nvram_data, i, bus)) + sdp->isp_devparam[i].dev_flags |= DPARM_RENEG; + if (ISP1080_NVRAM_TGT_QFRZ(nvram_data, i, bus)) { + PRINTF("%s: not supporting QFRZ option " + "for target %d bus %d\n", + isp->isp_name, i, bus); + } + sdp->isp_devparam[i].dev_flags |= DPARM_ARQ; + if (ISP1080_NVRAM_TGT_ARQ(nvram_data, i, bus) == 0) { + PRINTF("%s: not disabling ARQ option " + "for target %d bus %d\n", + isp->isp_name, i, bus); + } + if (ISP1080_NVRAM_TGT_TQING(nvram_data, i, bus)) + sdp->isp_devparam[i].dev_flags |= DPARM_TQING; + if (ISP1080_NVRAM_TGT_SYNC(nvram_data, i, bus)) + sdp->isp_devparam[i].dev_flags |= DPARM_SYNC; + if (ISP1080_NVRAM_TGT_WIDE(nvram_data, i, bus)) + sdp->isp_devparam[i].dev_flags |= DPARM_WIDE; + if (ISP1080_NVRAM_TGT_PARITY(nvram_data, i, bus)) + sdp->isp_devparam[i].dev_flags |= DPARM_PARITY; + if (ISP1080_NVRAM_TGT_DISC(nvram_data, i, bus)) + sdp->isp_devparam[i].dev_flags |= DPARM_DISC; + sdp->isp_devparam[i].cur_dflags = 0; + if (isp->isp_dblev >= 3) { + PRINTF(" Target %d: Ena %d Throttle " + "%d Offset %d Period %d Flags " + "0x%x\n", i, + sdp->isp_devparam[i].dev_enable, + sdp->isp_devparam[i].exc_throttle, + sdp->isp_devparam[i].sync_offset, + sdp->isp_devparam[i].sync_period, + sdp->isp_devparam[i].dev_flags); + } + } + } + } else if (IS_SCSI(isp)) { sdparam *sdp = (sdparam *) isp->isp_param; sdp->isp_fifo_threshold = @@ -3754,10 +4151,8 @@ isp_read_nvram(isp) sdp->isp_max_queue_depth = ISP_NVRAM_MAX_QUEUE_DEPTH(nvram_data); - sdp->isp_fast_mttr = ISP_NVRAM_FAST_MTTR_ENABLE(nvram_data); + isp->isp_fast_mttr = ISP_NVRAM_FAST_MTTR_ENABLE(nvram_data); if (isp->isp_dblev > 2) { - static char *true = "true"; - static char *false = "false"; PRINTF("%s: NVRAM values:\n", isp->isp_name); PRINTF(" Fifo Threshold = 0x%x\n", sdp->isp_fifo_threshold); @@ -3776,15 +4171,15 @@ isp_read_nvram(isp) PRINTF(" Async Data Setup = 0x%x\n", sdp->isp_async_data_setup); PRINTF(" REQ/ACK Active Negation = %s\n", - sdp->isp_req_ack_active_neg? true : false); + sdp->isp_req_ack_active_neg? tru : not); PRINTF(" Data Line Active Negation = %s\n", - sdp->isp_data_line_active_neg? true : false); + sdp->isp_data_line_active_neg? tru : not); PRINTF(" Data DMA Burst Enable = %s\n", - sdp->isp_data_dma_burst_enabl? true : false); + sdp->isp_data_dma_burst_enabl? tru : not); PRINTF(" Cmd DMA Burst Enable = %s\n", - sdp->isp_cmd_dma_burst_enable? true : false); + sdp->isp_cmd_dma_burst_enable? tru : not); PRINTF(" Fast MTTR = %s\n", - sdp->isp_fast_mttr? true : false); + isp->isp_fast_mttr? tru : not); } for (i = 0; i < MAX_TARGETS; i++) { sdp->isp_devparam[i].dev_enable = @@ -3858,19 +4253,41 @@ isp_read_nvram(isp) u_int32_t lo32; u_int32_t hi32; #endif - } wds; + } wd; u_int64_t full64; } wwnstore; wwnstore.full64 = ISP2100_NVRAM_NODE_NAME(nvram_data); - PRINTF("%s: Adapter WWN 0x%08x%08x\n", isp->isp_name, - wwnstore.wds.hi32, wwnstore.wds.lo32); - fcp->isp_wwn = wwnstore.full64; + /* + * Broken PTI cards with nothing in the top nibble. Pah. + */ + if ((wwnstore.wd.hi32 >> 28) == 0) { + wwnstore.wd.hi32 |= (2 << 28); + CFGPRINTF("%s: (corrected) Adapter WWN 0x%08x%08x\n", + isp->isp_name, wwnstore.wd.hi32, wwnstore.wd.lo32); + } else { + CFGPRINTF("%s: Adapter WWN 0x%08x%08x\n", isp->isp_name, + wwnstore.wd.hi32, wwnstore.wd.lo32); + } + fcp->isp_nodewwn = wwnstore.full64; + + /* + * If the Node WWN has 2 in the top nibble, we can + * authoritatively construct a Port WWN by adding + * our unit number (plus one to make it nonzero) and + * putting it into bits 59..56. If the top nibble isn't + * 2, then we just set them identically. + */ + if ((fcp->isp_nodewwn >> 60) == 2) { + fcp->isp_portwwn = fcp->isp_nodewwn | + (((u_int64_t)(isp->isp_unit+1)) << 56); + } else { + fcp->isp_portwwn = fcp->isp_nodewwn; + } wwnstore.full64 = ISP2100_NVRAM_BOOT_NODE_NAME(nvram_data); if (wwnstore.full64 != 0) { PRINTF("%s: BOOT DEVICE WWN 0x%08x%08x\n", - isp->isp_name, wwnstore.wds.hi32, - wwnstore.wds.lo32); + isp->isp_name, wwnstore.wd.hi32, wwnstore.wd.lo32); } fcp->isp_maxalloc = ISP2100_NVRAM_MAXIOCBALLOCATION(nvram_data); @@ -3923,10 +4340,14 @@ isp_rdnvram_word(isp, wo, rp) ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT|BIU_NVRAM_CLOCK); SYS_DELAY(2); - if (isp->isp_type & ISP_HA_FC) { + if (IS_FC(isp)) { wo &= ((ISP2100_NVRAM_SIZE >> 1) - 1); rqst = (ISP_NVRAM_READ << 8) | wo; cbits = 10; + } else if (IS_1080(isp) || IS_12X0(isp)) { + wo &= ((ISP1080_NVRAM_SIZE >> 1) - 1); + rqst = (ISP_NVRAM_READ << 8) | wo; + cbits = 10; } else { wo &= ((ISP_NVRAM_SIZE >> 1) - 1); rqst = (ISP_NVRAM_READ << 6) | wo; diff --git a/sys/dev/ic/isp_inline.h b/sys/dev/ic/isp_inline.h new file mode 100644 index 00000000000..8846e504b53 --- /dev/null +++ b/sys/dev/ic/isp_inline.h @@ -0,0 +1,278 @@ +/* $OpenBSD: isp_inline.h,v 1.1 1999/11/22 12:50:53 mjacob Exp $ */ +/* + * Qlogic Inline Functions + * + *--------------------------------------- + * Copyright (c) 1999 by Matthew Jacob + * Feral Software + * All rights reserved. + * mjacob@feral.com + *--------------------------------------- + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice immediately at the beginning of the file, without modification, + * this list of conditions, and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ +#ifndef _ISP_INLINE_H +#define _ISP_INLINE_H + +static INLINE void isp_prtstst __P((ispstatusreq_t *)); +static INLINE char *isp2100_fw_statename __P((int)); +static INLINE char *isp2100_pdb_statename __P((int)); + + +static INLINE void +isp_prtstst(sp) + ispstatusreq_t *sp; +{ + char *p, buf[172]; + sprintf(p, "states->"); + if (sp->req_state_flags & RQSF_GOT_BUS) { + p += strlen(p); + sprintf(p, "%s%s", buf, "GOT_BUS "); + } + if (sp->req_state_flags & RQSF_GOT_TARGET) { + p += strlen(p); + sprintf(p, "%s%s", buf, "GOT_TGT "); + } + if (sp->req_state_flags & RQSF_SENT_CDB) { + p += strlen(p); + sprintf(p, "%s%s", buf, "SENT_CDB "); + } + if (sp->req_state_flags & RQSF_XFRD_DATA) { + p += strlen(p); + sprintf(p, "%s%s", buf, "XFRD_DATA "); + } + if (sp->req_state_flags & RQSF_GOT_STATUS) { + p += strlen(p); + sprintf(p, "%s%s", buf, "GOT_STS "); + } + if (sp->req_state_flags & RQSF_GOT_SENSE) { + p += strlen(p); + sprintf(p, "%s%s", buf, "GOT_SNS "); + } + if (sp->req_state_flags & RQSF_XFER_COMPLETE) { + p += strlen(p); + sprintf(p, "%s%s", buf, "XFR_CMPLT "); + } + p += strlen(p); + sprintf(p, "%s%s", buf, "\n"); + p += strlen(p); + sprintf(p, "%s%s", buf, "status->"); + if (sp->req_status_flags & RQSTF_DISCONNECT) { + p += strlen(p); + sprintf(p, "%s%s", buf, "Disconnect "); + } + if (sp->req_status_flags & RQSTF_SYNCHRONOUS) { + p += strlen(p); + sprintf(p, "%s%s", buf, "Sync_xfr "); + } + if (sp->req_status_flags & RQSTF_PARITY_ERROR) { + p += strlen(p); + sprintf(p, "%s%s", buf, "Parity "); + } + if (sp->req_status_flags & RQSTF_BUS_RESET) { + p += strlen(p); + sprintf(p, "%s%s", buf, "Bus_Reset "); + } + if (sp->req_status_flags & RQSTF_DEVICE_RESET) { + p += strlen(p); + sprintf(p, "%s%s", buf, "Device_Reset "); + } + if (sp->req_status_flags & RQSTF_ABORTED) { + p += strlen(p); + sprintf(p, "%s%s", buf, "Aborted "); + } + if (sp->req_status_flags & RQSTF_TIMEOUT) { + p += strlen(p); + sprintf(p, "%s%s", buf, "Timeout "); + } + if (sp->req_status_flags & RQSTF_NEGOTIATION) { + p += strlen(p); + sprintf(p, "%s%s", buf, "Negotiation "); + } + PRINTF(buf, "%s\n", buf); +} + +static INLINE char * +isp2100_fw_statename(state) + int state; +{ + static char buf[16]; + switch(state) { + case FW_CONFIG_WAIT: return "Config Wait"; + case FW_WAIT_AL_PA: return "Waiting for AL_PA"; + case FW_WAIT_LOGIN: return "Wait Login"; + case FW_READY: return "Ready"; + case FW_LOSS_OF_SYNC: return "Loss Of Sync"; + case FW_ERROR: return "Error"; + case FW_REINIT: return "Re-Init"; + case FW_NON_PART: return "Nonparticipating"; + default: + sprintf(buf, "0x%x", state); + return buf; + } +} + +static INLINE char *isp2100_pdb_statename(int pdb_state) +{ + static char buf[16]; + switch(pdb_state) { + case PDB_STATE_DISCOVERY: return "Port Discovery"; + case PDB_STATE_WDISC_ACK: return "Waiting Port Discovery ACK"; + case PDB_STATE_PLOGI: return "Port Login"; + case PDB_STATE_PLOGI_ACK: return "Wait Port Login ACK"; + case PDB_STATE_PRLI: return "Process Login"; + case PDB_STATE_PRLI_ACK: return "Wait Process Login ACK"; + case PDB_STATE_LOGGED_IN: return "Logged In"; + case PDB_STATE_PORT_UNAVAIL: return "Port Unavailable"; + case PDB_STATE_PRLO: return "Process Logout"; + case PDB_STATE_PRLO_ACK: return "Wait Process Logout ACK"; + case PDB_STATE_PLOGO: return "Port Logout"; + case PDB_STATE_PLOG_ACK: return "Wait Port Logout ACK"; + default: + sprintf(buf, "0x%x", pdb_state); + return buf; + } +} + +/* + * Handle Functions. + * For each outstanding command there will be a non-zero handle. + * There will be at most isp_maxcmds handles, and isp_lasthdls + * will be a seed for the last handled allocated. + */ + +static INLINE int +isp_save_xs __P((struct ispsoftc *, ISP_SCSI_XFER_T *, u_int32_t *)); + +static INLINE ISP_SCSI_XFER_T * +isp_find_xs __P((struct ispsoftc *, u_int32_t)); + +static INLINE u_int32_t +isp_find_handle __P((struct ispsoftc *, ISP_SCSI_XFER_T *)); + +static INLINE void +isp_destroy_handle __P((struct ispsoftc *, u_int32_t)); + +static INLINE void +isp_remove_handle __P((struct ispsoftc *, ISP_SCSI_XFER_T *)); + +static INLINE int +isp_save_xs(isp, xs, handlep) + struct ispsoftc *isp; + ISP_SCSI_XFER_T *xs; + u_int32_t *handlep; +{ + int i, j; + + for (j = isp->isp_lasthdls, i = 0; i < (int) isp->isp_maxcmds; i++) { + if (isp->isp_xflist[j] == NULL) { + break; + } + if (++j == isp->isp_maxcmds) { + j = 0; + } + } + if (i == isp->isp_maxcmds) { + return (-1); + } + isp->isp_xflist[j] = xs; + *handlep = j+1; + if (++j == isp->isp_maxcmds) + j = 0; + isp->isp_lasthdls = j; + return (0); +} + +static INLINE ISP_SCSI_XFER_T * +isp_find_xs(isp, handle) + struct ispsoftc *isp; + u_int32_t handle; +{ + if (handle < 1 || handle > (u_int32_t) isp->isp_maxcmds) { + return (NULL); + } else { + return (isp->isp_xflist[handle - 1]); + } +} + +static INLINE u_int32_t +isp_find_handle(isp, xs) + struct ispsoftc *isp; + ISP_SCSI_XFER_T *xs; +{ + int i; + if (xs != NULL) { + for (i = 0; i < isp->isp_maxcmds; i++) { + if (isp->isp_xflist[i] == xs) { + return ((u_int32_t) i+1); + } + } + } + return (0); +} + +static INLINE void +isp_destroy_handle(isp, handle) + struct ispsoftc *isp; + u_int32_t handle; +{ + if (handle > 0 && handle <= (u_int32_t) isp->isp_maxcmds) { + isp->isp_xflist[handle - 1] = NULL; + } +} + +static INLINE void +isp_remove_handle(isp, xs) + struct ispsoftc *isp; + ISP_SCSI_XFER_T *xs; +{ + isp_destroy_handle(isp, isp_find_handle(isp, xs)); +} + +static INLINE int +isp_getrqentry __P((struct ispsoftc *, u_int16_t *, u_int16_t *, void **)); + +static INLINE int +isp_getrqentry(isp, iptrp, optrp, resultp) + struct ispsoftc *isp; + u_int16_t *iptrp; + u_int16_t *optrp; + void **resultp; +{ + volatile u_int16_t iptr, optr; + + optr = isp->isp_reqodx = ISP_READ(isp, OUTMAILBOX4); + iptr = isp->isp_reqidx; + *resultp = ISP_QUEUE_ENTRY(isp->isp_rquest, iptr); + iptr = ISP_NXT_QENTRY(iptr, RQUEST_QUEUE_LEN); + if (iptr == optr) { + return (1); + } + *optrp = optr; + *iptrp = iptr; + return (0); +} +#endif /* _ISP_INLINE_H */ diff --git a/sys/dev/ic/isp_openbsd.c b/sys/dev/ic/isp_openbsd.c index 7cbeaef9749..71b8f526dbe 100644 --- a/sys/dev/ic/isp_openbsd.c +++ b/sys/dev/ic/isp_openbsd.c @@ -1,5 +1,4 @@ -/* $OpenBSD: isp_openbsd.c,v 1.3 1999/03/25 22:58:38 mjacob Exp $ */ -/* release_03_25_99 */ +/* $OpenBSD: isp_openbsd.c,v 1.4 1999/11/22 12:50:53 mjacob Exp $ */ /* * Platform (OpenBSD) dependent common attachment code for Qlogic adapters. * @@ -42,29 +41,28 @@ * * Matthew Jacob * Feral Software - * 2339 3rd Street - * Suite 24 - * San Francisco, CA, 94107 + * PMB#825 + * 5214-F Diamond Heights Blvd. + * San Francisco, CA, 94131 */ #include <dev/ic/isp_openbsd.h> static void ispminphys __P((struct buf *)); +static int32_t ispcmd_slow __P((ISP_SCSI_XFER_T *)); static int32_t ispcmd __P((ISP_SCSI_XFER_T *)); static struct scsi_device isp_dev = { NULL, NULL, NULL, NULL }; static int isp_poll __P((struct ispsoftc *, ISP_SCSI_XFER_T *, int)); static void isp_watch __P((void *)); +static void isp_command_requeue(void *); +static void isp_internal_restart(void *); struct cfdriver isp_cd = { NULL, "isp", DV_DULL }; -#define FC_OPENINGS RQUEST_QUEUE_LEN / (MAX_FC_TARG-1) -#define PI_OPENINGS RQUEST_QUEUE_LEN / (MAX_TARGETS-1) -#define DTHR 1 - /* * Complete attachment of hardware, include subdevices. */ @@ -72,7 +70,6 @@ void isp_attach(isp) struct ispsoftc *isp; { - isp->isp_osinfo._adapter.scsi_cmd = ispcmd; isp->isp_osinfo._adapter.scsi_minphys = ispminphys; isp->isp_state = ISP_RUNSTATE; @@ -86,23 +83,23 @@ isp_attach(isp) isp->isp_osinfo._link.adapter_softc = isp; isp->isp_osinfo._link.device = &isp_dev; isp->isp_osinfo._link.adapter = &isp->isp_osinfo._adapter; + isp->isp_osinfo._link.openings = isp->isp_maxcmds; + isp->isp_osinfo.wqf = isp->isp_osinfo.wqt = NULL; /* XXX 2nd Bus? */ - if (isp->isp_type & ISP_HA_FC) { - isp->isp_osinfo._link.openings = FC_OPENINGS; + if (IS_FC(isp)) { + isp->isp_osinfo._adapter.scsi_cmd = ispcmd; isp->isp_osinfo._link.adapter_buswidth = MAX_FC_TARG; /* We can set max lun width here */ - isp->isp_osinfo._link.adapter_target = - ((fcparam *)isp->isp_param)->isp_loopid; + /* loopid set below */ } else { - isp->isp_osinfo.delay_throttle_count = DTHR; - isp->isp_osinfo._link.openings = PI_OPENINGS; + sdparam *sdp = isp->isp_param; + isp->isp_osinfo._adapter.scsi_cmd = ispcmd_slow; isp->isp_osinfo._link.adapter_buswidth = MAX_TARGETS; /* We can set max lun width here */ isp->isp_osinfo._link.adapter_target = - ((sdparam *)isp->isp_param)->isp_initiator_id; + sdp->isp_initiator_id; + isp->isp_osinfo.discovered[0] = 1 << sdp->isp_initiator_id; } - if (isp->isp_osinfo._link.openings < 2) - isp->isp_osinfo._link.openings = 2; /* * Send a SCSI Bus Reset (used to be done as part of attach, @@ -114,17 +111,57 @@ isp_attach(isp) * XXX: that async events happen. */ if (IS_SCSI(isp)) { - (void) isp_control(isp, ISPCTL_RESET_BUS, NULL); + int bus = 0; + (void) isp_control(isp, ISPCTL_RESET_BUS, &bus); + if (IS_12X0(isp)) { + bus++; + (void) isp_control(isp, ISPCTL_RESET_BUS, &bus); + } /* - * Wait for it to settle. + * wait for the bus to settle. */ + printf("%s: waiting 2 seconds for bus reset settling\n", + isp->isp_name); delay(2 * 1000000); + } else { + int i, j; + fcparam *fcp = isp->isp_param; + /* + * wait for the loop to settle. + */ + printf("%s: waiting 2 seconds for loop reset settling\n", + isp->isp_name); + delay(2 * 1000000); + for (j = 0; j < 5; j++) { + for (i = 0; i < 5; i++) { + if (isp_control(isp, ISPCTL_FCLINK_TEST, NULL)) + continue; +#ifdef ISP2100_FABRIC + /* + * Wait extra time to see if the f/w + * eventually completed an FLOGI that + * will allow us to know we're on a + * fabric. + */ + if (fcp->isp_onfabric == 0) { + delay(1 * 1000000); + continue; + } +#endif + break; + } + if (fcp->isp_fwstate == FW_READY && + fcp->isp_loopstate >= LOOP_PDB_RCVD) { + break; + } + } + isp->isp_osinfo._link.adapter_target = fcp->isp_loopid; } /* * Start the watchdog. * - * The wathdog will, ridiculously enough, also enable Sync negotiation. + * The watchdog will, ridiculously enough, also enable Sync negotiation. */ isp->isp_dogactive = 1; timeout(isp_watch, isp, WATCH_INTERVAL * hz); @@ -156,7 +193,87 @@ ispminphys(bp) minphys(bp); } -static int +static int32_t +ispcmd_slow(xs) + ISP_SCSI_XFER_T *xs; +{ + sdparam *sdp; + int tgt, chan; + u_int16_t f; + struct ispsoftc *isp = XS_ISP(xs); + + /* + * Have we completed discovery for this target on this adapter? + */ + sdp = isp->isp_param; + sdp += chan; + tgt = XS_TGT(xs); + chan = XS_CHANNEL(xs); + if ((xs->flags & SCSI_POLL) != 0 || + (isp->isp_osinfo.discovered[chan] & (1 << tgt)) != 0) { + return (ispcmd(xs)); + } + + f = DPARM_DEFAULT; + if (xs->sc_link->quirks & SDEV_NOSYNCWIDE) { + f ^= DPARM_SYNC; + f ^= DPARM_WIDE; +#ifdef DEBUG + } else { + printf("%s: channel %d target %d can do SYNC xfers\n", + isp->isp_name, chan, tgt); + printf("%s: channel %d target %d can do WIDE xfers\n", + isp->isp_name, chan, tgt); +#endif + } + if (xs->sc_link->quirks & SDEV_NOTAGS) { + f ^= DPARM_TQING; +#ifdef DEBUG + } else { + printf("%s: channel %d target %d can do TAGGED xfers\n", + isp->isp_name, chan, tgt); +#endif + } + + /* + * Okay, we know about this device now, + * so mark parameters to be updated for it. + */ + sdp->isp_devparam[tgt].dev_flags = f; + sdp->isp_devparam[tgt].dev_update = 1; + isp->isp_update |= 1 << chan; + + /* + * Now check to see whether we can get out of this checking mode now. + * XXX: WE CANNOT AS YET BECAUSE THERE IS NO MECHANISM TO TELL US + * XXX: WHEN WE'RE DONE DISCOVERY BECAUSE WE NEED ONE COMMAND AFTER + * XXX: DISCOVERY IS DONE FOR EACH TARGET TO TELL US THAT WE'RE DONE + * XXX: AND THAT DOESN'T HAPPEN HERE. AT BEST WE CAN MARK OURSELVES + * XXX: DONE WITH DISCOVERY FOR THIS TARGET AND SO SAVE MAYBE 20 + * XXX: LINES OF C CODE. + */ + isp->isp_osinfo.discovered[chan] |= (1 << tgt); + /* do not bother with these lines- they'll never execute correctly */ +#if 0 + sdp = isp->isp_param; + for (chan = 0; chan < (IS_12X0(isp)? 2 : 1); chan++, sdp++) { + f = 0xffff & ~(1 << sdp->isp_initiator_id); + if (isp->isp_osinfo.discovered[chan] != f) { + break; + } + } + if (chan == (IS_12X0(isp)? 2 : 1)) { + CFGPRINTF("%s: allowing sync/wide negotiation and " + "tag usage\n", isp->isp_name); + isp->isp_osinfo._adapter.scsipi_cmd = ispcmd; + if (IS_12X0(isp)) + isp->isp_update |= 2; + } +#endif + return (ispcmd(xs)); +} + +static int32_t ispcmd(xs) ISP_SCSI_XFER_T *xs; { @@ -179,34 +296,89 @@ ispcmd(xs) isp->isp_state = ISP_RUNSTATE; ENABLE_INTS(isp); } + + /* + * Check for queue blockage... + */ + if (isp->isp_osinfo.blocked) { + if (xs->flags & SCSI_POLL) { + xs->error = XS_DRIVER_STUFFUP; + splx(s); + return (TRY_AGAIN_LATER); + } + if (isp->isp_osinfo.wqf != NULL) { + isp->isp_osinfo.wqt->free_list.le_next = xs; + } else { + isp->isp_osinfo.wqf = xs; + } + isp->isp_osinfo.wqt = xs; + xs->free_list.le_next = NULL; + splx(s); + return (SUCCESSFULLY_QUEUED); + } DISABLE_INTS(isp); result = ispscsicmd(xs); ENABLE_INTS(isp); - if (result != CMD_QUEUED || (xs->flags & SCSI_POLL) == 0) { + + if ((xs->flags & SCSI_POLL) == 0) { + switch (result) { + case CMD_QUEUED: + result = SUCCESSFULLY_QUEUED; + break; + case CMD_EAGAIN: + result = TRY_AGAIN_LATER; + break; + case CMD_RQLATER: + result = SUCCESSFULLY_QUEUED; + timeout(isp_command_requeue, xs, hz); + break; + case CMD_COMPLETE: + result = COMPLETE; + break; + } (void) splx(s); return (result); } + switch (result) { + case CMD_QUEUED: + result = SUCCESSFULLY_QUEUED; + break; + case CMD_RQLATER: + case CMD_EAGAIN: + if (XS_NOERR(xs)) { + xs->error = XS_DRIVER_STUFFUP; + } + result = TRY_AGAIN_LATER; + break; + case CMD_COMPLETE: + result = COMPLETE; + break; + + } + /* - * If we can't use interrupts, poll on completion. + * We can't use interrupts so poll on completion. */ - if (isp_poll(isp, xs, xs->timeout)) { - /* - * If no other error occurred but we didn't finish, - * something bad happened. - */ - if ((xs->flags & ITSDONE) == 0) { - isp->isp_nactive--; - if (isp->isp_nactive < 0) - isp->isp_nactive = 0; - if (xs->error == XS_NOERROR) { - isp_lostcmd(isp, xs); - xs->error = XS_DRIVER_STUFFUP; + if (result == SUCCESSFULLY_QUEUED) { + if (isp_poll(isp, xs, xs->timeout)) { + /* + * If no other error occurred but we didn't finish, + * something bad happened. + */ + if (XS_IS_CMD_DONE(xs) == 0) { + if (isp_control(isp, ISPCTL_ABORT_CMD, xs)) { + isp_restart(isp); + } + if (XS_NOERR(xs)) { + XS_SETERR(xs, HBA_BOTCH); + } } } + result = COMPLETE; } (void) splx(s); - return (COMPLETE); + return (result); } static int @@ -237,20 +409,22 @@ isp_watch(arg) { int i; struct ispsoftc *isp = arg; - ISP_SCSI_XFER_T *xs; - int s = splbio(); + struct scsi_xfer *xs; + int s; /* - * Look for completely dead commands. + * Look for completely dead commands (but not polled ones). */ - for (i = 0; i < RQUEST_QUEUE_LEN; i++) { - if ((xs = (ISP_SCSI_XFER_T *) isp->isp_xflist[i]) == NULL) { + s = splbio(); + for (i = 0; i < isp->isp_maxcmds; i++) { + if ((xs = (struct scsi_xfer *) isp->isp_xflist[i]) == NULL) { continue; } - if (XS_TIME(xs) == 0) { + if (xs->timeout == 0 || (xs->flags & SCSI_POLL)) { continue; } - XS_TIME(xs) -= (WATCH_INTERVAL * 1000); + xs->timeout -= (WATCH_INTERVAL * 1000); + /* * Avoid later thinking that this * transaction is not being timed. @@ -262,9 +436,6 @@ isp_watch(arg) } else if (xs->timeout > -(2 * WATCH_INTERVAL * 1000)) { continue; } - if (IS_SCSI(isp)) { - isp->isp_osinfo.delay_throttle_count = DTHR; - } if (isp_control(isp, ISPCTL_ABORT_CMD, xs)) { printf("%s: isp_watch failed to abort command\n", isp->isp_name); @@ -272,21 +443,9 @@ isp_watch(arg) break; } } - - if (isp->isp_osinfo.delay_throttle_count) { - if (--isp->isp_osinfo.delay_throttle_count == 0) { - sdparam *sdp = isp->isp_param; - for (i = 0; i < MAX_TARGETS; i++) { - sdp->isp_devparam[i].dev_flags |= - DPARM_WIDE|DPARM_SYNC|DPARM_TQING; - sdp->isp_devparam[i].dev_update = 1; - } - isp->isp_update = 1; - } - } - timeout(isp_watch, isp, WATCH_INTERVAL * hz); + timeout(isp_watch, isp, WATCH_INTERVAL * hz); isp->isp_dogactive = 1; - (void) splx(s); + splx(s); } /* @@ -317,140 +476,235 @@ isp_uninit(isp) splx(s); } +/* + * Restart function for a command to be requeued later. + */ +static void +isp_command_requeue(void *arg) +{ + struct scsi_xfer *xs = arg; + struct ispsoftc *isp = XS_ISP(xs); + int s = splbio(); + switch (ispcmd_slow(xs)) { + case SUCCESSFULLY_QUEUED: + printf("%s: isp_command_reque: queued %d.%d\n", + isp->isp_name, XS_TGT(xs), XS_LUN(xs)); + break; + case TRY_AGAIN_LATER: + printf("%s: EAGAIN for %d.%d\n", + isp->isp_name, XS_TGT(xs), XS_LUN(xs)); + /* FALLTHROUGH */ + case COMPLETE: + /* can only be an error */ + if (XS_NOERR(xs)) + XS_SETERR(xs, XS_DRIVER_STUFFUP); + XS_CMD_DONE(xs); + break; + } + (void) splx(s); +} + +/* + * Restart function after a LOOP UP event (e.g.), + * done as a timeout for some hysteresis. + */ +static void +isp_internal_restart(void *arg) +{ + struct ispsoftc *isp = arg; + int result, nrestarted = 0, s; + + s = splbio(); + if (isp->isp_osinfo.blocked == 0) { + struct scsi_xfer *xs; + while ((xs = isp->isp_osinfo.wqf) != NULL) { + isp->isp_osinfo.wqf = xs->free_list.le_next; + xs->free_list.le_next = NULL; + DISABLE_INTS(isp); + result = ispscsicmd(xs); + ENABLE_INTS(isp); + if (result != CMD_QUEUED) { + printf("%s: botched command restart (0x%x)\n", + isp->isp_name, result); + if (XS_NOERR(xs)) + XS_SETERR(xs, XS_DRIVER_STUFFUP); + XS_CMD_DONE(xs); + } + nrestarted++; + } + printf("%s: requeued %d commands\n", isp->isp_name, nrestarted); + } + (void) splx(s); +} + int isp_async(isp, cmd, arg) struct ispsoftc *isp; ispasync_t cmd; void *arg; { + int bus, tgt; int s = splbio(); switch (cmd) { case ISPASYNC_NEW_TGT_PARAMS: - if (IS_SCSI(isp)) { - sdparam *sdp = isp->isp_param; - char *wt; - int mhz, flags, tgt, period; - - tgt = *((int *) arg); - - flags = sdp->isp_devparam[tgt].cur_dflags; - period = sdp->isp_devparam[tgt].cur_period; - if ((flags & DPARM_SYNC) && period && - (sdp->isp_devparam[tgt].cur_offset) != 0) { - if (sdp->isp_lvdmode) { - switch (period) { - case 0xa: - mhz = 40; - break; - case 0xb: - mhz = 33; - break; - case 0xc: - mhz = 25; - break; - default: - mhz = 1000 / (period * 4); - break; - } - } else { + if (IS_SCSI(isp) && isp->isp_dblev) { + sdparam *sdp = isp->isp_param; + char *wt; + int mhz, flags, period; + + tgt = *((int *) arg); + bus = (tgt >> 16) & 0xffff; + tgt &= 0xffff; + + flags = sdp->isp_devparam[tgt].cur_dflags; + period = sdp->isp_devparam[tgt].cur_period; + if ((flags & DPARM_SYNC) && period && + (sdp->isp_devparam[tgt].cur_offset) != 0) { + if (sdp->isp_lvdmode) { + switch (period) { + case 0xa: + mhz = 40; + break; + case 0xb: + mhz = 33; + break; + case 0xc: + mhz = 25; + break; + default: mhz = 1000 / (period * 4); + break; } } else { - mhz = 0; - } - switch (flags & (DPARM_WIDE|DPARM_TQING)) { - case DPARM_WIDE: - wt = ", 16 bit wide\n"; - break; - case DPARM_TQING: - wt = ", Tagged Queueing Enabled\n"; - break; - case DPARM_WIDE|DPARM_TQING: - wt = ", 16 bit wide, Tagged Queueing Enabled\n"; - break; - default: - wt = "\n"; - break; - } - if (mhz) { - printf("%s: Target %d at %dMHz Max Offset %d%s", - isp->isp_name, tgt, mhz, - sdp->isp_devparam[tgt].cur_offset, wt); - } else { - printf("%s: Target %d Async Mode%s", - isp->isp_name, tgt, wt); + mhz = 1000 / (period * 4); } + } else { + mhz = 0; + } + switch (flags & (DPARM_WIDE|DPARM_TQING)) { + case DPARM_WIDE: + wt = ", 16 bit wide\n"; + break; + case DPARM_TQING: + wt = ", Tagged Queueing Enabled\n"; + break; + case DPARM_WIDE|DPARM_TQING: + wt = ", 16 bit wide, Tagged Queueing Enabled\n"; + break; + default: + wt = "\n"; + break; + } + if (mhz) { + CFGPRINTF("%s: Bus %d Target %d at %dMHz Max " + "Offset %d%s", isp->isp_name, bus, tgt, mhz, + sdp->isp_devparam[tgt].cur_offset, wt); + } else { + CFGPRINTF("%s: Bus %d Target %d Async Mode%s", + isp->isp_name, bus, tgt, wt); } break; + } case ISPASYNC_BUS_RESET: - printf("%s: SCSI bus reset detected\n", isp->isp_name); + if (arg) + bus = *((int *) arg); + else + bus = 0; + printf("%s: SCSI bus %d reset detected\n", isp->isp_name, bus); break; case ISPASYNC_LOOP_DOWN: + /* + * Hopefully we get here in time to minimize the number + * of commands we are firing off that are sure to die. + */ + isp->isp_osinfo.blocked = 1; printf("%s: Loop DOWN\n", isp->isp_name); break; - case ISPASYNC_LOOP_UP: + case ISPASYNC_LOOP_UP: + isp->isp_osinfo.blocked = 0; + timeout(isp_internal_restart, isp, 1); printf("%s: Loop UP\n", isp->isp_name); break; - case ISPASYNC_PDB_CHANGE_COMPLETE: -#if 0 - if (isp->isp_type & ISP_HA_FC) { - int i; - static char *roles[4] = { + case ISPASYNC_PDB_CHANGED: + if (IS_FC(isp) && isp->isp_dblev) { + const char *fmt = "%s: Target %d (Loop 0x%x) Port ID 0x%x " + "role %s %s\n Port WWN 0x%08x%08x\n Node WWN 0x%08x%08x\n"; + const static char *roles[4] = { "No", "Target", "Initiator", "Target/Initiator" }; - for (i = 0; i < MAX_FC_TARG; i++) { - isp_pdb_t *pdbp = - &((fcparam *)isp->isp_param)->isp_pdb[i]; - if (pdbp->pdb_options == INVALID_PDB_OPTIONS) - continue; - printf("%s: Loop ID %d, %s role\n", - isp->isp_name, pdbp->pdb_loopid, - roles[(pdbp->pdb_prli_svc3 >> 4) & 0x3]); - printf(" Node Address 0x%x WWN 0x" - "%02x%02x%02x%02x%02x%02x%02x%02x\n", - BITS2WORD(pdbp->pdb_portid_bits), - pdbp->pdb_portname[0], pdbp->pdb_portname[1], - pdbp->pdb_portname[2], pdbp->pdb_portname[3], - pdbp->pdb_portname[4], pdbp->pdb_portname[5], - pdbp->pdb_portname[6], pdbp->pdb_portname[7]); - if (pdbp->pdb_options & PDB_OPTIONS_ADISC) - printf(" Hard Address 0x%x WWN 0x" - "%02x%02x%02x%02x%02x%02x%02x%02x\n", - BITS2WORD(pdbp->pdb_hardaddr_bits), - pdbp->pdb_nodename[0], - pdbp->pdb_nodename[1], - pdbp->pdb_nodename[2], - pdbp->pdb_nodename[3], - pdbp->pdb_nodename[4], - pdbp->pdb_nodename[5], - pdbp->pdb_nodename[6], - pdbp->pdb_nodename[7]); - switch (pdbp->pdb_prli_svc3 & SVC3_ROLE_MASK) { - case SVC3_TGT_ROLE|SVC3_INI_ROLE: - printf(" Master State=%s, Slave State=%s\n", - isp2100_pdb_statename(pdbp->pdb_mstate), - isp2100_pdb_statename(pdbp->pdb_sstate)); - break; - case SVC3_TGT_ROLE: - printf(" Master State=%s\n", - isp2100_pdb_statename(pdbp->pdb_mstate)); - break; - case SVC3_INI_ROLE: - printf(" Slave State=%s\n", - isp2100_pdb_statename(pdbp->pdb_sstate)); - break; - default: - break; - } + char *ptr; + fcparam *fcp = isp->isp_param; + int tgt = *((int *) arg); + struct lportdb *lp = &fcp->portdb[tgt]; + + if (lp->valid) { + ptr = "arrived"; + } else { + ptr = "disappeared"; } + printf(fmt, isp->isp_name, tgt, lp->loopid, lp->portid, + roles[lp->roles & 0x3], ptr, + (u_int32_t) (lp->port_wwn >> 32), + (u_int32_t) (lp->port_wwn & 0xffffffffLL), + (u_int32_t) (lp->node_wwn >> 32), + (u_int32_t) (lp->node_wwn & 0xffffffffLL)); break; } -#else - break; -#endif +#ifdef ISP2100_FABRIC case ISPASYNC_CHANGE_NOTIFY: printf("%s: Name Server Database Changed\n", isp->isp_name); break; + case ISPASYNC_FABRIC_DEV: + { + int target; + struct lportdb *lp; + sns_scrsp_t *resp = (sns_scrsp_t *) arg; + u_int32_t portid; + u_int64_t wwn; + fcparam *fcp = isp->isp_param; + + portid = + (((u_int32_t) resp->snscb_port_id[0]) << 16) | + (((u_int32_t) resp->snscb_port_id[1]) << 8) | + (((u_int32_t) resp->snscb_port_id[2])); + wwn = + (((u_int64_t)resp->snscb_portname[0]) << 56) | + (((u_int64_t)resp->snscb_portname[1]) << 48) | + (((u_int64_t)resp->snscb_portname[2]) << 40) | + (((u_int64_t)resp->snscb_portname[3]) << 32) | + (((u_int64_t)resp->snscb_portname[4]) << 24) | + (((u_int64_t)resp->snscb_portname[5]) << 16) | + (((u_int64_t)resp->snscb_portname[6]) << 8) | + (((u_int64_t)resp->snscb_portname[7])); + printf("%s: Fabric Device (Type 0x%x)@PortID 0x%x WWN " + "0x%08x%08x\n", isp->isp_name, resp->snscb_port_type, + portid, ((u_int32_t)(wwn >> 32)), + ((u_int32_t)(wwn & 0xffffffff))); + if (resp->snscb_port_type != 2) + break; + for (target = FC_SNS_ID+1; target < MAX_FC_TARG; target++) { + lp = &fcp->portdb[target]; + if (lp->port_wwn == wwn) + break; + } + if (target < MAX_FC_TARG) { + break; + } + for (target = FC_SNS_ID+1; target < MAX_FC_TARG; target++) { + lp = &fcp->portdb[target]; + if (lp->port_wwn == 0) + break; + } + if (target == MAX_FC_TARG) { + printf("%s: no more space for fabric devices\n", + isp->isp_name); + return (-1); + } + lp->port_wwn = lp->node_wwn = wwn; + lp->portid = portid; + break; + } +#endif default: break; } diff --git a/sys/dev/ic/isp_openbsd.h b/sys/dev/ic/isp_openbsd.h index 777eb04f971..3f37060920e 100644 --- a/sys/dev/ic/isp_openbsd.h +++ b/sys/dev/ic/isp_openbsd.h @@ -1,5 +1,4 @@ -/* $OpenBSD: isp_openbsd.h,v 1.3 1999/03/25 22:58:38 mjacob Exp $ */ -/* release_03_25_99 */ +/* $OpenBSD: isp_openbsd.h,v 1.4 1999/11/22 12:50:53 mjacob Exp $ */ /* * OpenBSD Specific definitions for the Qlogic ISP Host Adapter * @@ -49,6 +48,7 @@ #include <sys/buf.h> #include <sys/proc.h> #include <sys/user.h> +#include <sys/queue.h> #include <scsi/scsi_all.h> @@ -63,24 +63,36 @@ #include <vm/pmap.h> #define ISP_PLATFORM_VERSION_MAJOR 0 -#define ISP_PLATFORM_VERSION_MINOR 2 +#define ISP_PLATFORM_VERSION_MINOR 5 #define ISP_SCSI_XFER_T struct scsi_xfer struct isposinfo { struct device _dev; struct scsi_link _link; struct scsi_adapter _adapter; - int8_t delay_throttle_count; + int blocked; + union { + int _seed; + u_int16_t _discovered[2]; + } un; +#define seed un._seed +#define discovered un._discovered + struct scsi_xfer *wqf, *wqt; }; #define MAXISPREQUEST 64 +#ifdef ISP2100_FABRIC +#define ISP2100_SCRLEN 0x400 +#else +#define ISP2100_SCRLEN 0x100 +#endif #include <dev/ic/ispreg.h> #include <dev/ic/ispvar.h> #include <dev/ic/ispmbox.h> -#define PRINTF printf #define IDPRINTF(lev, x) if (isp->isp_dblev >= lev) printf x +#define PRINTF printf #define MEMZERO bzero #define MEMCPY(dst, src, count) bcopy((src), (dst), (count)) @@ -91,14 +103,21 @@ struct isposinfo { #define MemoryBarrier() #endif +#define DMA_MSW(x) (((x) >> 16) & 0xffff) +#define DMA_LSW(x) (((x) & 0xffff)) + #if defined(SCSIDEBUG) #define DFLT_DBLEVEL 3 -#else -#if defined(DEBUG) +#define CFGPRINTF printf +#elif defined(DIAGNOSTIC) +#define DFLT_DBLEVEL 1 +#define CFGPRINTF printf +#elif defined(DEBUG) #define DFLT_DBLEVEL 2 +#define CFGPRINTF printf #else -#define DFLT_DBLEVEL 1 -#endif +#define DFLT_DBLEVEL 0 +#define CFGPRINTF if (0) printf #endif #define ISP_LOCKVAL_DECL int isp_spl_save @@ -114,9 +133,10 @@ struct isposinfo { #define XS_LUN(xs) ((int) (xs)->sc_link->lun) #define XS_TGT(xs) ((int) (xs)->sc_link->target) #define XS_RESID(xs) (xs)->resid +#define XS_CHANNEL(xs) 0 /* only one channel supported */ #define XS_XFRLEN(xs) (xs)->datalen #define XS_CDBLEN(xs) (xs)->cmdlen -#define XS_CDBP(xs) (xs)->cmd +#define XS_CDBP(xs) ((caddr_t) (xs)->cmd) #define XS_STS(xs) (xs)->status #define XS_TIME(xs) (xs)->timeout #define XS_SNSP(xs) (&(xs)->sense) @@ -156,118 +176,47 @@ struct isposinfo { /* * This is our default tag (ordered). */ -#define XS_KINDOF_TAG(xs) REQFLAG_STAG +#define XS_KINDOF_TAG(xs) REQFLAG_OTAG -#define CMD_COMPLETE COMPLETE -#define CMD_EAGAIN TRY_AGAIN_LATER -#define CMD_QUEUED SUCCESSFULLY_QUEUED +#define CMD_COMPLETE 100 +#define CMD_EAGAIN 101 +#define CMD_QUEUED 102 +#define CMD_RQLATER 103 #define isp_name isp_osinfo._dev.dv_xname +#define isp_unit isp_osinfo._dev.dv_unit -#define FC_FW_READY_DELAY (12 * 1000000) +#define SCSI_QFULL 0x28 #define SYS_DELAY(x) delay(x) -#define WATCH_INTERVAL 10 +#define WATCH_INTERVAL 30 + +#define FC_FW_READY_DELAY (5 * 1000000) +#define DEFAULT_LOOPID(x) 107 +#define DEFAULT_WWN(x) (0x1000b00d00000000LL + (x)->isp_osinfo.seed) extern void isp_attach __P((struct ispsoftc *)); extern void isp_uninit __P((struct ispsoftc *)); -static inline void isp_prtstst __P((ispstatusreq_t *)); -static inline const char *isp2100_fw_statename __P((int)); -static inline const char * isp2100_pdb_statename __P((int)); - -static inline void -isp_prtstst(sp) - ispstatusreq_t *sp; -{ - char buf[128]; - sprintf(buf, "states->"); - if (sp->req_state_flags & RQSF_GOT_BUS) - sprintf(buf, "%s%s", buf, "GOT_BUS "); - if (sp->req_state_flags & RQSF_GOT_TARGET) - sprintf(buf, "%s%s", buf, "GOT_TGT "); - if (sp->req_state_flags & RQSF_SENT_CDB) - sprintf(buf, "%s%s", buf, "SENT_CDB "); - if (sp->req_state_flags & RQSF_XFRD_DATA) - sprintf(buf, "%s%s", buf, "XFRD_DATA "); - if (sp->req_state_flags & RQSF_GOT_STATUS) - sprintf(buf, "%s%s", buf, "GOT_STS "); - if (sp->req_state_flags & RQSF_GOT_SENSE) - sprintf(buf, "%s%s", buf, "GOT_SNS "); - if (sp->req_state_flags & RQSF_XFER_COMPLETE) - sprintf(buf, "%s%s", buf, "XFR_CMPLT "); - sprintf(buf, "%s%s", buf, "\n"); - sprintf(buf, "%s%s", buf, "status->"); - if (sp->req_status_flags & RQSTF_DISCONNECT) - sprintf(buf, "%s%s", buf, "Disconnect "); - if (sp->req_status_flags & RQSTF_SYNCHRONOUS) - sprintf(buf, "%s%s", buf, "Sync_xfr "); - if (sp->req_status_flags & RQSTF_PARITY_ERROR) - sprintf(buf, "%s%s", buf, "Parity "); - if (sp->req_status_flags & RQSTF_BUS_RESET) - sprintf(buf, "%s%s", buf, "Bus_Reset "); - if (sp->req_status_flags & RQSTF_DEVICE_RESET) - sprintf(buf, "%s%s", buf, "Device_Reset "); - if (sp->req_status_flags & RQSTF_ABORTED) - sprintf(buf, "%s%s", buf, "Aborted "); - if (sp->req_status_flags & RQSTF_TIMEOUT) - sprintf(buf, "%s%s", buf, "Timeout "); - if (sp->req_status_flags & RQSTF_NEGOTIATION) - sprintf(buf, "%s%s", buf, "Negotiation "); - sprintf(buf, "%s%s", buf, "\n"); - printf(buf); -} - -static inline const char * -isp2100_fw_statename(state) - int state; -{ - static char buf[16]; - switch(state) { - case FW_CONFIG_WAIT: return "Config Wait"; - case FW_WAIT_AL_PA: return "Waiting for AL_PA"; - case FW_WAIT_LOGIN: return "Wait Login"; - case FW_READY: return "Ready"; - case FW_LOSS_OF_SYNC: return "Loss Of Sync"; - case FW_ERROR: return "Error"; - case FW_REINIT: return "Re-Init"; - case FW_NON_PART: return "Non-Participating"; - default: - sprintf(buf, "0x%x", state); - return buf; - } -} - -static inline const char * -isp2100_pdb_statename(pdb_state) - int pdb_state; -{ - static char buf[16]; - switch(pdb_state) { - case PDB_STATE_DISCOVERY: return "Port Discovery"; - case PDB_STATE_WDISC_ACK: return "Waiting Port Discovery ACK"; - case PDB_STATE_PLOGI: return "Port Login"; - case PDB_STATE_PLOGI_ACK: return "Wait Port Login ACK"; - case PDB_STATE_PRLI: return "Process Login"; - case PDB_STATE_PRLI_ACK: return "Wait Process Login ACK"; - case PDB_STATE_LOGGED_IN: return "Logged In"; - case PDB_STATE_PORT_UNAVAIL: return "Port Unavailable"; - case PDB_STATE_PRLO: return "Process Logout"; - case PDB_STATE_PRLO_ACK: return "Wait Process Logout ACK"; - case PDB_STATE_PLOGO: return "Port Logout"; - case PDB_STATE_PLOG_ACK: return "Wait Port Logout ACK"; - default: - sprintf(buf, "0x%x", pdb_state); - return buf; - } -} -/* - * Keep these off for now... - */ +#define ISP_UNSWIZZLE_AND_COPY_PDBP(isp, dest, src) \ + bcopy(src, dest, sizeof (isp_pdb_t)) +#define ISP_SWIZZLE_ICB(a, b) +#ifdef __sparc__ +#define ISP_SWIZZLE_REQUEST(a, b) \ + ISP_SBUSIFY_ISPHDR(a, &(b)->req_header); \ + ISP_SBUSIFY_ISPREQ(a, b) +#define ISP_UNSWIZZLE_RESPONSE(a, b) \ + ISP_SBUSIFY_ISPHDR(a, &(b)->req_header) +#else +#define ISP_SWIZZLE_REQUEST(a, b) +#define ISP_UNSWIZZLE_RESPONSE(a, b) +#endif +#define ISP_SWIZZLE_SNS_REQ(a, b) +#define ISP_UNSWIZZLE_SNS_RSP(a, b, c) -#define ISP_NO_FASTPOST_SCSI 1 -#define ISP_NO_FASTPOST_FC 1 +#define INLINE inline +#include <dev/ic/isp_inline.h> #endif /* _ISP_OPENBSD_H */ diff --git a/sys/dev/ic/ispmbox.h b/sys/dev/ic/ispmbox.h index 12bd100a0ca..3c9daa00bc2 100644 --- a/sys/dev/ic/ispmbox.h +++ b/sys/dev/ic/ispmbox.h @@ -1,10 +1,9 @@ -/* $OpenBSD: ispmbox.h,v 1.6 1999/04/04 02:04:40 mjacob Exp $ */ -/* release_03_25_99 */ +/* $OpenBSD: ispmbox.h,v 1.7 1999/11/22 12:50:53 mjacob Exp $ */ /* * Mailbox and Queue Entry Definitions for for Qlogic ISP SCSI adapters. * *--------------------------------------- - * Copyright (c) 1997, 1998 by Matthew Jacob + * Copyright (c) 1997, 1998, 1999 by Matthew Jacob * NASA/Ames Research Center * All rights reserved. *--------------------------------------- @@ -83,7 +82,7 @@ #define MBOX_GET_SBUS_PARAMS 0x0027 #define MBOX_GET_TARGET_PARAMS 0x0028 #define MBOX_GET_DEV_QUEUE_PARAMS 0x0029 - /* 2a */ +#define MBOX_GET_RESET_DELAY_PARAMS 0x002a /* 2b */ /* 2c */ /* 2d */ @@ -94,13 +93,13 @@ #define MBOX_SET_RETRY_COUNT 0x0032 #define MBOX_SET_TAG_AGE_LIMIT 0x0033 #define MBOX_SET_CLOCK_RATE 0x0034 -#define MBOX_SET_ACTIVE_NEG_STATE 0x0035 +#define MBOX_SET_ACT_NEG_STATE 0x0035 #define MBOX_SET_ASYNC_DATA_SETUP_TIME 0x0036 #define MBOX_SET_SBUS_CONTROL_PARAMS 0x0037 #define MBOX_SET_PCI_PARAMETERS 0x0037 #define MBOX_SET_TARGET_PARAMS 0x0038 #define MBOX_SET_DEV_QUEUE_PARAMS 0x0039 - /* 3a */ +#define MBOX_SET_RESET_DELAY_PARAMS 0x003a /* 3b */ /* 3c */ /* 3d */ @@ -130,6 +129,10 @@ #define MBOX_GET_PORT_NAME 0x6a #define MBOX_GET_LINK_STATUS 0x6b #define MBOX_INIT_LIP_RESET 0x6c +#define MBOX_SEND_SNS 0x6e +#define MBOX_FABRIC_LOGIN 0x6f +#define MBOX_SEND_CHANGE_REQUEST 0x70 +#define MBOX_FABRIC_LOGOUT 0x71 #define MBOX_INIT_LIP_LOGIN 0x72 #define ISP2100_SET_PCI_PARAM 0x00ff @@ -185,19 +188,34 @@ typedef struct { u_int32_t ds_count; } ispds_t; +#define _ISP_SWAP8(a, b) { \ + u_int8_t tmp; \ + tmp = a; \ + a = b; \ + b = tmp; \ +} + +/* + * These elements get swizzled around for SBus instances. + */ typedef struct { -#if BYTE_ORDER == BIG_ENDIAN - u_int8_t rqs_entry_count; - u_int8_t rqs_entry_type; - u_int8_t rqs_flags; - u_int8_t rqs_seqno; -#else u_int8_t rqs_entry_type; u_int8_t rqs_entry_count; u_int8_t rqs_seqno; u_int8_t rqs_flags; -#endif } isphdr_t; +/* + * There are no (for all intents and purposes) non-sparc SBus machines + */ +#ifdef __sparc__ +#define ISP_SBUSIFY_ISPHDR(isp, hdrp) \ + if ((isp)->isp_bustype == ISP_BT_SBUS) { \ + _ISP_SWAP8((hdrp)->rqs_entry_count, (hdrp)->rqs_entry_type); \ + _ISP_SWAP8((hdrp)->rqs_flags, (hdrp)->rqs_seqno); \ + } +#else +#define ISP_SBUSIFY_ISPHDR(a, b) +#endif /* RQS Flag definitions */ #define RQSFLAG_CONTINUATION 0x01 @@ -237,13 +255,8 @@ typedef struct { typedef struct { isphdr_t req_header; u_int32_t req_handle; -#if BYTE_ORDER == BIG_ENDIAN - u_int8_t req_target; - u_int8_t req_lun_trn; -#else u_int8_t req_lun_trn; u_int8_t req_target; -#endif u_int16_t req_cdblen; #define req_modifier req_cdblen /* marker packet */ u_int16_t req_flags; @@ -254,17 +267,31 @@ typedef struct { ispds_t req_dataseg[ISP_RQDSEG]; } ispreq_t; +/* + * A request packet can also be a marker packet. + */ +#define SYNC_DEVICE 0 +#define SYNC_TARGET 1 +#define SYNC_ALL 2 + +/* + * There are no (for all intents and purposes) non-sparc SBus machines + */ +#ifdef __sparc__ +#define ISP_SBUSIFY_ISPREQ(isp, rqp) \ + if ((isp)->isp_bustype == ISP_BT_SBUS) { \ + _ISP_SWAP8((rqp)->req_target, (rqp)->req_lun_trn); \ + } +#else +#define ISP_SBUSIFY_ISPREQ(a, b) +#endif + #define ISP_RQDSEG_T2 3 typedef struct { isphdr_t req_header; u_int32_t req_handle; -#if BYTE_ORDER == BIG_ENDIAN - u_int8_t req_target; - u_int8_t req_lun_trn; -#else u_int8_t req_lun_trn; u_int8_t req_target; -#endif u_int16_t req_scclun; u_int16_t req_flags; u_int16_t _res2; @@ -299,13 +326,8 @@ typedef struct { typedef struct { isphdr_t req_header; u_int32_t req_handle; -#if BYTE_ORDER == BIG_ENDIAN - u_int8_t req_target; - u_int8_t req_lun_trn; -#else u_int8_t req_lun_trn; u_int8_t req_target; -#endif u_int16_t req_cdblen; u_int16_t req_flags; u_int16_t _res1; @@ -323,26 +345,6 @@ typedef struct { typedef struct { isphdr_t req_header; - u_int32_t _res1; -#if BYTE_ORDER == BIG_ENDIAN - u_int8_t req_target; - u_int8_t req_lun_trn; - u_int8_t _res2; - u_int8_t req_modifier; -#else - u_int8_t req_lun_trn; - u_int8_t req_target; - u_int8_t req_modifier; - u_int8_t _res2; -#endif -} ispmarkreq_t; - -#define SYNC_DEVICE 0 -#define SYNC_TARGET 1 -#define SYNC_ALL 2 - -typedef struct { - isphdr_t req_header; u_int32_t req_handle; u_int16_t req_scsi_status; u_int16_t req_completion_status; @@ -436,72 +438,74 @@ typedef struct { /* * Initialization Control Block * - * Version One format. + * Version One (prime) format. */ -typedef struct { -#if BYTE_ORDER == BIG_ENDIAN - u_int8_t _reserved0; - u_int8_t icb_version; -#else +typedef struct isp_icb { u_int8_t icb_version; u_int8_t _reserved0; -#endif - u_int16_t icb_fwoptions; - u_int16_t icb_maxfrmlen; + u_int16_t icb_fwoptions; + u_int16_t icb_maxfrmlen; u_int16_t icb_maxalloc; u_int16_t icb_execthrottle; -#if BYTE_ORDER == BIG_ENDIAN - u_int8_t icb_retry_delay; - u_int8_t icb_retry_count; -#else u_int8_t icb_retry_count; u_int8_t icb_retry_delay; -#endif - u_int8_t icb_nodename[8]; + u_int8_t icb_portname[8]; u_int16_t icb_hardaddr; -#if BYTE_ORDER == BIG_ENDIAN - u_int8_t _reserved1; u_int8_t icb_iqdevtype; -#else - u_int8_t icb_iqdevtype; - u_int8_t _reserved1; -#endif - u_int8_t icb_portname[8]; + u_int8_t icb_logintime; + u_int8_t icb_nodename[8]; u_int16_t icb_rqstout; u_int16_t icb_rspnsin; - u_int16_t icb_rqstqlen; - u_int16_t icb_rsltqlen; - u_int16_t icb_rqstaddr[4]; - u_int16_t icb_respaddr[4]; + u_int16_t icb_rqstqlen; + u_int16_t icb_rsltqlen; + u_int16_t icb_rqstaddr[4]; + u_int16_t icb_respaddr[4]; + u_int16_t icb_lunenables; + u_int8_t icb_ccnt; + u_int8_t icb_icnt; + u_int16_t icb_lunetimeout; + u_int16_t _reserved1; + u_int16_t icb_xfwoptions; + u_int8_t icb_racctimer; + u_int8_t icb_idelaytimer; + u_int16_t icb_zfwoptions; + u_int16_t _reserved2[13]; } isp_icb_t; #define ICB_VERSION1 1 -#define ICBOPT_HARD_ADDRESS (1<<0) -#define ICBOPT_FAIRNESS (1<<1) -#define ICBOPT_FULL_DUPLEX (1<<2) -#define ICBOPT_FAST_POST (1<<3) -#define ICBOPT_TGT_ENABLE (1<<4) -#define ICBOPT_INI_DISABLE (1<<5) -#define ICBOPT_INI_ADISC (1<<6) -#define ICBOPT_INI_TGTTYPE (1<<7) -#define ICBOPT_PDBCHANGE_AE (1<<8) -#define ICBOPT_NOLIP (1<<9) -#define ICBOPT_SRCHDOWN (1<<10) -#define ICBOPT_PREVLOOP (1<<11) -#define ICBOPT_STOP_ON_QFULL (1<<12) -#define ICBOPT_FULL_LOGIN (1<<13) -#define ICBOPT_USE_PORTNAME (1<<14) +#define ICBOPT_HARD_ADDRESS 0x0001 +#define ICBOPT_FAIRNESS 0x0002 +#define ICBOPT_FULL_DUPLEX 0x0004 +#define ICBOPT_FAST_POST 0x0008 +#define ICBOPT_TGT_ENABLE 0x0010 +#define ICBOPT_INI_DISABLE 0x0020 +#define ICBOPT_INI_ADISC 0x0040 +#define ICBOPT_INI_TGTTYPE 0x0080 +#define ICBOPT_PDBCHANGE_AE 0x0100 +#define ICBOPT_NOLIP 0x0200 +#define ICBOPT_SRCHDOWN 0x0400 +#define ICBOPT_PREVLOOP 0x0800 +#define ICBOPT_STOP_ON_QFULL 0x1000 +#define ICBOPT_FULL_LOGIN 0x2000 +#define ICBOPT_USE_PORTNAME 0x4000 +#define ICBOPT_EXTENDED 0x8000 #define ICB_MIN_FRMLEN 256 #define ICB_MAX_FRMLEN 2112 #define ICB_DFLT_FRMLEN 1024 +#define ICB_DFLT_ALLOC 256 +#define ICB_DFLT_THROTTLE 16 +#define ICB_DFLT_RDELAY 5 +#define ICB_DFLT_RCOUNT 3 + #define RQRSP_ADDR0015 0 #define RQRSP_ADDR1631 1 #define RQRSP_ADDR3247 2 #define RQRSP_ADDR4863 3 + #define ICB_NNM0 7 #define ICB_NNM1 6 #define ICB_NNM2 5 @@ -527,33 +531,17 @@ typedef struct { typedef struct { u_int16_t pdb_options; -#if BYTE_ORDER == BIG_ENDIAN - u_int8_t pdb_sstate; - u_int8_t pdb_mstate; -#else u_int8_t pdb_mstate; u_int8_t pdb_sstate; -#endif -#if BYTE_ORDER == BIG_ENDIAN -#define BITS2WORD(x) \ - (x)[1] << 16 | (x)[2] << 8 | (x)[3] -#else -#define BITS2WORD(x) \ - (x)[0] << 16 | (x)[3] << 8 | (x)[2] -#endif +#define BITS2WORD(x) (x)[0] << 16 | (x)[3] << 8 | (x)[2] u_int8_t pdb_hardaddr_bits[4]; u_int8_t pdb_portid_bits[4]; u_int8_t pdb_nodename[8]; u_int8_t pdb_portname[8]; u_int16_t pdb_execthrottle; u_int16_t pdb_exec_count; -#if BYTE_ORDER == BIG_ENDIAN - u_int8_t pdb_retry_delay; - u_int8_t pdb_retry_count; -#else u_int8_t pdb_retry_count; u_int8_t pdb_retry_delay; -#endif u_int16_t pdb_resalloc; u_int16_t pdb_curalloc; u_int16_t pdb_qhead; @@ -563,13 +551,8 @@ typedef struct { u_int16_t pdb_features; /* PLOGI, Common Service */ u_int16_t pdb_pconcurrnt; /* PLOGI, Common Service */ u_int16_t pdb_roi; /* PLOGI, Common Service */ -#if BYTE_ORDER == BIG_ENDIAN - u_int8_t pdb_initiator; /* PLOGI, Class 3 Control Flags */ - u_int8_t pdb_target; -#else u_int8_t pdb_target; u_int8_t pdb_initiator; /* PLOGI, Class 3 Control Flags */ -#endif u_int16_t pdb_rdsiz; /* PLOGI, Class 3 */ u_int16_t pdb_ncseq; /* PLOGI, Class 3 */ u_int16_t pdb_noseq; /* PLOGI, Class 3 */ @@ -588,8 +571,6 @@ typedef struct { u_int16_t pdb_sl_ptr; } isp_pdb_t; -#define INVALID_PDB_OPTIONS 0xDEAD - #define PDB_OPTIONS_XMITTING (1<<11) #define PDB_OPTIONS_LNKXMIT (1<<10) #define PDB_OPTIONS_ABORTED (1<<9) @@ -611,426 +592,29 @@ typedef struct { #define SVC3_TGT_ROLE 0x10 #define SVC3_INI_ROLE 0x20 #define SVC3_ROLE_MASK 0x30 +#define SVC3_ROLE_SHIFT 4 -/* - * Target Mode Structures - */ -#define TGTSVALID 0x80 /* scsi status & sense data valid */ -#define SUGGSENSELEN 18 - -/* - * Structure for Enable Lun and Modify Lun queue entries - */ -typedef struct { - isphdr_t le_header; - u_int32_t le_reserved2; -#if BYTE_ORDER == BIG_ENDIAN -#else - u_int8_t le_lun; - u_int8_t le_rsvd; - u_int8_t le_ops; /* Modify LUN only */ - u_int8_t le_tgt; /* Not for FC */ -#endif - u_int32_t le_flags; /* Not for FC */ -#if BYTE_ORDER == BIG_ENDIAN -#else - u_int8_t le_status; - u_int8_t le_rsvd2; - u_int8_t le_cmd_count; - u_int8_t le_in_count; - u_int8_t le_cdb6len; /* Not for FC */ - u_int8_t le_cdb7len; /* Not for FC */ -#endif - u_int16_t le_timeout; - u_int16_t le_reserved[20]; -} lun_entry_t; - -/* - * le_flags values - */ -#define LUN_TQAE 0x00000001 /* Tagged Queue Action Enable */ -#define LUN_DSSM 0x01000000 /* Disable Sending SDP Message */ -#define LUN_DM 0x40000000 /* Disconnects Mandatory */ - -/* - * le_ops values - */ -#define LUN_CCINCR 0x01 /* increment command count */ -#define LUN_CCDECR 0x02 /* decrement command count */ -#define LUN_ININCR 0x40 /* increment immed. notify count */ -#define LUN_INDECR 0x80 /* decrement immed. notify count */ - -/* - * le_status values - */ -#define LUN_ERR 0x04 /* request completed with error */ -#define LUN_INVAL 0x06 /* invalid request */ -#define LUN_NOCAP 0x16 /* can't provide requested capability */ -#define LUN_ENABLED 0x3E /* LUN already enabled */ - -/* - * Immediate Notify Entry structure - */ -#define IN_MSGLEN 8 /* 8 bytes */ -#define IN_RSVDLEN 8 /* 8 words */ -typedef struct { - isphdr_t in_header; - u_int32_t in_reserved2; -#if BYTE_ORDER == BIG_ENDIAN -#else - u_int8_t in_lun; /* lun */ - u_int8_t in_iid; /* initiator */ - u_int8_t in_rsvd; - u_int8_t in_tgt; /* target */ -#endif - u_int32_t in_flags; -#if BYTE_ORDER == BIG_ENDIAN -#else - u_int8_t in_status; - u_int8_t in_rsvd2; - u_int8_t in_tag_val; /* tag value */ - u_int8_t in_tag_type; /* tag type */ -#endif - u_int16_t in_seqid; /* sequence id */ - u_int8_t in_msg[IN_MSGLEN]; /* SCSI message bytes */ - u_int16_t in_reserved[IN_RSVDLEN]; - u_int8_t in_sense[SUGGSENSELEN]; /* suggested sense data */ -} in_entry_t; - +#define SNS_GAN 0x100 +#define SNS_GP3 0x171 typedef struct { - isphdr_t in_header; - u_int32_t in_reserved2; -#if BYTE_ORDER == BIG_ENDIAN -#else - u_int8_t in_lun; /* lun */ - u_int8_t in_iid; /* initiator */ -#endif - u_int16_t in_rsvd; - u_int32_t in_rsvd2; - u_int16_t in_status; - u_int16_t in_task_flags; - u_int16_t in_seqid; /* sequence id */ -} in_fcentry_t; - -/* - * Values for the in_status field - */ -#define IN_NO_RCAP 0x16 /* requested capability not available */ -#define IN_IDE_RECEIVED 0x33 /* Initiator Detected Error msg received */ -#define IN_RSRC_UNAVAIL 0x34 /* resource unavailable */ -#define IN_MSG_RECEIVED 0x36 /* SCSI message received */ -#define IN_PORT_LOGOUT 0x29 /* port has logged out (FC) */ -#define IN_ABORT_TASK 0x20 /* task named in RX_ID is being aborted (FC) */ + u_int16_t snscb_rblen; /* response buffer length (words) */ + u_int16_t snscb_res0; + u_int16_t snscb_addr[4]; /* response buffer address */ + u_int16_t snscb_sblen; /* subcommand buffer length (words) */ + u_int16_t snscb_res1; + u_int16_t snscb_data[1]; /* variable data */ +} sns_screq_t; /* Subcommand Request Structure */ +#define SNS_GAN_REQ_SIZE (sizeof (sns_screq_t)+(5*(sizeof (u_int16_t)))) +#define SNS_GP3_REQ_SIZE (sizeof (sns_screq_t)+(5*(sizeof (u_int16_t)))) -/* - * Notify Acknowledge Entry structure - */ -#define NA_RSVDLEN 22 typedef struct { - isphdr_t na_header; - u_int32_t na_reserved2; -#if BYTE_ORDER == BIG_ENDIAN -#else - u_int8_t na_lun; /* lun */ - u_int8_t na_iid; /* initiator */ - u_int8_t na_rsvd; - u_int8_t na_tgt; /* target */ -#endif - u_int32_t na_flags; -#if BYTE_ORDER == BIG_ENDIAN -#else - u_int8_t na_status; - u_int8_t na_event; -#endif - u_int16_t na_seqid; /* sequence id */ - u_int16_t na_reserved[NA_RSVDLEN]; -} na_entry_t; - -/* - * Value for the na_event field - */ -#define NA_RST_CLRD 0x80 /* Clear an async event notification */ - -#define NA2_RSVDLEN 21 -typedef struct { - isphdr_t na_header; - u_int32_t na_reserved2; -#if BYTE_ORDER == BIG_ENDIAN -#else - u_int8_t na_lun; /* lun */ - u_int8_t na_iid; /* initiator */ -#endif - u_int16_t na_rsvd; - u_int16_t na_flags; - u_int16_t na_rsvd2; - u_int16_t na_status; - u_int16_t na_task_flags; - u_int16_t na_seqid; /* sequence id */ - u_int16_t na_reserved[NA2_RSVDLEN]; -} na_fcentry_t; -#define NAFC_RST_CLRD 0x40 - -/* - * Value for the na_event field - */ -#define NA_RST_CLRD 0x80 /* Clear an async event notification */ -/* - * Accept Target I/O Entry structure - */ -#define ATIO_CDBLEN 26 - -typedef struct { - isphdr_t at_header; - u_int32_t at_reserved2; -#if BYTE_ORDER == BIG_ENDIAN -#else - u_int8_t at_lun; /* lun */ - u_int8_t at_iid; /* initiator */ - u_int8_t at_cdblen; /* cdb length */ - u_int8_t at_tgt; /* target */ -#endif - u_int32_t at_flags; -#if BYTE_ORDER == BIG_ENDIAN -#else - u_int8_t at_status; /* firmware status */ - u_int8_t at_scsi_status; /* scsi status */ - u_int8_t at_tag_val; /* tag value */ - u_int8_t at_tag_type; /* tag type */ -#endif - u_int8_t at_cdb[ATIO_CDBLEN]; /* received CDB */ - u_int8_t at_sense[SUGGSENSELEN]; /* suggested sense data */ -} at_entry_t; - -/* - * at_flags values - */ -#define AT_NODISC 0x00008000 /* disconnect disabled */ -#define AT_TQAE 0x00000001 /* Tagged Queue Action enabled */ - -/* - * at_status values - */ -#define AT_PATH_INVALID 0x07 /* ATIO sent to firmware for disabled lun */ -#define AT_PHASE_ERROR 0x14 /* Bus phase sequence error */ -#define AT_NOCAP 0x16 /* Requested capability not available */ -#define AT_BDR_MSG 0x17 /* Bus Device Reset msg received */ -#define AT_CDB 0x3D /* CDB received */ - -/* - * Accept Target I/O Entry structure, Type 2 - */ -#define ATIO2_CDBLEN 16 - -typedef struct { - isphdr_t at_header; - u_int32_t at_reserved2; -#if BYTE_ORDER == BIG_ENDIAN -#else - u_int8_t at_lun; /* lun */ - u_int8_t at_iid; /* initiator */ -#endif - u_int16_t at_rxid; /* response ID */ - u_int16_t at_flags; - u_int16_t at_status; /* firmware status */ -#if BYTE_ORDER == BIG_ENDIAN -#else - u_int8_t at_reserved1; - u_int8_t at_taskcodes; - u_int8_t at_taskflags; - u_int8_t at_execodes; -#endif - u_int8_t at_cdb[ATIO2_CDBLEN]; /* received CDB */ - u_int32_t at_datalen; /* allocated data len */ - u_int16_t at_scclun; - u_int16_t at_reserved3; - u_int16_t at_scsi_status; - u_int8_t at_sense[SUGGSENSELEN]; /* suggested sense data */ -} at2_entry_t; - -#define ATIO2_TC_ATTR_MASK 0x7 -#define ATIO2_TC_ATTR_SIMPLEQ 0 -#define ATIO2_TC_ATTR_HEADOFQ 1 -#define ATIO2_TC_ATTR_ORDERED 2 -#define ATIO2_TC_ATTR_ACAQ 4 -#define ATIO2_TC_ATTR_UNTAGGED 5 -#define TC2TT(code) \ - (((code) == ATIO2_TC_ATTR_SIMPLEQ)? 0x20 : \ - (((code) == ATIO2_TC_ATTR_HEADOFQ)? 0x21 : \ - (((code) == ATIO2_TC_ATTR_ORDERED)? 0x22 : \ - (((code) == ATIO2_TC_ATTR_ACAQ)? 0x24 : 0)))) - - -/* - * Continue Target I/O Entry structure - * Request from driver. The response from the - * ISP firmware is the same except that the last 18 - * bytes are overwritten by suggested sense data if - * the 'autosense valid' bit is set in the status byte. - */ -typedef struct { - isphdr_t ct_header; - u_int32_t ct_reserved; -#if BYTE_ORDER == BIG_ENDIAN -#else - u_int8_t ct_lun; /* lun */ - u_int8_t ct_iid; /* initiator id */ - u_int8_t ct_rsvd; - u_int8_t ct_tgt; /* our target id */ -#endif - u_int32_t ct_flags; -#if BYTE_ORDER == BIG_ENDIAN -#else - u_int8_t ct_status; /* isp status */ - u_int8_t ct_scsi_status; /* scsi status */ - u_int8_t ct_tag_val; /* tag value */ - u_int8_t ct_tag_type; /* tag type */ -#endif - u_int32_t ct_xfrlen; /* transfer length */ - u_int32_t ct_resid; /* residual length */ - u_int16_t ct_timeout; - u_int16_t ct_seg_count; - ispds_t ct_dataseg[ISP_RQDSEG]; -} ct_entry_t; - -/* - * ct_flags values - */ -#define CT_TQAE 0x00000001 /* Tagged Queue Action enable */ -#define CT_DATA_IN 0x00000040 /* Data direction */ -#define CT_DATA_OUT 0x00000080 /* Data direction */ -#define CT_NO_DATA 0x000000C0 /* Data direction */ -#define CT_DATAMASK 0x000000C0 /* Data direction */ -#define CT_NODISC 0x00008000 /* Disconnects disabled */ -#define CT_DSDP 0x01000000 /* Disable Save Data Pointers */ -#define CT_SENDRDP 0x04000000 /* Send Restore Pointers msg */ -#define CT_SENDSTATUS 0x80000000 /* Send SCSI status byte */ - -/* - * ct_status values - * - set by the firmware when it returns the CTIO - */ -#define CT_OK 0x01 /* completed without error */ -#define CT_ABORTED 0x02 /* aborted by host */ -#define CT_ERR 0x04 /* see sense data for error */ -#define CT_INVAL 0x06 /* request for disabled lun */ -#define CT_NOPATH 0x07 /* invalid ITL nexus */ -#define CT_INVRXID 0x08 /* (FC only) Invalid RX_ID */ -#define CT_RSELTMO 0x0A /* reselection timeout after 2 tries */ -#define CT_TIMEOUT 0x0B /* timed out */ -#define CT_RESET 0x0E /* SCSI Bus Reset occurred */ -#define CT_PHASE_ERROR 0x14 /* Bus phase sequence error */ -#define CT_BDR_MSG 0x17 /* Bus Device Reset msg received */ -#define CT_TERMINATED 0x19 /* due to Terminate Transfer mbox cmd */ -#define CT_LOGOUT 0x29 /* port logout not acknowledged yet */ -#define CT_NOACK 0x35 /* Outstanding Immed. Notify. entry */ - -/* - * When the firmware returns a CTIO entry, it may overwrite the last - * part of the structure with sense data. This starts at offset 0x2E - * into the entry, which is in the middle of ct_dataseg[1]. Rather - * than define a new struct for this, I'm just using the sense data - * offset. - */ -#define CTIO_SENSE_OFFSET 0x2E - -/* - * Entry length in u_longs. All entries are the same size so - * any one will do as the numerator. - */ -#define UINT32_ENTRY_SIZE (sizeof(at_entry_t)/sizeof(u_int32_t)) - -/* - * QLA2100 CTIO (type 2) entry - */ -#define MAXRESPLEN 26 -typedef struct { - isphdr_t ct_header; - u_int32_t ct_reserved; -#if BYTE_ORDER == BIG_ENDIAN -#else - u_int8_t ct_lun; /* lun */ - u_int8_t ct_iid; /* initiator id */ -#endif - u_int16_t ct_rxid; /* response ID */ - u_int16_t ct_flags; - u_int16_t ct_status; /* isp status */ - u_int16_t ct_timeout; - u_int16_t ct_seg_count; - u_int32_t ct_reloff; /* relative offset */ - u_int32_t ct_resid; /* residual length */ - union { - /* - * The three different modes that the target driver - * can set the CTIO2 up as. - * - * The first is for sending FCP_DATA_IUs as well as - * (optionally) sending a terminal SCSI status FCP_RSP_IU. - * - * The second is for sending SCSI sense data in an FCP_RSP_IU. - * Note that no FCP_DATA_IUs will be sent. - * - * The third is for sending FCP_RSP_IUs as built specifically - * in system memory as located by the isp_dataseg. - */ - struct { - u_int32_t _reserved; - u_int16_t _reserved2; - u_int16_t ct_scsi_status; - u_int32_t ct_xfrlen; - ispds_t ct_dataseg[ISP_RQDSEG_T2]; - } m0; - struct { - u_int16_t _reserved; - u_int16_t _reserved2; - u_int16_t ct_senselen; - u_int16_t ct_scsi_status; - u_int16_t ct_resplen; - u_int8_t ct_resp[MAXRESPLEN]; - } m1; - struct { - u_int32_t _reserved; - u_int16_t _reserved2; - u_int16_t _reserved3; - u_int32_t ct_datalen; - ispds_t ct_fcp_rsp_iudata; - } m2; - /* - * CTIO2 returned from F/W... - */ - struct { - u_int32_t _reserved[4]; - u_int16_t ct_scsi_status; - u_int8_t ct_sense[SUGGSENSELEN]; - } fw; - } rsp; -} ct2_entry_t; -/* - * ct_flags values for CTIO2 - */ -#define CT2_FLAG_MMASK 0x0003 -#define CT2_FLAG_MODE0 0x0000 -#define CT2_FLAG_MODE1 0x0001 -#define CT2_FLAG_MODE2 0x0002 -#define CT2_DATA_IN CT_DATA_IN -#define CT2_DATA_OUT CT_DATA_OUT -#define CT2_NO_DATA CT_NO_DATA -#define CT2_DATAMASK CT_DATA_MASK -#define CT2_CCINCR 0x0100 -#define CT2_FASTPOST 0x0200 -#define CT2_SENDSTATUS 0x8000 - -/* - * ct_status values are (mostly) the same as that for ct_entry. - */ - -/* - * ct_scsi_status values- the low 8 bits are the normal SCSI status - * we know and love. The upper 8 bits are validity markers for FCP_RSP_IU - * fields. - */ -#define CT2_RSPLEN_VALID 0x0100 -#define CT2_SNSLEN_VALID 0x0200 -#define CT2_DATA_OVER 0x0400 -#define CT2_DATA_UNDER 0x0800 + u_int8_t snscb_cthdr[16]; + u_int8_t snscb_port_type; + u_int8_t snscb_port_id[3]; + u_int8_t snscb_portname[8]; + u_int16_t snscb_data[1]; /* variable data */ +} sns_scrsp_t; /* Subcommand Response Structure */ +#define SNS_GAN_RESP_SIZE 608 /* Maximum response size (bytes) */ +#define SNS_GP3_RESP_SIZE 532 /* XXX: For 128 ports */ #endif /* _ISPMBOX_H */ diff --git a/sys/dev/ic/ispreg.h b/sys/dev/ic/ispreg.h index c1d136720a6..af661310c52 100644 --- a/sys/dev/ic/ispreg.h +++ b/sys/dev/ic/ispreg.h @@ -1,5 +1,4 @@ -/* $OpenBSD: ispreg.h,v 1.4 1999/03/25 22:58:38 mjacob Exp $ */ -/* release_03_25_99 */ +/* $OpenBSD: ispreg.h,v 1.5 1999/11/22 12:50:53 mjacob Exp $ */ /* * Machine Independent (well, as best as possible) register * definitions for Qlogic ISP SCSI adapters. @@ -54,6 +53,14 @@ * Offsets for various register blocks. * * Sad but true, different architectures have different offsets. + * + * Don't be alarmed if none of this makes sense. The original register + * layout set some defines in a certain pattern. Everything else has been + * grafted on since. For example, the ISP1080 manual will state that DMA + * registers start at 0x80 from the base of the register address space. + * That's true, but for our purposes, we define DMA_REGS_OFF for the 1080 + * to start at offset 0x60 because the DMA registers are all defined to + * be DMA_BLOCK+0x20 and so on. Clear? */ #define BIU_REGS_OFF 0x00 @@ -188,11 +195,11 @@ #define BIU2100_ICR_ENABLE_TXDMA_INT 0x0001 #define BIU2100_ICR_DISABLE_ALL_INTS 0x0000 -#define ENABLE_INTS(isp) (isp->isp_type & ISP_HA_SCSI)? \ +#define ENABLE_INTS(isp) (IS_SCSI(isp))? \ ISP_WRITE(isp, BIU_ICR, BIU_ICR_ENABLE_RISC_INT | BIU_ICR_ENABLE_ALL_INTS) : \ ISP_WRITE(isp, BIU_ICR, BIU2100_ICR_ENA_RISC_INT | BIU2100_ICR_ENABLE_ALL_INTS) -#define INTS_ENABLED(isp) ((isp->isp_type & ISP_HA_SCSI)? \ +#define INTS_ENABLED(isp) ((IS_SCSI(isp))? \ (ISP_READ(isp, BIU_ICR) & (BIU_ICR_ENABLE_RISC_INT|BIU_ICR_ENABLE_ALL_INTS)) :\ (ISP_READ(isp, BIU_ICR) & \ (BIU2100_ICR_ENA_RISC_INT|BIU2100_ICR_ENABLE_ALL_INTS))) @@ -214,6 +221,8 @@ #define BIU2100_ISR_RXDMA_INT_PENDING 0x0002 /* Global interrupt pending */ #define BIU2100_ISR_TXDMA_INT_PENDING 0x0001 /* Global interrupt pending */ +#define INT_PENDING(isp, isr) (IS_FC(isp)? \ + ((isr & BIU2100_ISR_RISC_INT) != 0) : ((isr & BIU_ISR_RISC_INT) != 0)) /* BUS SEMAPHORE REGISTER */ #define BIU_SEMA_STATUS 0x0002 /* Semaphore Status Bit */ @@ -606,7 +615,13 @@ #define PCI_HCCR_BIOS 0x0001 /* W : BIOS enable */ /* - * Qlogic 1XXX NVRAM is an array of 128 bytes. + * NVRAM Definitions (PCI cards only) + */ + +#define ISPBSMX(c, byte, shift, mask) \ + (((c)[(byte)] >> (shift)) & (mask)) +/* + * Qlogic 1020/1040 NVRAM is an array of 128 bytes. * * Some portion of the front of this is for general host adapter properties * This is followed by an array of per-target parameters, and is tailed off @@ -616,9 +631,6 @@ #define ISP_NVRAM_SIZE 128 -#define ISPBSMX(c, byte, shift, mask) \ - (((c)[(byte)] >> (shift)) & (mask)) - #define ISP_NVRAM_VERSION(c) (c)[4] #define ISP_NVRAM_FIFO_THRESHOLD(c) ISPBSMX(c, 5, 0, 0x03) #define ISP_NVRAM_BIOS_DISABLE(c) ISPBSMX(c, 5, 2, 0x01) @@ -669,6 +681,115 @@ #define ISP_NVRAM_TGT_LUN_DISABLE(c, t) ISPBSMX(c, _IxT(t, 3), 5, 0x01) /* + * Qlogic 1080/1240 NVRAM is an array of 256 bytes. + * + * Some portion of the front of this is for general host adapter properties + * This is followed by an array of per-target parameters, and is tailed off + * with a checksum xor byte at offset 256. For non-byte entities data is + * stored in Little Endian order. + */ + +#define ISP1080_NVRAM_SIZE 256 + +#define ISP1080_NVRAM_VERSION(c) ISP_NVRAM_VERSION(c) + +/* Offset 5 */ +/* + uint8_t bios_configuration_mode :2; + uint8_t bios_disable :1; + uint8_t selectable_scsi_boot_enable :1; + uint8_t cd_rom_boot_enable :1; + uint8_t disable_loading_risc_code :1; + uint8_t enable_64bit_addressing :1; + uint8_t unused_7 :1; + */ + +/* Offsets 6, 7 */ +/* + uint8_t boot_lun_number :5; + uint8_t scsi_bus_number :1; + uint8_t unused_6 :1; + uint8_t unused_7 :1; + uint8_t boot_target_number :4; + uint8_t unused_12 :1; + uint8_t unused_13 :1; + uint8_t unused_14 :1; + uint8_t unused_15 :1; + */ + +#define ISP1080_NVRAM_HBA_ENABLE(c) ISPBSMX(c, 16, 3, 0x01) + +#define ISP1080_NVRAM_BURST_ENABLE(c) ISPBSMX(c, 16, 1, 0x01) +#define ISP1080_NVRAM_FIFO_THRESHOLD(c) ISPBSMX(c, 16, 4, 0x0f) + +#define ISP1080_NVRAM_AUTO_TERM_SUPPORT(c) ISPBSMX(c, 17, 7, 0x01) +#define ISP1080_NVRAM_BUS0_TERM_MODE(c) ISPBSMX(c, 17, 0, 0x03) +#define ISP1080_NVRAM_BUS1_TERM_MODE(c) ISPBSMX(c, 17, 2, 0x03) + +#define ISP1080_ISP_PARAMETER(c) \ + (((c)[18]) | ((c)[19] << 8)) + +#define ISP1080_FAST_POST ISPBSMX(c, 20, 0, 0x01) +#define ISP1080_REPORT_LVD_TRANSITION ISPBSMX(c, 20, 1, 0x01) + +#define ISP1080_BUS1_OFF 112 + +#define ISP1080_NVRAM_INITIATOR_ID(c, b) \ + ISPBSMX(c, ((b == 0)? 0 : ISP1080_BUS1_OFF) + 24, 0, 0x0f) +#define ISP1080_NVRAM_BUS_RESET_DELAY(c, b) \ + (c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 25] +#define ISP1080_NVRAM_BUS_RETRY_COUNT(c, b) \ + (c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 26] +#define ISP1080_NVRAM_BUS_RETRY_DELAY(c, b) \ + (c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 27] + +#define ISP1080_NVRAM_ASYNC_DATA_SETUP_TIME(c, b) \ + ISPBSMX(c, ((b == 0)? 0 : ISP1080_BUS1_OFF) + 28, 0, 0x0f) +#define ISP1080_NVRAM_REQ_ACK_ACTIVE_NEGATION(c, b) \ + ISPBSMX(c, ((b == 0)? 0 : ISP1080_BUS1_OFF) + 28, 4, 0x01) +#define ISP1080_NVRAM_DATA_LINE_ACTIVE_NEGATION(c, b) \ + ISPBSMX(c, ((b == 0)? 0 : ISP1080_BUS1_OFF) + 28, 5, 0x01) +#define ISP1080_NVRAM_SELECTION_TIMEOUT(c, b) \ + (((c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 30]) | \ + ((c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 31] << 8)) +#define ISP1080_NVRAM_MAX_QUEUE_DEPTH(c, b) \ + (((c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 32]) | \ + ((c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 33] << 8)) + +#define ISP1080_NVRAM_TARGOFF(b) \ + ((b == 0)? 40: (40 + ISP1080_BUS1_OFF)) +#define ISP1080_NVRAM_TARGSIZE 6 +#define _IxT8(tgt, tidx, b) \ + (ISP1080_NVRAM_TARGOFF((b)) + (ISP1080_NVRAM_TARGSIZE * (tgt)) + (tidx)) + +#define ISP1080_NVRAM_TGT_RENEG(c, t, b) \ + ISPBSMX(c, _IxT8(t, 0, (b)), 0, 0x01) +#define ISP1080_NVRAM_TGT_QFRZ(c, t, b) \ + ISPBSMX(c, _IxT8(t, 0, (b)), 1, 0x01) +#define ISP1080_NVRAM_TGT_ARQ(c, t, b) \ + ISPBSMX(c, _IxT8(t, 0, (b)), 2, 0x01) +#define ISP1080_NVRAM_TGT_TQING(c, t, b) \ + ISPBSMX(c, _IxT8(t, 0, (b)), 3, 0x01) +#define ISP1080_NVRAM_TGT_SYNC(c, t, b) \ + ISPBSMX(c, _IxT8(t, 0, (b)), 4, 0x01) +#define ISP1080_NVRAM_TGT_WIDE(c, t, b) \ + ISPBSMX(c, _IxT8(t, 0, (b)), 5, 0x01) +#define ISP1080_NVRAM_TGT_PARITY(c, t, b) \ + ISPBSMX(c, _IxT8(t, 0, (b)), 6, 0x01) +#define ISP1080_NVRAM_TGT_DISC(c, t, b) \ + ISPBSMX(c, _IxT8(t, 0, (b)), 7, 0x01) +#define ISP1080_NVRAM_TGT_EXEC_THROTTLE(c, t, b) \ + ISPBSMX(c, _IxT8(t, 1, (b)), 0, 0xff) +#define ISP1080_NVRAM_TGT_SYNC_PERIOD(c, t, b) \ + ISPBSMX(c, _IxT8(t, 2, (b)), 0, 0xff) +#define ISP1080_NVRAM_TGT_SYNC_OFFSET(c, t, b) \ + ISPBSMX(c, _IxT8(t, 3, (b)), 0, 0x0f) +#define ISP1080_NVRAM_TGT_DEVICE_ENABLE(c, t, b) \ + ISPBSMX(c, _IxT8(t, 3, (b)), 4, 0x01) +#define ISP1080_NVRAM_TGT_LUN_DISABLE(c, t, b) \ + ISPBSMX(c, _IxT8(t, 3, (b)), 5, 0x01) + +/* * Qlogic 2XXX NVRAM is an array of 256 bytes. * * Some portion of the front of this is for general RISC engine parameters, diff --git a/sys/dev/ic/ispvar.h b/sys/dev/ic/ispvar.h index 8882cefb51c..1ccc141de29 100644 --- a/sys/dev/ic/ispvar.h +++ b/sys/dev/ic/ispvar.h @@ -1,10 +1,9 @@ -/* $OpenBSD: ispvar.h,v 1.6 1999/04/04 02:07:27 mjacob Exp $ */ -/* release_03_25_99 */ +/* $OpenBSD: ispvar.h,v 1.7 1999/11/22 12:50:53 mjacob Exp $ */ /* * Soft Definitions for for Qlogic ISP SCSI adapters. * *--------------------------------------- - * Copyright (c) 1997, 1998 by Matthew Jacob + * Copyright (c) 1997, 1998, 1999 by Matthew Jacob * NASA/Ames Research Center * All rights reserved. *--------------------------------------- @@ -39,16 +38,25 @@ #if defined(__NetBSD__) || defined(__OpenBSD__) #include <dev/ic/ispmbox.h> +#ifdef ISP_TARGET_MODE +#include <dev/ic/isp_target.h> +#endif #endif #ifdef __FreeBSD__ #include <dev/isp/ispmbox.h> +#ifdef ISP_TARGET_MODE +#include <dev/isp/isp_target.h> +#endif #endif #ifdef __linux__ #include "ispmbox.h" +#ifdef ISP_TARGET_MODE +#include "isp_target.h" +#endif #endif #define ISP_CORE_VERSION_MAJOR 1 -#define ISP_CORE_VERSION_MINOR 7 +#define ISP_CORE_VERSION_MINOR 11 /* * Vector for bus specific code to provide specific services. @@ -59,7 +67,7 @@ struct ispmdvec { void (*dv_wr_reg) __P((struct ispsoftc *, int, u_int16_t)); int (*dv_mbxdma) __P((struct ispsoftc *)); int (*dv_dmaset) __P((struct ispsoftc *, - ISP_SCSI_XFER_T *, ispreq_t *, u_int8_t *, u_int8_t)); + ISP_SCSI_XFER_T *, ispreq_t *, u_int16_t *, u_int16_t)); void (*dv_dmaclr) __P((struct ispsoftc *, ISP_SCSI_XFER_T *, u_int32_t)); void (*dv_reset0) __P((struct ispsoftc *)); @@ -68,7 +76,7 @@ struct ispmdvec { const u_int16_t *dv_ispfw; /* ptr to f/w */ u_int16_t dv_fwlen; /* length of f/w */ u_int16_t dv_codeorg; /* code ORG for f/w */ - u_int16_t dv_fwrev; /* f/w revision */ + u_int32_t dv_fwrev; /* f/w revision */ /* * Initial values for conf1 register */ @@ -82,45 +90,98 @@ struct ispmdvec { #else #define MAX_FC_TARG 126 #endif -#define DEFAULT_LOOPID 113 -/* queue length must be a power of two */ +#define ISP_MAX_TARGETS(isp) (IS_FC(isp)? MAX_FC_TARG : MAX_TARGETS) +#ifdef ISP2100_SCCLUN +#define _ISP_FC_LUN(isp) 65536 +#else +#define _ISP_FC_LUN(isp) 16 +#endif +#define _ISP_SCSI_LUN(isp) \ + ((ISP_FW_REVX(isp->isp_fwrev) >= ISP_FW_REV(7, 55, 0))? 32 : 8) +#define ISP_MAX_LUNS(isp) \ + (IS_FC(isp)? _ISP_FC_LUN(isp) : _ISP_SCSI_LUN(isp)) + + +/* + * Macros to read, write ISP registers through bus specific code. + */ + +#define ISP_READ(isp, reg) \ + (*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg)) + +#define ISP_WRITE(isp, reg, val) \ + (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val)) + +#define ISP_MBOXDMASETUP(isp) \ + (*(isp)->isp_mdvec->dv_mbxdma)((isp)) + +#define ISP_DMASETUP(isp, xs, req, iptrp, optr) \ + (*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req), (iptrp), (optr)) + +#define ISP_DMAFREE(isp, xs, hndl) \ + if ((isp)->isp_mdvec->dv_dmaclr) \ + (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (hndl)) + +#define ISP_RESET0(isp) \ + if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp)) +#define ISP_RESET1(isp) \ + if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp)) +#define ISP_DUMPREGS(isp) \ + if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp)) + +#define ISP_SETBITS(isp, reg, val) \ + (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val)) + +#define ISP_CLRBITS(isp, reg, val) \ + (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val)) + +/* this is the size of a queue entry (request and response) */ #define QENTRY_LEN 64 +/* both request and result queue length must be a power of two */ #define RQUEST_QUEUE_LEN MAXISPREQUEST +/* I've seen wierdnesses with the result queue < 64 */ +#if MAXISPREQUEST > 64 #define RESULT_QUEUE_LEN (MAXISPREQUEST/2) +#else +#define RESULT_QUEUE_LEN MAXISPREQUEST +#endif #define ISP_QUEUE_ENTRY(q, idx) ((q) + ((idx) * QENTRY_LEN)) #define ISP_QUEUE_SIZE(n) ((n) * QENTRY_LEN) #define ISP_NXT_QENTRY(idx, qlen) (((idx) + 1) & ((qlen)-1)) -#define ISP_QAVAIL(in, out, qlen) \ +#define ISP_QAVAIL(in, out, qlen) \ ((in == out)? (qlen - 1) : ((in > out)? \ - ((qlen - 1) - (in - out)) : (out - in - 1))) + ((qlen - 1) - (in - out)) : (out - in - 1))) + +#define ISP_ADD_REQUEST(isp, iptr) \ + ISP_WRITE(isp, INMAILBOX4, iptr), isp->isp_reqidx = iptr + /* - * SCSI Specific Host Adapter Parameters + * SCSI Specific Host Adapter Parameters- per bus, per target */ typedef struct { - u_int isp_req_ack_active_neg : 1, - isp_data_line_active_neg: 1, + u_int isp_gotdparms : 1, + isp_req_ack_active_neg : 1, + isp_data_line_active_neg: 1, isp_cmd_dma_burst_enable: 1, isp_data_dma_burst_enabl: 1, isp_fifo_threshold : 3, isp_ultramode : 1, isp_diffmode : 1, isp_lvdmode : 1, - isp_fast_mttr : 1, + : 1, isp_initiator_id : 4, - isp_async_data_setup : 4; - u_int16_t isp_selection_timeout; - u_int16_t isp_max_queue_depth; - u_int16_t isp_clock; + isp_async_data_setup : 4; + u_int16_t isp_selection_timeout; + u_int16_t isp_max_queue_depth; u_int8_t isp_tag_aging; - u_int8_t isp_bus_reset_delay; - u_int8_t isp_retry_count; - u_int8_t isp_retry_delay; + u_int8_t isp_bus_reset_delay; + u_int8_t isp_retry_count; + u_int8_t isp_retry_delay; struct { - u_int - dev_enable : 1, - dev_announced : 1, + u_int dev_enable : 1, /* ignored */ + : 1, dev_update : 1, dev_refresh : 1, exc_throttle : 8, @@ -131,7 +192,7 @@ typedef struct { u_int16_t dev_flags; /* goal device flags */ u_int16_t cur_dflags; /* current device flags */ } isp_devparam[MAX_TARGETS]; -} sdparam; /* scsi device parameters */ +} sdparam; /* * Device Flags @@ -152,84 +213,80 @@ typedef struct { /* technically, not really correct, as they need to be rated based upon clock */ #define ISP_40M_SYNCPARMS 0x080a -#define ISP_20M_SYNCPARMS 0x080c -#define ISP_10M_SYNCPARMS 0x0c19 -#define ISP_08M_SYNCPARMS 0x0c25 -#define ISP_05M_SYNCPARMS 0x0c32 -#define ISP_04M_SYNCPARMS 0x0c41 +#define ISP_20M_SYNCPARMS 0x080c +#define ISP_10M_SYNCPARMS 0x0c19 +#define ISP_08M_SYNCPARMS 0x0c25 +#define ISP_05M_SYNCPARMS 0x0c32 +#define ISP_04M_SYNCPARMS 0x0c41 /* * Fibre Channel Specifics */ +#define FL_PORT_ID 0x7e /* FL_Port Special ID */ +#define FC_PORT_ID 0x7f /* Fabric Controller Special ID */ +#define FC_SNS_ID 0x80 /* SNS Server Special ID */ + typedef struct { - u_int64_t isp_wwn; /* WWN of adapter */ + u_int32_t isp_fwoptions : 16, + : 7, + loop_seen_once : 1, + isp_loopstate : 3, /* Current Loop State */ + isp_fwstate : 3, /* ISP F/W state */ + isp_gotdparms : 1, + isp_onfabric : 1; u_int8_t isp_loopid; /* hard loop id */ u_int8_t isp_alpa; /* ALPA */ + volatile u_int16_t isp_lipseq; /* LIP sequence # */ + u_int32_t isp_portid; u_int8_t isp_execthrottle; - u_int8_t isp_retry_delay; - u_int8_t isp_retry_count; - u_int8_t isp_fwstate; /* ISP F/W state */ + u_int8_t isp_retry_delay; + u_int8_t isp_retry_count; + u_int8_t isp_reserved; u_int16_t isp_maxalloc; u_int16_t isp_maxfrmlen; - u_int16_t isp_fwoptions; + u_int64_t isp_nodewwn; + u_int64_t isp_portwwn; /* - * Port Data Base + * Port Data Base. This is indexed by 'target', which is invariate. + * However, elements within can move around due to loop changes, + * so the actual loop ID passed to the F/W is in this structure. + * The first time the loop is seen up, loopid will match the index + * (except for fabric nodes which are above mapped above FC_SNS_ID + * and are completely virtual), but subsequent LIPs can cause things + * to move around. */ - isp_pdb_t isp_pdb[MAX_FC_TARG]; + struct lportdb { + u_int + loopid : 8, + : 4, + fabdev : 1, + roles : 2, + valid : 1; + u_int32_t portid; + u_int64_t node_wwn; + u_int64_t port_wwn; + } portdb[MAX_FC_TARG], tport[FL_PORT_ID]; /* * Scratch DMA mapped in area to fetch Port Database stuff, etc. */ - volatile caddr_t isp_scratch; + caddr_t isp_scratch; u_int32_t isp_scdma; } fcparam; -#define ISP2100_SCRLEN 0x100 - -#define FW_CONFIG_WAIT 0x0000 -#define FW_WAIT_AL_PA 0x0001 -#define FW_WAIT_LOGIN 0x0002 -#define FW_READY 0x0003 -#define FW_LOSS_OF_SYNC 0x0004 -#define FW_ERROR 0x0005 -#define FW_REINIT 0x0006 -#define FW_NON_PART 0x0007 +#define FW_CONFIG_WAIT 0 +#define FW_WAIT_AL_PA 1 +#define FW_WAIT_LOGIN 2 +#define FW_READY 3 +#define FW_LOSS_OF_SYNC 4 +#define FW_ERROR 5 +#define FW_REINIT 6 +#define FW_NON_PART 7 -#ifdef ISP_TARGET_MODE -/* - * Some temporary Target Mode definitions - */ -typedef struct tmd_cmd { - u_int8_t cd_iid; /* initiator */ - u_int8_t cd_tgt; /* target */ - u_int8_t cd_lun; /* LUN for this command */ - u_int8_t cd_state; - u_int8_t cd_cdb[16]; /* command bytes */ - u_int8_t cd_sensedata[20]; - u_int16_t cd_rxid; - u_int32_t cd_datalen; - u_int32_t cd_totbytes; - void * cd_hba; -} tmd_cmd_t; - -/* - * Async Target Mode Event Definitions - */ -#define TMD_BUS_RESET 0 -#define TMD_BDR 1 - -/* - * Immediate Notify data structure. - */ -#define NOTIFY_MSGLEN 5 -typedef struct { - u_int8_t nt_iid; /* initiator */ - u_int8_t nt_tgt; /* target */ - u_int8_t nt_lun; /* LUN for this command */ - u_int8_t nt_msg[NOTIFY_MSGLEN]; /* SCSI message byte(s) */ -} tmd_notify_t; - -#endif +#define LOOP_NIL 0 +#define LOOP_LIP_RCVD 1 +#define LOOP_PDB_RCVD 2 +#define LOOP_READY 7 /* * Soft Structure per host adapter @@ -241,89 +298,63 @@ struct ispsoftc { struct isposinfo isp_osinfo; /* - * Pointer to bus specific data + * Pointer to bus specific functions and data */ struct ispmdvec * isp_mdvec; /* - * Mostly nonvolatile state, debugging, etc.. + * (Mostly) nonvolatile state. Board specific parameters + * may contain some volatile state (e.g., current loop state). */ - u_int : 8, - isp_confopts : 8, - isp_port : 1, /* for dual ported impls */ - isp_used : 1, - isp_dblev : 3, - isp_gotdparms : 1, - isp_dogactive : 1, - isp_bustype : 1, /* BUS Implementation */ - isp_type : 8; /* HBA Type and Revision */ - - u_int16_t isp_fwrev; /* Running F/W revision */ - u_int16_t isp_romfw_rev; /* 'ROM' F/W revision */ - void * isp_param; + void * isp_param; /* type specific */ + u_int16_t isp_fwrev[3]; /* Loaded F/W revision */ + u_int16_t isp_romfw_rev[3]; /* PROM F/W revision */ + u_int16_t isp_maxcmds; /* max possible I/O cmds */ + u_int8_t isp_type; /* HBA Chip Type */ + u_int8_t isp_revision; /* HBA Chip H/W Revision */ + + u_int32_t : 4, + isp_touched : 1, /* board ever seen? */ + isp_fast_mttr : 1, /* fast sram */ + isp_bustype : 1, /* SBus or PCI */ + isp_dogactive : 1, /* watchdog running */ + isp_dblev : 8, /* debug level */ + isp_clock : 8, /* input clock */ + isp_confopts : 8; /* config options */ /* * Volatile state */ - volatile u_int - : 19, + volatile u_int32_t : 9, isp_state : 3, - isp_sendmarker : 1, /* send a marker entry */ - isp_update : 1, /* update parameters */ - isp_nactive : 9; /* how many commands active */ + isp_sendmarker : 2, /* send a marker entry */ + isp_update : 2, /* update parameters */ + isp_nactive : 16; /* how many commands active */ - /* - * Result and Request Queue indices. - */ - volatile u_int8_t isp_reqodx; /* index of last ISP pickup */ - volatile u_int8_t isp_reqidx; /* index of next request */ - volatile u_int8_t isp_residx; /* index of next result */ - volatile u_int8_t isp_seqno; /* rolling sequence # */ + volatile u_int16_t isp_reqodx; /* index of last ISP pickup */ + volatile u_int16_t isp_reqidx; /* index of next request */ + volatile u_int16_t isp_residx; /* index of next result */ + volatile u_int16_t isp_lasthdls; /* last handle seed */ /* - * Sheer laziness, but it gets us around the problem - * where we don't have a clean way of remembering - * which transaction is bound to which ISP queue entry. - * - * There are other more clever ways to do this, but, - * jeez, so I blow a couple of KB per host adapter... - * and it *is* faster. + * Active commands are stored here, indexed by handle functions. */ - ISP_SCSI_XFER_T *isp_xflist[RQUEST_QUEUE_LEN]; + ISP_SCSI_XFER_T **isp_xflist; /* - * request/result queues and dma handles for them. + * request/result queue pointers and dma handles for them. */ - volatile caddr_t isp_rquest; - volatile caddr_t isp_result; + caddr_t isp_rquest; + caddr_t isp_result; u_int32_t isp_rquest_dma; u_int32_t isp_result_dma; - -#ifdef ISP_TARGET_MODE - /* - * Vectors for handling target mode support. - * - * isp_tmd_newcmd is for feeding a newly arrived command to some - * upper layer. - * - * isp_tmd_event is for notifying some upper layer that an event has - * occurred that is not necessarily tied to any target (e.g., a SCSI - * Bus Reset). - * - * isp_tmd_notify is for notifying some upper layer that some - * event is now occurring that is either pertinent for a specific - * device or for a specific command (e.g., BDR or ABORT TAG). - * - * It is left undefined (for now) how pools of commands are managed. - */ - void (*isp_tmd_newcmd) __P((void *, tmd_cmd_t *)); - void (*isp_tmd_event) __P((void *, int)); - void (*isp_tmd_notify) __P((void *, tmd_notify_t *)); -#endif }; +#define SDPARAM(isp) ((sdparam *) (isp)->isp_param) +#define FCPARAM(isp) ((fcparam *) (isp)->isp_param) + /* * ISP States */ @@ -337,8 +368,11 @@ struct ispsoftc { */ #define ISP_CFG_NORELOAD 0x80 /* don't download f/w */ #define ISP_CFG_NONVRAM 0x40 /* ignore NVRAM */ +#define ISP_CFG_FULL_DUPLEX 0x01 /* Full Duplex (Fibre Channel only) */ +#define ISP_CFG_OWNWWN 0x02 /* override NVRAM wwn */ -#define ISP_FW_REV(maj, min) ((maj) << 10| (min)) +#define ISP_FW_REV(maj, min, mic) ((maj << 24) | (min << 16) | mic) +#define ISP_FW_REVX(xp) ((xp[0]<<24) | (xp[1] << 16) | xp[2]) /* * Bus (implementation) types @@ -356,10 +390,12 @@ struct ispsoftc { #define ISP_HA_SCSI_1040 0x4 #define ISP_HA_SCSI_1040A 0x5 #define ISP_HA_SCSI_1040B 0x6 +#define ISP_HA_SCSI_1040C 0x7 #define ISP_HA_SCSI_1080 0xd #define ISP_HA_SCSI_12X0 0xe #define ISP_HA_FC 0xf0 #define ISP_HA_FC_2100 0x10 +#define ISP_HA_FC_2200 0x20 #define IS_SCSI(isp) (isp->isp_type & ISP_HA_SCSI) #define IS_1080(isp) (isp->isp_type == ISP_HA_SCSI_1080) @@ -367,39 +403,6 @@ struct ispsoftc { #define IS_FC(isp) (isp->isp_type & ISP_HA_FC) /* - * Macros to read, write ISP registers through bus specific code. - */ - -#define ISP_READ(isp, reg) \ - (*(isp)->isp_mdvec->dv_rd_reg)((isp), (reg)) - -#define ISP_WRITE(isp, reg, val) \ - (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), (val)) - -#define ISP_MBOXDMASETUP(isp) \ - (*(isp)->isp_mdvec->dv_mbxdma)((isp)) - -#define ISP_DMASETUP(isp, xs, req, iptrp, optr) \ - (*(isp)->isp_mdvec->dv_dmaset)((isp), (xs), (req), (iptrp), (optr)) - -#define ISP_DMAFREE(isp, xs, seqno) \ - if ((isp)->isp_mdvec->dv_dmaclr) \ - (*(isp)->isp_mdvec->dv_dmaclr)((isp), (xs), (seqno)) - -#define ISP_RESET0(isp) \ - if ((isp)->isp_mdvec->dv_reset0) (*(isp)->isp_mdvec->dv_reset0)((isp)) -#define ISP_RESET1(isp) \ - if ((isp)->isp_mdvec->dv_reset1) (*(isp)->isp_mdvec->dv_reset1)((isp)) -#define ISP_DUMPREGS(isp) \ - if ((isp)->isp_mdvec->dv_dregs) (*(isp)->isp_mdvec->dv_dregs)((isp)) - -#define ISP_SETBITS(isp, reg, val) \ - (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) | (val)) - -#define ISP_CLRBITS(isp, reg, val) \ - (*(isp)->isp_mdvec->dv_wr_reg)((isp), (reg), ISP_READ((isp), (reg)) & ~(val)) - -/* * Function Prototypes */ @@ -432,21 +435,19 @@ int32_t ispscsicmd __P((ISP_SCSI_XFER_T *)); /* * Platform Dependent to External to Internal Control Function * - * For: Aborting a running command - arg is an ISP_SCSI_XFER_T * - * Resetting a Device - arg is target to reset - * Resetting a BUS - arg is ignored - * Updating parameters - arg is ignored + * Assumes all locks are held and that no reentrancy issues need be dealt with. * - * First argument is this instance's softc pointer. - * Second argument is an index into xflist array. - * Assumes all locks must be held already. */ typedef enum { - ISPCTL_RESET_BUS, - ISPCTL_RESET_DEV, - ISPCTL_ABORT_CMD, - ISPCTL_UPDATE_PARAMS, - ISPCTL_FCLINK_TEST + ISPCTL_RESET_BUS, /* Reset Bus */ + ISPCTL_RESET_DEV, /* Reset Device */ + ISPCTL_ABORT_CMD, /* Abort Command */ + ISPCTL_UPDATE_PARAMS, /* Update Operating Parameters */ +#ifdef ISP_TARGET_MODE + ISPCTL_ENABLE_LUN, /* enable a LUN */ + ISPCTL_MODIFY_LUN, /* enable a LUN */ +#endif + ISPCTL_FCLINK_TEST /* Test FC Link Status */ } ispctl_t; int isp_control __P((struct ispsoftc *, ispctl_t, void *)); @@ -455,18 +456,20 @@ int isp_control __P((struct ispsoftc *, ispctl_t, void *)); * Platform Dependent to Internal to External Control Function * (each platform must provide such a function) * - * For: Announcing Target Paramter Changes (arg is target) + * Assumes all locks are held and that no reentrancy issues need be dealt with. * - * Assumes all locks are held. */ typedef enum { ISPASYNC_NEW_TGT_PARAMS, - ISPASYNC_BUS_RESET, /* Bus Reset */ - ISPASYNC_LOOP_DOWN, /* Obvious FC only */ - ISPASYNC_LOOP_UP, /* "" */ - ISPASYNC_PDB_CHANGE_COMPLETE, /* "" */ - ISPASYNC_CHANGE_NOTIFY /* "" */ + ISPASYNC_BUS_RESET, /* Bus Was Reset */ + ISPASYNC_LOOP_DOWN, /* FC Loop Down */ + ISPASYNC_LOOP_UP, /* FC Loop Up */ + ISPASYNC_PDB_CHANGED, /* FC Port Data Base Changed */ + ISPASYNC_CHANGE_NOTIFY, /* FC SNS Change Notification */ + ISPASYNC_FABRIC_DEV, /* FC New Fabric Device */ + ISPASYNC_TARGET_CMD, /* New target command */ + ISPASYNC_TARGET_EVENT /* New target event */ } ispasync_t; int isp_async __P((struct ispsoftc *, ispasync_t, void *)); @@ -475,5 +478,4 @@ int isp_async __P((struct ispsoftc *, ispasync_t, void *)); */ void isp_lostcmd __P((struct ispsoftc *, ISP_SCSI_XFER_T *)); - #endif /* _ISPVAR_H */ |