1999-07-06 00:31:35 +04:00
|
|
|
/* $NetBSD: isp_netbsd.c,v 1.15 1999/07/05 20:31:36 mjacob Exp $ */
|
|
|
|
/* release_6_5_99 */
|
1998-07-15 23:44:04 +04:00
|
|
|
/*
|
|
|
|
* Platform (NetBSD) dependent common attachment code for Qlogic adapters.
|
1999-07-06 00:31:35 +04:00
|
|
|
* Matthew Jacob <mjacob@nas.nasa.gov>
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Copyright (C) 1997, 1998, 1999 National Aeronautics & Space Administration
|
1998-07-15 23:44:04 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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
|
1999-07-06 00:31:35 +04:00
|
|
|
* notice, this list of conditions and the following disclaimer.
|
1998-07-15 23:44:04 +04:00
|
|
|
* 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
|
1999-07-06 00:31:35 +04:00
|
|
|
* derived from this software without specific prior written permission
|
1998-07-15 23:44:04 +04:00
|
|
|
*
|
1999-07-06 00:31:35 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
1998-07-15 23:44:04 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <dev/ic/isp_netbsd.h>
|
|
|
|
|
|
|
|
static void ispminphys __P((struct buf *));
|
|
|
|
static int32_t ispcmd __P((ISP_SCSI_XFER_T *));
|
|
|
|
|
|
|
|
static struct scsipi_device isp_dev = { NULL, NULL, NULL, NULL };
|
|
|
|
static int isp_poll __P((struct ispsoftc *, ISP_SCSI_XFER_T *, int));
|
1999-02-09 03:42:22 +03:00
|
|
|
static void isp_watch __P((void *));
|
|
|
|
static void isp_internal_restart __P((void *));
|
|
|
|
|
|
|
|
#define FC_OPENINGS RQUEST_QUEUE_LEN / (MAX_FC_TARG-1)
|
|
|
|
#define PI_OPENINGS RQUEST_QUEUE_LEN / (MAX_TARGETS-1)
|
1998-07-15 23:44:04 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Complete attachment of hardware, include subdevices.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
isp_attach(isp)
|
|
|
|
struct ispsoftc *isp;
|
|
|
|
{
|
1998-11-20 00:43:00 +03:00
|
|
|
|
|
|
|
isp->isp_osinfo._adapter.scsipi_cmd = ispcmd;
|
|
|
|
isp->isp_osinfo._adapter.scsipi_minphys = ispminphys;
|
|
|
|
|
1998-07-15 23:44:04 +04:00
|
|
|
isp->isp_state = ISP_RUNSTATE;
|
|
|
|
isp->isp_osinfo._link.scsipi_scsi.channel = SCSI_CHANNEL_ONLY_ONE;
|
|
|
|
isp->isp_osinfo._link.adapter_softc = isp;
|
|
|
|
isp->isp_osinfo._link.device = &isp_dev;
|
1998-11-20 00:43:00 +03:00
|
|
|
isp->isp_osinfo._link.adapter = &isp->isp_osinfo._adapter;
|
1999-02-09 03:42:22 +03:00
|
|
|
TAILQ_INIT(&isp->isp_osinfo.waitq);
|
1998-07-15 23:44:04 +04:00
|
|
|
|
1999-07-06 00:31:35 +04:00
|
|
|
if (IS_FC(isp)) {
|
1999-03-17 09:15:47 +03:00
|
|
|
/*
|
|
|
|
* Give it another chance here to come alive...
|
|
|
|
*/
|
|
|
|
fcparam *fcp = isp->isp_param;
|
|
|
|
if (fcp->isp_fwstate != FW_READY) {
|
|
|
|
(void) isp_control(isp, ISPCTL_FCLINK_TEST, NULL);
|
|
|
|
}
|
1998-07-15 23:44:04 +04:00
|
|
|
isp->isp_osinfo._link.scsipi_scsi.max_target = MAX_FC_TARG-1;
|
1999-03-17 09:15:47 +03:00
|
|
|
#ifdef ISP2100_SCCLUN
|
1998-12-05 22:48:23 +03:00
|
|
|
/*
|
|
|
|
* 16 bits worth, but let's be reasonable..
|
|
|
|
*/
|
|
|
|
isp->isp_osinfo._link.scsipi_scsi.max_lun = 255;
|
|
|
|
#else
|
|
|
|
isp->isp_osinfo._link.scsipi_scsi.max_lun = 15;
|
|
|
|
#endif
|
1999-02-09 03:42:22 +03:00
|
|
|
isp->isp_osinfo._link.openings = FC_OPENINGS;
|
1998-12-05 22:48:23 +03:00
|
|
|
isp->isp_osinfo._link.scsipi_scsi.adapter_target =
|
|
|
|
((fcparam *)isp->isp_param)->isp_loopid;
|
1998-07-15 23:44:04 +04:00
|
|
|
} else {
|
1999-05-12 22:59:23 +04:00
|
|
|
sdparam *sdp = isp->isp_param;
|
1999-02-09 03:42:22 +03:00
|
|
|
isp->isp_osinfo._link.openings = PI_OPENINGS;
|
1998-07-15 23:44:04 +04:00
|
|
|
isp->isp_osinfo._link.scsipi_scsi.max_target = MAX_TARGETS-1;
|
1998-12-05 22:48:23 +03:00
|
|
|
if (isp->isp_bustype == ISP_BT_SBUS) {
|
|
|
|
isp->isp_osinfo._link.scsipi_scsi.max_lun = 7;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Too much target breakage at present.
|
|
|
|
*/
|
|
|
|
#if 0
|
1999-04-04 06:29:34 +04:00
|
|
|
if (isp->isp_fwrev >= ISP_FW_REV(7,55,0))
|
1998-12-05 22:48:23 +03:00
|
|
|
isp->isp_osinfo._link.scsipi_scsi.max_lun = 31;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
isp->isp_osinfo._link.scsipi_scsi.max_lun = 7;
|
|
|
|
}
|
1998-07-15 23:44:04 +04:00
|
|
|
isp->isp_osinfo._link.scsipi_scsi.adapter_target =
|
1999-05-12 22:59:23 +04:00
|
|
|
sdp->isp_initiator_id;
|
|
|
|
if (IS_12X0(isp)) {
|
|
|
|
isp->isp_osinfo._link_b = isp->isp_osinfo._link;
|
|
|
|
sdp++;
|
|
|
|
isp->isp_osinfo._link_b.scsipi_scsi.adapter_target =
|
|
|
|
sdp->isp_initiator_id;
|
|
|
|
isp->isp_osinfo._link_b.scsipi_scsi.channel = 1;
|
|
|
|
}
|
1998-07-15 23:44:04 +04:00
|
|
|
}
|
|
|
|
if (isp->isp_osinfo._link.openings < 2)
|
|
|
|
isp->isp_osinfo._link.openings = 2;
|
|
|
|
isp->isp_osinfo._link.type = BUS_SCSI;
|
1998-12-28 22:10:43 +03:00
|
|
|
|
1999-02-09 03:42:22 +03:00
|
|
|
/*
|
|
|
|
* Send a SCSI Bus Reset (used to be done as part of attach,
|
|
|
|
* but now left to the OS outer layers).
|
|
|
|
*/
|
|
|
|
|
1999-05-12 22:59:23 +04:00
|
|
|
if (IS_SCSI(isp)) {
|
|
|
|
int bus = 0;
|
|
|
|
(void) isp_control(isp, ISPCTL_RESET_BUS, &bus);
|
|
|
|
if (IS_12X0(isp)) {
|
|
|
|
bus++;
|
|
|
|
(void) isp_control(isp, ISPCTL_RESET_BUS, &bus);
|
|
|
|
}
|
1999-03-17 09:15:47 +03:00
|
|
|
SYS_DELAY(2*1000000);
|
|
|
|
}
|
1999-02-09 03:42:22 +03:00
|
|
|
|
1998-12-28 22:10:43 +03:00
|
|
|
/*
|
|
|
|
* Start the watchdog.
|
|
|
|
*/
|
|
|
|
isp->isp_dogactive = 1;
|
|
|
|
timeout(isp_watch, isp, 30 * hz);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* And attach children (if any).
|
|
|
|
*/
|
1998-07-15 23:44:04 +04:00
|
|
|
config_found((void *)isp, &isp->isp_osinfo._link, scsiprint);
|
1999-05-12 22:59:23 +04:00
|
|
|
if (IS_12X0(isp)) {
|
|
|
|
config_found((void *)isp, &isp->isp_osinfo._link_b, scsiprint);
|
|
|
|
}
|
1998-07-15 23:44:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* minphys our xfers
|
|
|
|
*
|
|
|
|
* Unfortunately, the buffer pointer describes the target device- not the
|
|
|
|
* adapter device, so we can't use the pointer to find out what kind of
|
|
|
|
* adapter we are and adjust accordingly.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
ispminphys(bp)
|
|
|
|
struct buf *bp;
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* XX: Only the 1020 has a 24 bit limit.
|
|
|
|
*/
|
|
|
|
if (bp->b_bcount >= (1 << 24)) {
|
|
|
|
bp->b_bcount = (1 << 24);
|
|
|
|
}
|
|
|
|
minphys(bp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ispcmd(xs)
|
|
|
|
ISP_SCSI_XFER_T *xs;
|
|
|
|
{
|
|
|
|
struct ispsoftc *isp;
|
1998-09-08 11:19:58 +04:00
|
|
|
int result;
|
1999-02-09 03:42:22 +03:00
|
|
|
int s;
|
1998-07-15 23:44:04 +04:00
|
|
|
|
|
|
|
isp = XS_ISP(xs);
|
1999-02-09 03:42:22 +03:00
|
|
|
s = splbio();
|
1998-09-08 11:19:58 +04:00
|
|
|
/*
|
|
|
|
* This is less efficient than I would like in that the
|
|
|
|
* majority of cases will have to do some pointer deferences
|
|
|
|
* to find out that things don't need to be updated.
|
|
|
|
*/
|
|
|
|
if ((xs->flags & SCSI_AUTOCONF) == 0 && (isp->isp_type & ISP_HA_SCSI)) {
|
|
|
|
sdparam *sdp = isp->isp_param;
|
1999-05-12 22:59:23 +04:00
|
|
|
sdp += XS_CHANNEL(xs);
|
1998-09-08 11:19:58 +04:00
|
|
|
if (sdp->isp_devparam[XS_TGT(xs)].dev_flags !=
|
|
|
|
sdp->isp_devparam[XS_TGT(xs)].cur_dflags) {
|
|
|
|
u_int16_t f = DPARM_WIDE|DPARM_SYNC|DPARM_TQING;
|
|
|
|
if (xs->sc_link->quirks & SDEV_NOSYNC)
|
|
|
|
f &= ~DPARM_SYNC;
|
|
|
|
if (xs->sc_link->quirks & SDEV_NOWIDE)
|
|
|
|
f &= ~DPARM_WIDE;
|
|
|
|
if (xs->sc_link->quirks & SDEV_NOTAG)
|
|
|
|
f &= ~DPARM_TQING;
|
|
|
|
sdp->isp_devparam[XS_TGT(xs)].dev_flags &=
|
|
|
|
~(DPARM_WIDE|DPARM_SYNC|DPARM_TQING);
|
|
|
|
sdp->isp_devparam[XS_TGT(xs)].dev_flags |= f;
|
|
|
|
sdp->isp_devparam[XS_TGT(xs)].dev_update = 1;
|
1999-05-12 22:59:23 +04:00
|
|
|
isp->isp_update |= (1 << XS_CHANNEL(xs));
|
1998-09-08 11:19:58 +04:00
|
|
|
}
|
|
|
|
}
|
1999-03-17 09:15:47 +03:00
|
|
|
|
|
|
|
if (isp->isp_state < ISP_RUNSTATE) {
|
|
|
|
DISABLE_INTS(isp);
|
|
|
|
isp_init(isp);
|
|
|
|
if (isp->isp_state != ISP_INITSTATE) {
|
|
|
|
ENABLE_INTS(isp);
|
|
|
|
(void) splx(s);
|
|
|
|
XS_SETERR(xs, HBA_BOTCH);
|
|
|
|
return (CMD_COMPLETE);
|
|
|
|
}
|
|
|
|
isp->isp_state = ISP_RUNSTATE;
|
|
|
|
ENABLE_INTS(isp);
|
|
|
|
}
|
|
|
|
|
1999-02-09 03:42:22 +03:00
|
|
|
/*
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
TAILQ_INSERT_TAIL(&isp->isp_osinfo.waitq, xs, adapter_q);
|
|
|
|
splx(s);
|
|
|
|
return (CMD_QUEUED);
|
|
|
|
}
|
|
|
|
|
1999-03-17 09:15:47 +03:00
|
|
|
DISABLE_INTS(isp);
|
1998-09-08 11:19:58 +04:00
|
|
|
result = ispscsicmd(xs);
|
1999-03-17 09:15:47 +03:00
|
|
|
ENABLE_INTS(isp);
|
1998-09-08 11:19:58 +04:00
|
|
|
if (result != CMD_QUEUED || (xs->flags & SCSI_POLL) == 0) {
|
1999-02-09 03:42:22 +03:00
|
|
|
(void) splx(s);
|
1998-09-08 11:19:58 +04:00
|
|
|
return (result);
|
1998-07-15 23:44:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we can't use interrupts, poll on completion.
|
|
|
|
*/
|
|
|
|
if (isp_poll(isp, xs, XS_TIME(xs))) {
|
|
|
|
/*
|
|
|
|
* If no other error occurred but we didn't finish,
|
|
|
|
* something bad happened.
|
|
|
|
*/
|
|
|
|
if (XS_IS_CMD_DONE(xs) == 0) {
|
|
|
|
isp->isp_nactive--;
|
|
|
|
if (isp->isp_nactive < 0)
|
|
|
|
isp->isp_nactive = 0;
|
|
|
|
if (XS_NOERR(xs)) {
|
|
|
|
isp_lostcmd(isp, xs);
|
|
|
|
XS_SETERR(xs, HBA_BOTCH);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-02-09 03:42:22 +03:00
|
|
|
(void) splx(s);
|
1998-07-15 23:44:04 +04:00
|
|
|
return (CMD_COMPLETE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
isp_poll(isp, xs, mswait)
|
|
|
|
struct ispsoftc *isp;
|
|
|
|
ISP_SCSI_XFER_T *xs;
|
|
|
|
int mswait;
|
|
|
|
{
|
|
|
|
|
|
|
|
while (mswait) {
|
|
|
|
/* Try the interrupt handling routine */
|
|
|
|
(void)isp_intr((void *)isp);
|
|
|
|
|
|
|
|
/* See if the xs is now done */
|
|
|
|
if (XS_IS_CMD_DONE(xs)) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
SYS_DELAY(1000); /* wait one millisecond */
|
|
|
|
mswait--;
|
|
|
|
}
|
|
|
|
return (1);
|
|
|
|
}
|
1998-12-28 22:10:43 +03:00
|
|
|
|
|
|
|
static void
|
|
|
|
isp_watch(arg)
|
|
|
|
void *arg;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct ispsoftc *isp = arg;
|
|
|
|
ISP_SCSI_XFER_T *xs;
|
|
|
|
ISP_ILOCKVAL_DECL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for completely dead commands (but not polled ones).
|
|
|
|
*/
|
|
|
|
ISP_ILOCK(isp);
|
|
|
|
for (i = 0; i < RQUEST_QUEUE_LEN; i++) {
|
|
|
|
if ((xs = (ISP_SCSI_XFER_T *) isp->isp_xflist[i]) == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (XS_TIME(xs) == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
XS_TIME(xs) -= (WATCH_INTERVAL * 1000);
|
|
|
|
/*
|
|
|
|
* Avoid later thinking that this
|
|
|
|
* transaction is not being timed.
|
|
|
|
* Then give ourselves to watchdog
|
|
|
|
* periods of grace.
|
|
|
|
*/
|
|
|
|
if (XS_TIME(xs) == 0) {
|
|
|
|
XS_TIME(xs) = 1;
|
|
|
|
} else if (XS_TIME(xs) > -(2 * WATCH_INTERVAL * 1000)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (isp_control(isp, ISPCTL_ABORT_CMD, xs)) {
|
|
|
|
printf("%s: isp_watch failed to abort command\n",
|
|
|
|
isp->isp_name);
|
|
|
|
isp_restart(isp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
timeout(isp_watch, isp, WATCH_INTERVAL * hz);
|
|
|
|
isp->isp_dogactive = 1;
|
|
|
|
ISP_IUNLOCK(isp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free any associated resources prior to decommissioning and
|
|
|
|
* set the card to a known state (so it doesn't wake up and kick
|
|
|
|
* us when we aren't expecting it to).
|
|
|
|
*
|
|
|
|
* Locks are held before coming here.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
isp_uninit(isp)
|
|
|
|
struct ispsoftc *isp;
|
|
|
|
{
|
|
|
|
ISP_ILOCKVAL_DECL;
|
|
|
|
ISP_ILOCK(isp);
|
|
|
|
/*
|
|
|
|
* Leave with interrupts disabled.
|
|
|
|
*/
|
|
|
|
DISABLE_INTS(isp);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Turn off the watchdog (if active).
|
|
|
|
*/
|
|
|
|
if (isp->isp_dogactive) {
|
|
|
|
untimeout(isp_watch, isp);
|
|
|
|
isp->isp_dogactive = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ISP_IUNLOCK(isp);
|
|
|
|
}
|
1999-01-30 10:31:50 +03:00
|
|
|
|
1999-02-09 03:42:22 +03:00
|
|
|
/*
|
|
|
|
* Restart function after a LOOP UP event (e.g.),
|
|
|
|
* done as a timeout for some hysteresis.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
isp_internal_restart(arg)
|
|
|
|
void *arg;
|
|
|
|
{
|
|
|
|
struct ispsoftc *isp = arg;
|
1999-03-17 09:15:47 +03:00
|
|
|
int result, nrestarted = 0, s;
|
1999-02-09 03:42:22 +03:00
|
|
|
|
1999-03-17 09:15:47 +03:00
|
|
|
s = splbio();
|
1999-02-09 03:42:22 +03:00
|
|
|
if (isp->isp_osinfo.blocked == 0) {
|
|
|
|
struct scsipi_xfer *xs;
|
|
|
|
while ((xs = TAILQ_FIRST(&isp->isp_osinfo.waitq)) != NULL) {
|
|
|
|
TAILQ_REMOVE(&isp->isp_osinfo.waitq, xs, adapter_q);
|
1999-03-17 09:15:47 +03:00
|
|
|
DISABLE_INTS(isp);
|
|
|
|
result = ispscsicmd(xs);
|
|
|
|
ENABLE_INTS(isp);
|
|
|
|
if (result != CMD_QUEUED) {
|
1999-02-09 03:42:22 +03:00
|
|
|
printf("%s: botched command restart (0x%x)\n",
|
|
|
|
isp->isp_name, result);
|
|
|
|
xs->flags |= ITSDONE;
|
|
|
|
if (xs->error == XS_NOERROR)
|
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
|
|
|
scsipi_done(xs);
|
|
|
|
}
|
|
|
|
nrestarted++;
|
|
|
|
}
|
|
|
|
printf("%s: requeued %d commands\n", isp->isp_name, nrestarted);
|
|
|
|
}
|
|
|
|
(void) splx(s);
|
|
|
|
}
|
|
|
|
|
1999-01-30 10:31:50 +03:00
|
|
|
int
|
|
|
|
isp_async(isp, cmd, arg)
|
|
|
|
struct ispsoftc *isp;
|
|
|
|
ispasync_t cmd;
|
|
|
|
void *arg;
|
|
|
|
{
|
1999-05-12 22:59:23 +04:00
|
|
|
int bus, tgt;
|
1999-02-09 03:42:22 +03:00
|
|
|
int s = splbio();
|
1999-01-30 10:31:50 +03:00
|
|
|
switch (cmd) {
|
|
|
|
case ISPASYNC_NEW_TGT_PARAMS:
|
|
|
|
if (isp->isp_type & ISP_HA_SCSI) {
|
|
|
|
sdparam *sdp = isp->isp_param;
|
|
|
|
char *wt;
|
1999-05-12 22:59:23 +04:00
|
|
|
int mhz, flags, period;
|
1999-01-30 10:31:50 +03:00
|
|
|
|
|
|
|
tgt = *((int *) arg);
|
1999-05-12 22:59:23 +04:00
|
|
|
bus = (tgt >> 16) & 0xffff;
|
|
|
|
tgt &= 0xffff;
|
1999-03-27 01:39:44 +03:00
|
|
|
|
|
|
|
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 = 1000 / (period * 4);
|
|
|
|
}
|
1999-01-30 10:31:50 +03:00
|
|
|
} else {
|
1999-03-27 01:39:44 +03:00
|
|
|
mhz = 0;
|
1999-01-30 10:31:50 +03:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
1999-03-27 01:39:44 +03:00
|
|
|
if (mhz) {
|
1999-05-12 22:59:23 +04:00
|
|
|
printf("%s: Bus %d Target %d at %dMHz Max "
|
|
|
|
"Offset %d%s", isp->isp_name, bus, tgt, mhz,
|
1999-03-27 01:39:44 +03:00
|
|
|
sdp->isp_devparam[tgt].cur_offset, wt);
|
1999-01-30 10:31:50 +03:00
|
|
|
} else {
|
1999-05-12 22:59:23 +04:00
|
|
|
printf("%s: Bus %d Target %d Async Mode%s",
|
|
|
|
isp->isp_name, bus, tgt, wt);
|
1999-01-30 10:31:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1999-03-17 09:15:47 +03:00
|
|
|
case ISPASYNC_BUS_RESET:
|
1999-05-12 22:59:23 +04:00
|
|
|
if (arg)
|
|
|
|
bus = *((int *) arg);
|
|
|
|
else
|
|
|
|
bus = 0;
|
|
|
|
printf("%s: SCSI bus %d reset detected\n", isp->isp_name, bus);
|
1999-03-17 09:15:47 +03:00
|
|
|
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:
|
|
|
|
isp->isp_osinfo.blocked = 0;
|
|
|
|
timeout(isp_internal_restart, isp, 1);
|
|
|
|
printf("%s: Loop UP\n", isp->isp_name);
|
|
|
|
break;
|
1999-07-06 00:31:35 +04:00
|
|
|
case ISPASYNC_PDB_CHANGED:
|
|
|
|
if (IS_FC(isp)) {
|
|
|
|
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] = {
|
1999-03-17 09:15:47 +03:00
|
|
|
"No", "Target", "Initiator", "Target/Initiator"
|
|
|
|
};
|
1999-07-06 00:31:35 +04:00
|
|
|
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";
|
1999-03-17 09:15:47 +03:00
|
|
|
}
|
1999-07-06 00:31:35 +04:00
|
|
|
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));
|
1999-03-17 09:15:47 +03:00
|
|
|
break;
|
|
|
|
}
|
1999-07-06 00:31:35 +04:00
|
|
|
#ifdef ISP2100_FABRIC
|
1999-03-17 09:15:47 +03:00
|
|
|
case ISPASYNC_CHANGE_NOTIFY:
|
|
|
|
printf("%s: Name Server Database Changed\n", isp->isp_name);
|
|
|
|
break;
|
1999-07-06 00:31:35 +04:00
|
|
|
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
|
1999-01-30 10:31:50 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1999-02-09 03:42:22 +03:00
|
|
|
(void) splx(s);
|
1999-01-30 10:31:50 +03:00
|
|
|
return (0);
|
|
|
|
}
|