Home | History | Annotate | Line # | Download | only in ic
isp_netbsd.c revision 1.16.2.1
      1  1.16.2.1  wrstuden /* $NetBSD: isp_netbsd.c,v 1.16.2.1 1999/12/27 18:34:49 wrstuden Exp $ */
      2       1.1    mjacob /*
      3       1.1    mjacob  * Platform (NetBSD) dependent common attachment code for Qlogic adapters.
      4      1.15    mjacob  * Matthew Jacob <mjacob (at) nas.nasa.gov>
      5      1.15    mjacob  */
      6      1.15    mjacob /*
      7      1.15    mjacob  * Copyright (C) 1997, 1998, 1999 National Aeronautics & Space Administration
      8       1.1    mjacob  * All rights reserved.
      9       1.1    mjacob  *
     10       1.1    mjacob  * Redistribution and use in source and binary forms, with or without
     11       1.1    mjacob  * modification, are permitted provided that the following conditions
     12       1.1    mjacob  * are met:
     13       1.1    mjacob  * 1. Redistributions of source code must retain the above copyright
     14      1.15    mjacob  *    notice, this list of conditions and the following disclaimer.
     15       1.1    mjacob  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1    mjacob  *    notice, this list of conditions and the following disclaimer in the
     17       1.1    mjacob  *    documentation and/or other materials provided with the distribution.
     18       1.1    mjacob  * 3. The name of the author may not be used to endorse or promote products
     19      1.15    mjacob  *    derived from this software without specific prior written permission
     20       1.1    mjacob  *
     21      1.15    mjacob  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22      1.15    mjacob  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23      1.15    mjacob  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24      1.15    mjacob  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25      1.15    mjacob  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26      1.15    mjacob  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27      1.15    mjacob  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28      1.15    mjacob  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29      1.15    mjacob  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30      1.15    mjacob  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31       1.1    mjacob  */
     32       1.1    mjacob 
     33       1.1    mjacob #include <dev/ic/isp_netbsd.h>
     34  1.16.2.1  wrstuden #include <sys/scsiio.h>
     35       1.1    mjacob 
     36       1.1    mjacob static void ispminphys __P((struct buf *));
     37  1.16.2.1  wrstuden static int32_t ispcmd_slow __P((ISP_SCSI_XFER_T *));
     38       1.1    mjacob static int32_t ispcmd __P((ISP_SCSI_XFER_T *));
     39  1.16.2.1  wrstuden static int
     40  1.16.2.1  wrstuden ispioctl __P((struct scsipi_link *, u_long, caddr_t, int, struct proc *));
     41       1.1    mjacob 
     42       1.1    mjacob static struct scsipi_device isp_dev = { NULL, NULL, NULL, NULL };
     43       1.1    mjacob static int isp_poll __P((struct ispsoftc *, ISP_SCSI_XFER_T *, int));
     44      1.10    mjacob static void isp_watch __P((void *));
     45  1.16.2.1  wrstuden static void isp_command_requeue __P((void *));
     46      1.10    mjacob static void isp_internal_restart __P((void *));
     47      1.10    mjacob 
     48       1.1    mjacob /*
     49       1.1    mjacob  * Complete attachment of hardware, include subdevices.
     50       1.1    mjacob  */
     51       1.1    mjacob void
     52       1.1    mjacob isp_attach(isp)
     53       1.1    mjacob 	struct ispsoftc *isp;
     54       1.1    mjacob {
     55       1.6   thorpej 
     56       1.6   thorpej 	isp->isp_osinfo._adapter.scsipi_minphys = ispminphys;
     57  1.16.2.1  wrstuden 	isp->isp_osinfo._adapter.scsipi_ioctl = ispioctl;
     58       1.6   thorpej 
     59       1.1    mjacob 	isp->isp_state = ISP_RUNSTATE;
     60  1.16.2.1  wrstuden 	isp->isp_osinfo._link.scsipi_scsi.channel =
     61  1.16.2.1  wrstuden 	    (IS_DUALBUS(isp))? 0 : SCSI_CHANNEL_ONLY_ONE;
     62       1.1    mjacob 	isp->isp_osinfo._link.adapter_softc = isp;
     63       1.1    mjacob 	isp->isp_osinfo._link.device = &isp_dev;
     64       1.6   thorpej 	isp->isp_osinfo._link.adapter = &isp->isp_osinfo._adapter;
     65  1.16.2.1  wrstuden 	isp->isp_osinfo._link.openings = isp->isp_maxcmds;
     66  1.16.2.1  wrstuden 	TAILQ_INIT(&isp->isp_osinfo.waitq);	/* XXX 2nd Bus? */
     67       1.1    mjacob 
     68      1.15    mjacob 	if (IS_FC(isp)) {
     69      1.11    mjacob 		/*
     70      1.11    mjacob 		 * Give it another chance here to come alive...
     71      1.11    mjacob 		 */
     72  1.16.2.1  wrstuden 		isp->isp_osinfo._adapter.scsipi_cmd = ispcmd;
     73       1.1    mjacob 		isp->isp_osinfo._link.scsipi_scsi.max_target = MAX_FC_TARG-1;
     74      1.11    mjacob #ifdef	ISP2100_SCCLUN
     75       1.7    mjacob 		/*
     76       1.7    mjacob 		 * 16 bits worth, but let's be reasonable..
     77       1.7    mjacob 		 */
     78       1.7    mjacob 		isp->isp_osinfo._link.scsipi_scsi.max_lun = 255;
     79       1.7    mjacob #else
     80       1.7    mjacob 		isp->isp_osinfo._link.scsipi_scsi.max_lun = 15;
     81       1.7    mjacob #endif
     82  1.16.2.1  wrstuden 		/* set below */
     83       1.1    mjacob 	} else {
     84      1.14    mjacob 		sdparam *sdp = isp->isp_param;
     85  1.16.2.1  wrstuden 		isp->isp_osinfo._adapter.scsipi_cmd = ispcmd_slow;
     86       1.1    mjacob 		isp->isp_osinfo._link.scsipi_scsi.max_target = MAX_TARGETS-1;
     87  1.16.2.1  wrstuden 		isp->isp_osinfo._link.scsipi_scsi.max_lun = 7;
     88       1.1    mjacob 		isp->isp_osinfo._link.scsipi_scsi.adapter_target =
     89      1.14    mjacob 		    sdp->isp_initiator_id;
     90  1.16.2.1  wrstuden 		isp->isp_osinfo.discovered[0] = 1 << sdp->isp_initiator_id;
     91  1.16.2.1  wrstuden 		if (IS_DUALBUS(isp)) {
     92      1.14    mjacob 			isp->isp_osinfo._link_b = isp->isp_osinfo._link;
     93      1.14    mjacob 			sdp++;
     94  1.16.2.1  wrstuden 			isp->isp_osinfo.discovered[1] =
     95  1.16.2.1  wrstuden 			    1 << sdp->isp_initiator_id;
     96      1.14    mjacob 			isp->isp_osinfo._link_b.scsipi_scsi.adapter_target =
     97      1.14    mjacob 			    sdp->isp_initiator_id;
     98      1.14    mjacob 			isp->isp_osinfo._link_b.scsipi_scsi.channel = 1;
     99      1.14    mjacob 		}
    100       1.1    mjacob 	}
    101       1.1    mjacob 	isp->isp_osinfo._link.type = BUS_SCSI;
    102       1.8    mjacob 
    103       1.8    mjacob 	/*
    104      1.10    mjacob 	 * Send a SCSI Bus Reset (used to be done as part of attach,
    105      1.10    mjacob 	 * but now left to the OS outer layers).
    106      1.10    mjacob 	 */
    107      1.14    mjacob 	if (IS_SCSI(isp)) {
    108      1.14    mjacob 		int bus = 0;
    109      1.14    mjacob 		(void) isp_control(isp, ISPCTL_RESET_BUS, &bus);
    110  1.16.2.1  wrstuden 		if (IS_DUALBUS(isp)) {
    111      1.14    mjacob 			bus++;
    112      1.14    mjacob 			(void) isp_control(isp, ISPCTL_RESET_BUS, &bus);
    113      1.14    mjacob 		}
    114      1.11    mjacob 		SYS_DELAY(2*1000000);
    115  1.16.2.1  wrstuden 	} else {
    116  1.16.2.1  wrstuden 		int i, j;
    117  1.16.2.1  wrstuden 		fcparam *fcp = isp->isp_param;
    118  1.16.2.1  wrstuden 		delay(2 * 1000000);
    119  1.16.2.1  wrstuden 		for (j = 0; j < 5; j++) {
    120  1.16.2.1  wrstuden 			for (i = 0; i < 5; i++) {
    121  1.16.2.1  wrstuden 				if (isp_control(isp, ISPCTL_FCLINK_TEST, NULL))
    122  1.16.2.1  wrstuden 					continue;
    123  1.16.2.1  wrstuden #ifdef	ISP2100_FABRIC
    124  1.16.2.1  wrstuden 				/*
    125  1.16.2.1  wrstuden 				 * Wait extra time to see if the f/w
    126  1.16.2.1  wrstuden 				 * eventually completed an FLOGI that
    127  1.16.2.1  wrstuden 				 * will allow us to know we're on a
    128  1.16.2.1  wrstuden 				 * fabric.
    129  1.16.2.1  wrstuden 				 */
    130  1.16.2.1  wrstuden 				if (fcp->isp_onfabric == 0) {
    131  1.16.2.1  wrstuden 					delay(1 * 1000000);
    132  1.16.2.1  wrstuden 					continue;
    133  1.16.2.1  wrstuden 				}
    134  1.16.2.1  wrstuden #endif
    135  1.16.2.1  wrstuden 				break;
    136  1.16.2.1  wrstuden 			}
    137  1.16.2.1  wrstuden 			if (fcp->isp_fwstate == FW_READY &&
    138  1.16.2.1  wrstuden 			    fcp->isp_loopstate >= LOOP_PDB_RCVD) {
    139  1.16.2.1  wrstuden 				break;
    140  1.16.2.1  wrstuden 			}
    141  1.16.2.1  wrstuden 		}
    142  1.16.2.1  wrstuden 		isp->isp_osinfo._link.scsipi_scsi.adapter_target =
    143  1.16.2.1  wrstuden 			fcp->isp_loopid;
    144      1.11    mjacob 	}
    145      1.10    mjacob 
    146      1.10    mjacob 	/*
    147       1.8    mjacob 	 * Start the watchdog.
    148       1.8    mjacob 	 */
    149       1.8    mjacob 	isp->isp_dogactive = 1;
    150  1.16.2.1  wrstuden 	timeout(isp_watch, isp, WATCH_INTERVAL * hz);
    151       1.8    mjacob 
    152       1.8    mjacob 	/*
    153       1.8    mjacob 	 * And attach children (if any).
    154       1.8    mjacob 	 */
    155       1.1    mjacob 	config_found((void *)isp, &isp->isp_osinfo._link, scsiprint);
    156  1.16.2.1  wrstuden 	if (IS_DUALBUS(isp)) {
    157      1.14    mjacob 		config_found((void *)isp, &isp->isp_osinfo._link_b, scsiprint);
    158      1.14    mjacob 	}
    159       1.1    mjacob }
    160       1.1    mjacob 
    161       1.1    mjacob /*
    162       1.1    mjacob  * minphys our xfers
    163       1.1    mjacob  *
    164       1.1    mjacob  * Unfortunately, the buffer pointer describes the target device- not the
    165       1.1    mjacob  * adapter device, so we can't use the pointer to find out what kind of
    166       1.1    mjacob  * adapter we are and adjust accordingly.
    167       1.1    mjacob  */
    168       1.1    mjacob 
    169       1.1    mjacob static void
    170       1.1    mjacob ispminphys(bp)
    171       1.1    mjacob 	struct buf *bp;
    172       1.1    mjacob {
    173       1.1    mjacob 	/*
    174       1.1    mjacob 	 * XX: Only the 1020 has a 24 bit limit.
    175       1.1    mjacob 	 */
    176       1.1    mjacob 	if (bp->b_bcount >= (1 << 24)) {
    177       1.1    mjacob 		bp->b_bcount = (1 << 24);
    178       1.1    mjacob 	}
    179       1.1    mjacob 	minphys(bp);
    180       1.1    mjacob }
    181       1.1    mjacob 
    182  1.16.2.1  wrstuden static int32_t
    183  1.16.2.1  wrstuden ispcmd_slow(xs)
    184  1.16.2.1  wrstuden 	ISP_SCSI_XFER_T *xs;
    185  1.16.2.1  wrstuden {
    186  1.16.2.1  wrstuden 	sdparam *sdp;
    187  1.16.2.1  wrstuden 	int tgt, chan, s;
    188  1.16.2.1  wrstuden 	u_int16_t flags;
    189  1.16.2.1  wrstuden 	struct ispsoftc *isp = XS_ISP(xs);
    190  1.16.2.1  wrstuden 
    191  1.16.2.1  wrstuden 	/*
    192  1.16.2.1  wrstuden 	 * Have we completed discovery for this target on this adapter?
    193  1.16.2.1  wrstuden 	 */
    194  1.16.2.1  wrstuden 	tgt = XS_TGT(xs);
    195  1.16.2.1  wrstuden 	chan = XS_CHANNEL(xs);
    196  1.16.2.1  wrstuden 	if ((xs->xs_control & XS_CTL_DISCOVERY) != 0 ||
    197  1.16.2.1  wrstuden 	    (isp->isp_osinfo.discovered[chan] & (1 << tgt)) != 0) {
    198  1.16.2.1  wrstuden 		return (ispcmd(xs));
    199  1.16.2.1  wrstuden 	}
    200  1.16.2.1  wrstuden 
    201  1.16.2.1  wrstuden 	flags = DPARM_DEFAULT;
    202  1.16.2.1  wrstuden 	if (xs->sc_link->quirks & SDEV_NOSYNC) {
    203  1.16.2.1  wrstuden 		flags ^= DPARM_SYNC;
    204  1.16.2.1  wrstuden #ifdef	DEBUG
    205  1.16.2.1  wrstuden 	} else {
    206  1.16.2.1  wrstuden 		printf("%s: channel %d target %d can do SYNC xfers\n",
    207  1.16.2.1  wrstuden 		    isp->isp_name, chan, tgt);
    208  1.16.2.1  wrstuden #endif
    209  1.16.2.1  wrstuden 	}
    210  1.16.2.1  wrstuden 	if (xs->sc_link->quirks & SDEV_NOWIDE) {
    211  1.16.2.1  wrstuden 		flags ^= DPARM_WIDE;
    212  1.16.2.1  wrstuden #ifdef	DEBUG
    213  1.16.2.1  wrstuden 	} else {
    214  1.16.2.1  wrstuden 		printf("%s: channel %d target %d can do WIDE xfers\n",
    215  1.16.2.1  wrstuden 		    isp->isp_name, chan, tgt);
    216  1.16.2.1  wrstuden #endif
    217  1.16.2.1  wrstuden 	}
    218  1.16.2.1  wrstuden 	if (xs->sc_link->quirks & SDEV_NOTAG) {
    219  1.16.2.1  wrstuden 		flags ^= DPARM_TQING;
    220  1.16.2.1  wrstuden #ifdef	DEBUG
    221  1.16.2.1  wrstuden 	} else {
    222  1.16.2.1  wrstuden 		printf("%s: channel %d target %d can do TAGGED xfers\n",
    223  1.16.2.1  wrstuden 		    isp->isp_name, chan, tgt);
    224  1.16.2.1  wrstuden #endif
    225  1.16.2.1  wrstuden 	}
    226  1.16.2.1  wrstuden 	/*
    227  1.16.2.1  wrstuden 	 * Okay, we know about this device now,
    228  1.16.2.1  wrstuden 	 * so mark parameters to be updated for it.
    229  1.16.2.1  wrstuden 	 */
    230  1.16.2.1  wrstuden 	s = splbio();
    231  1.16.2.1  wrstuden 	isp->isp_osinfo.discovered[chan] |= (1 << tgt);
    232  1.16.2.1  wrstuden 	sdp = isp->isp_param;
    233  1.16.2.1  wrstuden 	sdp += chan;
    234  1.16.2.1  wrstuden 	sdp->isp_devparam[tgt].dev_flags = flags;
    235  1.16.2.1  wrstuden 	sdp->isp_devparam[tgt].dev_update = 1;
    236  1.16.2.1  wrstuden 	isp->isp_update |= (1 << chan);
    237  1.16.2.1  wrstuden 	splx(s);
    238  1.16.2.1  wrstuden 	return (ispcmd(xs));
    239  1.16.2.1  wrstuden }
    240  1.16.2.1  wrstuden 
    241  1.16.2.1  wrstuden static int
    242  1.16.2.1  wrstuden ispioctl(sc_link, cmd, addr, flag, p)
    243  1.16.2.1  wrstuden 	struct scsipi_link *sc_link;
    244  1.16.2.1  wrstuden 	u_long cmd;
    245  1.16.2.1  wrstuden 	caddr_t addr;
    246  1.16.2.1  wrstuden 	int flag;
    247  1.16.2.1  wrstuden 	struct proc *p;
    248  1.16.2.1  wrstuden {
    249  1.16.2.1  wrstuden 	struct ispsoftc *isp = sc_link->adapter_softc;
    250  1.16.2.1  wrstuden 	int s, chan, retval = ENOTTY;
    251  1.16.2.1  wrstuden 
    252  1.16.2.1  wrstuden 	switch (cmd) {
    253  1.16.2.1  wrstuden 	case SCBUSIORESET:
    254  1.16.2.1  wrstuden 		chan = sc_link->scsipi_scsi.channel;
    255  1.16.2.1  wrstuden 		s = splbio();
    256  1.16.2.1  wrstuden 		if (isp_control(isp, ISPCTL_RESET_BUS, &chan))
    257  1.16.2.1  wrstuden 			retval = EIO;
    258  1.16.2.1  wrstuden 		else
    259  1.16.2.1  wrstuden 			retval = 0;
    260  1.16.2.1  wrstuden 		(void) splx(s);
    261  1.16.2.1  wrstuden 		break;
    262  1.16.2.1  wrstuden 	default:
    263  1.16.2.1  wrstuden 		break;
    264  1.16.2.1  wrstuden 	}
    265  1.16.2.1  wrstuden 	return (retval);
    266  1.16.2.1  wrstuden }
    267  1.16.2.1  wrstuden 
    268  1.16.2.1  wrstuden 
    269  1.16.2.1  wrstuden static int32_t
    270       1.1    mjacob ispcmd(xs)
    271       1.1    mjacob 	ISP_SCSI_XFER_T *xs;
    272       1.1    mjacob {
    273       1.1    mjacob 	struct ispsoftc *isp;
    274  1.16.2.1  wrstuden 	int result, s;
    275       1.1    mjacob 
    276       1.1    mjacob 	isp = XS_ISP(xs);
    277      1.10    mjacob 	s = splbio();
    278      1.11    mjacob 	if (isp->isp_state < ISP_RUNSTATE) {
    279      1.11    mjacob 		DISABLE_INTS(isp);
    280      1.11    mjacob 		isp_init(isp);
    281      1.11    mjacob                 if (isp->isp_state != ISP_INITSTATE) {
    282      1.11    mjacob 			ENABLE_INTS(isp);
    283      1.11    mjacob                         (void) splx(s);
    284      1.11    mjacob                         XS_SETERR(xs, HBA_BOTCH);
    285  1.16.2.1  wrstuden                         return (COMPLETE);
    286      1.11    mjacob                 }
    287      1.11    mjacob                 isp->isp_state = ISP_RUNSTATE;
    288      1.11    mjacob 		ENABLE_INTS(isp);
    289      1.11    mjacob         }
    290      1.11    mjacob 
    291      1.10    mjacob 	/*
    292      1.10    mjacob 	 * Check for queue blockage...
    293      1.10    mjacob 	 */
    294      1.10    mjacob 	if (isp->isp_osinfo.blocked) {
    295      1.16   thorpej 		if (xs->xs_control & XS_CTL_POLL) {
    296      1.10    mjacob 			xs->error = XS_DRIVER_STUFFUP;
    297      1.10    mjacob 			splx(s);
    298      1.10    mjacob 			return (TRY_AGAIN_LATER);
    299      1.10    mjacob 		}
    300      1.10    mjacob 		TAILQ_INSERT_TAIL(&isp->isp_osinfo.waitq, xs, adapter_q);
    301      1.10    mjacob 		splx(s);
    302  1.16.2.1  wrstuden 		return (SUCCESSFULLY_QUEUED);
    303      1.10    mjacob 	}
    304      1.11    mjacob 	DISABLE_INTS(isp);
    305       1.3    mjacob 	result = ispscsicmd(xs);
    306      1.11    mjacob 	ENABLE_INTS(isp);
    307  1.16.2.1  wrstuden 
    308  1.16.2.1  wrstuden 	if ((xs->xs_control & XS_CTL_POLL) == 0) {
    309  1.16.2.1  wrstuden 		switch (result) {
    310  1.16.2.1  wrstuden 		case CMD_QUEUED:
    311  1.16.2.1  wrstuden 			result = SUCCESSFULLY_QUEUED;
    312  1.16.2.1  wrstuden 			break;
    313  1.16.2.1  wrstuden 		case CMD_EAGAIN:
    314  1.16.2.1  wrstuden 			result = TRY_AGAIN_LATER;
    315  1.16.2.1  wrstuden 			break;
    316  1.16.2.1  wrstuden 		case CMD_RQLATER:
    317  1.16.2.1  wrstuden 			result = SUCCESSFULLY_QUEUED;
    318  1.16.2.1  wrstuden 			timeout(isp_command_requeue, xs, hz);
    319  1.16.2.1  wrstuden 			break;
    320  1.16.2.1  wrstuden 		case CMD_COMPLETE:
    321  1.16.2.1  wrstuden 			result = COMPLETE;
    322  1.16.2.1  wrstuden 			break;
    323  1.16.2.1  wrstuden 		}
    324      1.10    mjacob 		(void) splx(s);
    325       1.3    mjacob 		return (result);
    326       1.1    mjacob 	}
    327       1.1    mjacob 
    328  1.16.2.1  wrstuden 	switch (result) {
    329  1.16.2.1  wrstuden 	case CMD_QUEUED:
    330  1.16.2.1  wrstuden 		result = SUCCESSFULLY_QUEUED;
    331  1.16.2.1  wrstuden 		break;
    332  1.16.2.1  wrstuden 	case CMD_RQLATER:
    333  1.16.2.1  wrstuden 	case CMD_EAGAIN:
    334  1.16.2.1  wrstuden 		if (XS_NOERR(xs)) {
    335  1.16.2.1  wrstuden 			xs->error = XS_DRIVER_STUFFUP;
    336  1.16.2.1  wrstuden 		}
    337  1.16.2.1  wrstuden 		result = TRY_AGAIN_LATER;
    338  1.16.2.1  wrstuden 		break;
    339  1.16.2.1  wrstuden 	case CMD_COMPLETE:
    340  1.16.2.1  wrstuden 		result = COMPLETE;
    341  1.16.2.1  wrstuden 		break;
    342  1.16.2.1  wrstuden 
    343  1.16.2.1  wrstuden 	}
    344       1.1    mjacob 	/*
    345       1.1    mjacob 	 * If we can't use interrupts, poll on completion.
    346       1.1    mjacob 	 */
    347  1.16.2.1  wrstuden 	if (result == SUCCESSFULLY_QUEUED) {
    348  1.16.2.1  wrstuden 		if (isp_poll(isp, xs, XS_TIME(xs))) {
    349  1.16.2.1  wrstuden 			/*
    350  1.16.2.1  wrstuden 			 * If no other error occurred but we didn't finish,
    351  1.16.2.1  wrstuden 			 * something bad happened.
    352  1.16.2.1  wrstuden 			 */
    353  1.16.2.1  wrstuden 			if (XS_IS_CMD_DONE(xs) == 0) {
    354  1.16.2.1  wrstuden 				if (isp_control(isp, ISPCTL_ABORT_CMD, xs)) {
    355  1.16.2.1  wrstuden 					isp_restart(isp);
    356  1.16.2.1  wrstuden 				}
    357  1.16.2.1  wrstuden 				if (XS_NOERR(xs)) {
    358  1.16.2.1  wrstuden 					XS_SETERR(xs, HBA_BOTCH);
    359  1.16.2.1  wrstuden 				}
    360       1.1    mjacob 			}
    361       1.1    mjacob 		}
    362  1.16.2.1  wrstuden 		result = COMPLETE;
    363       1.1    mjacob 	}
    364      1.10    mjacob 	(void) splx(s);
    365  1.16.2.1  wrstuden 	return (result);
    366       1.1    mjacob }
    367       1.1    mjacob 
    368       1.1    mjacob static int
    369       1.1    mjacob isp_poll(isp, xs, mswait)
    370       1.1    mjacob 	struct ispsoftc *isp;
    371       1.1    mjacob 	ISP_SCSI_XFER_T *xs;
    372       1.1    mjacob 	int mswait;
    373       1.1    mjacob {
    374       1.1    mjacob 
    375       1.1    mjacob 	while (mswait) {
    376       1.1    mjacob 		/* Try the interrupt handling routine */
    377       1.1    mjacob 		(void)isp_intr((void *)isp);
    378       1.1    mjacob 
    379       1.1    mjacob 		/* See if the xs is now done */
    380       1.1    mjacob 		if (XS_IS_CMD_DONE(xs)) {
    381       1.1    mjacob 			return (0);
    382       1.1    mjacob 		}
    383       1.1    mjacob 		SYS_DELAY(1000);	/* wait one millisecond */
    384       1.1    mjacob 		mswait--;
    385       1.1    mjacob 	}
    386       1.1    mjacob 	return (1);
    387       1.8    mjacob }
    388       1.8    mjacob 
    389       1.8    mjacob static void
    390       1.8    mjacob isp_watch(arg)
    391       1.8    mjacob 	void *arg;
    392       1.8    mjacob {
    393       1.8    mjacob 	int i;
    394       1.8    mjacob 	struct ispsoftc *isp = arg;
    395  1.16.2.1  wrstuden 	struct scsipi_xfer *xs;
    396  1.16.2.1  wrstuden 	int s;
    397       1.8    mjacob 
    398       1.8    mjacob 	/*
    399       1.8    mjacob 	 * Look for completely dead commands (but not polled ones).
    400       1.8    mjacob 	 */
    401  1.16.2.1  wrstuden 	s = splbio();
    402  1.16.2.1  wrstuden 	for (i = 0; i < isp->isp_maxcmds; i++) {
    403  1.16.2.1  wrstuden 		xs = isp->isp_xflist[i];
    404  1.16.2.1  wrstuden 		if (xs == NULL) {
    405       1.8    mjacob 			continue;
    406       1.8    mjacob 		}
    407  1.16.2.1  wrstuden 		if (xs->timeout == 0 || (xs->xs_control & XS_CTL_POLL)) {
    408       1.8    mjacob 			continue;
    409       1.8    mjacob 		}
    410  1.16.2.1  wrstuden 		xs->timeout -= (WATCH_INTERVAL * 1000);
    411       1.8    mjacob 		/*
    412       1.8    mjacob 		 * Avoid later thinking that this
    413       1.8    mjacob 		 * transaction is not being timed.
    414       1.8    mjacob 		 * Then give ourselves to watchdog
    415       1.8    mjacob 		 * periods of grace.
    416       1.8    mjacob 		 */
    417  1.16.2.1  wrstuden 		if (xs->timeout == 0) {
    418  1.16.2.1  wrstuden 			xs->timeout = 1;
    419  1.16.2.1  wrstuden 		} else if (xs->timeout > -(2 * WATCH_INTERVAL * 1000)) {
    420       1.8    mjacob 			continue;
    421       1.8    mjacob 		}
    422       1.8    mjacob 		if (isp_control(isp, ISPCTL_ABORT_CMD, xs)) {
    423       1.8    mjacob 			printf("%s: isp_watch failed to abort command\n",
    424       1.8    mjacob 			    isp->isp_name);
    425       1.8    mjacob 			isp_restart(isp);
    426       1.8    mjacob 			break;
    427       1.8    mjacob 		}
    428       1.8    mjacob 	}
    429       1.8    mjacob 	timeout(isp_watch, isp, WATCH_INTERVAL * hz);
    430       1.8    mjacob 	isp->isp_dogactive = 1;
    431  1.16.2.1  wrstuden 	(void) splx(s);
    432       1.8    mjacob }
    433       1.8    mjacob 
    434       1.8    mjacob /*
    435       1.8    mjacob  * Free any associated resources prior to decommissioning and
    436       1.8    mjacob  * set the card to a known state (so it doesn't wake up and kick
    437       1.8    mjacob  * us when we aren't expecting it to).
    438       1.8    mjacob  *
    439       1.8    mjacob  * Locks are held before coming here.
    440       1.8    mjacob  */
    441       1.8    mjacob void
    442       1.8    mjacob isp_uninit(isp)
    443       1.8    mjacob 	struct ispsoftc *isp;
    444       1.8    mjacob {
    445       1.8    mjacob 	ISP_ILOCKVAL_DECL;
    446       1.8    mjacob 	ISP_ILOCK(isp);
    447       1.8    mjacob 	/*
    448       1.8    mjacob 	 * Leave with interrupts disabled.
    449       1.8    mjacob 	 */
    450       1.8    mjacob 	DISABLE_INTS(isp);
    451       1.8    mjacob 
    452       1.8    mjacob 	/*
    453       1.8    mjacob 	 * Turn off the watchdog (if active).
    454       1.8    mjacob 	 */
    455       1.8    mjacob 	if (isp->isp_dogactive) {
    456       1.8    mjacob 		untimeout(isp_watch, isp);
    457       1.8    mjacob 		isp->isp_dogactive = 0;
    458       1.8    mjacob 	}
    459       1.8    mjacob 
    460       1.8    mjacob 	ISP_IUNLOCK(isp);
    461       1.9    mjacob }
    462       1.9    mjacob 
    463      1.10    mjacob /*
    464  1.16.2.1  wrstuden  * Restart function for a command to be requeued later.
    465  1.16.2.1  wrstuden  */
    466  1.16.2.1  wrstuden static void
    467  1.16.2.1  wrstuden isp_command_requeue(arg)
    468  1.16.2.1  wrstuden 	void *arg;
    469  1.16.2.1  wrstuden {
    470  1.16.2.1  wrstuden 	struct scsipi_xfer *xs = arg;
    471  1.16.2.1  wrstuden 	struct ispsoftc *isp = XS_ISP(xs);
    472  1.16.2.1  wrstuden 	int s = splbio();
    473  1.16.2.1  wrstuden 	switch (ispcmd_slow(xs)) {
    474  1.16.2.1  wrstuden 	case SUCCESSFULLY_QUEUED:
    475  1.16.2.1  wrstuden 		printf("%s: isp_command_requeue: requeued for %d.%d\n",
    476  1.16.2.1  wrstuden 		    isp->isp_name, XS_TGT(xs), XS_LUN(xs));
    477  1.16.2.1  wrstuden 		break;
    478  1.16.2.1  wrstuden 	case TRY_AGAIN_LATER:
    479  1.16.2.1  wrstuden 		printf("%s: EAGAIN for %d.%d\n",
    480  1.16.2.1  wrstuden 		    isp->isp_name, XS_TGT(xs), XS_LUN(xs));
    481  1.16.2.1  wrstuden 		/* FALLTHROUGH */
    482  1.16.2.1  wrstuden 	case COMPLETE:
    483  1.16.2.1  wrstuden 		/* can only be an error */
    484  1.16.2.1  wrstuden 		xs->xs_status |= XS_STS_DONE;
    485  1.16.2.1  wrstuden 		if (XS_NOERR(xs)) {
    486  1.16.2.1  wrstuden 			XS_SETERR(xs, HBA_BOTCH);
    487  1.16.2.1  wrstuden 		}
    488  1.16.2.1  wrstuden 		scsipi_done(xs);
    489  1.16.2.1  wrstuden 		break;
    490  1.16.2.1  wrstuden 	}
    491  1.16.2.1  wrstuden 	(void) splx(s);
    492  1.16.2.1  wrstuden }
    493  1.16.2.1  wrstuden 
    494  1.16.2.1  wrstuden /*
    495      1.10    mjacob  * Restart function after a LOOP UP event (e.g.),
    496      1.10    mjacob  * done as a timeout for some hysteresis.
    497      1.10    mjacob  */
    498      1.10    mjacob static void
    499      1.10    mjacob isp_internal_restart(arg)
    500      1.10    mjacob 	void *arg;
    501      1.10    mjacob {
    502      1.10    mjacob 	struct ispsoftc *isp = arg;
    503      1.11    mjacob 	int result, nrestarted = 0, s;
    504      1.10    mjacob 
    505      1.11    mjacob 	s = splbio();
    506      1.10    mjacob 	if (isp->isp_osinfo.blocked == 0) {
    507      1.10    mjacob 		struct scsipi_xfer *xs;
    508      1.10    mjacob 		while ((xs = TAILQ_FIRST(&isp->isp_osinfo.waitq)) != NULL) {
    509      1.10    mjacob 			TAILQ_REMOVE(&isp->isp_osinfo.waitq, xs, adapter_q);
    510      1.11    mjacob 			DISABLE_INTS(isp);
    511      1.11    mjacob 			result = ispscsicmd(xs);
    512      1.11    mjacob 			ENABLE_INTS(isp);
    513      1.11    mjacob 			if (result != CMD_QUEUED) {
    514      1.10    mjacob 				printf("%s: botched command restart (0x%x)\n",
    515      1.10    mjacob 				    isp->isp_name, result);
    516      1.16   thorpej 				xs->xs_status |= XS_STS_DONE;
    517      1.10    mjacob 				if (xs->error == XS_NOERROR)
    518      1.10    mjacob 					xs->error = XS_DRIVER_STUFFUP;
    519      1.10    mjacob 				scsipi_done(xs);
    520      1.10    mjacob 			}
    521      1.10    mjacob 			nrestarted++;
    522      1.10    mjacob 		}
    523      1.10    mjacob 		printf("%s: requeued %d commands\n", isp->isp_name, nrestarted);
    524      1.10    mjacob 	}
    525      1.10    mjacob 	(void) splx(s);
    526      1.10    mjacob }
    527  1.16.2.1  wrstuden 
    528       1.9    mjacob int
    529       1.9    mjacob isp_async(isp, cmd, arg)
    530       1.9    mjacob 	struct ispsoftc *isp;
    531       1.9    mjacob 	ispasync_t cmd;
    532       1.9    mjacob 	void *arg;
    533       1.9    mjacob {
    534      1.14    mjacob 	int bus, tgt;
    535      1.10    mjacob 	int s = splbio();
    536       1.9    mjacob 	switch (cmd) {
    537       1.9    mjacob 	case ISPASYNC_NEW_TGT_PARAMS:
    538  1.16.2.1  wrstuden 	if (IS_SCSI(isp) && isp->isp_dblev) {
    539  1.16.2.1  wrstuden 		sdparam *sdp = isp->isp_param;
    540  1.16.2.1  wrstuden 		char *wt;
    541  1.16.2.1  wrstuden 		int mhz, flags, period;
    542  1.16.2.1  wrstuden 
    543  1.16.2.1  wrstuden 		tgt = *((int *) arg);
    544  1.16.2.1  wrstuden 		bus = (tgt >> 16) & 0xffff;
    545  1.16.2.1  wrstuden 		tgt &= 0xffff;
    546  1.16.2.1  wrstuden 		sdp += bus;
    547  1.16.2.1  wrstuden 		flags = sdp->isp_devparam[tgt].cur_dflags;
    548  1.16.2.1  wrstuden 		period = sdp->isp_devparam[tgt].cur_period;
    549  1.16.2.1  wrstuden 
    550  1.16.2.1  wrstuden 		if ((flags & DPARM_SYNC) && period &&
    551  1.16.2.1  wrstuden 		    (sdp->isp_devparam[tgt].cur_offset) != 0) {
    552  1.16.2.1  wrstuden #if	0
    553  1.16.2.1  wrstuden 			/* CAUSES PANICS */
    554  1.16.2.1  wrstuden 			static char *m = "%s: bus %d now %s mode\n";
    555  1.16.2.1  wrstuden 			u_int16_t r, l;
    556  1.16.2.1  wrstuden 			if (bus == 1)
    557  1.16.2.1  wrstuden 				r = SXP_PINS_DIFF | SXP_BANK1_SELECT;
    558  1.16.2.1  wrstuden 			else
    559  1.16.2.1  wrstuden 				r = SXP_PINS_DIFF;
    560  1.16.2.1  wrstuden 			l = ISP_READ(isp, r) & ISP1080_MODE_MASK;
    561  1.16.2.1  wrstuden 			switch (l) {
    562  1.16.2.1  wrstuden 			case ISP1080_LVD_MODE:
    563  1.16.2.1  wrstuden 				sdp->isp_lvdmode = 1;
    564  1.16.2.1  wrstuden 				printf(m, isp->isp_name, bus, "LVD");
    565  1.16.2.1  wrstuden 				break;
    566  1.16.2.1  wrstuden 			case ISP1080_HVD_MODE:
    567  1.16.2.1  wrstuden 				sdp->isp_diffmode = 1;
    568  1.16.2.1  wrstuden 				printf(m, isp->isp_name, bus, "Differential");
    569  1.16.2.1  wrstuden 				break;
    570  1.16.2.1  wrstuden 			case ISP1080_SE_MODE:
    571  1.16.2.1  wrstuden 				sdp->isp_ultramode = 1;
    572  1.16.2.1  wrstuden 				printf(m, isp->isp_name, bus, "Single-Ended");
    573  1.16.2.1  wrstuden 				break;
    574  1.16.2.1  wrstuden 			default:
    575  1.16.2.1  wrstuden 				printf("%s: unknown mode on bus %d (0x%x)\n",
    576  1.16.2.1  wrstuden 				    isp->isp_name, bus, l);
    577  1.16.2.1  wrstuden 				break;
    578  1.16.2.1  wrstuden 			}
    579  1.16.2.1  wrstuden #endif
    580  1.16.2.1  wrstuden 			/*
    581  1.16.2.1  wrstuden 			 * There's some ambiguity about our negotiated speed
    582  1.16.2.1  wrstuden 			 * if we haven't detected LVD mode correctly (which
    583  1.16.2.1  wrstuden 			 * seems to happen, unfortunately). If we're in LVD
    584  1.16.2.1  wrstuden 			 * mode, then different rules apply about speed.
    585  1.16.2.1  wrstuden 			 */
    586  1.16.2.1  wrstuden 			if (sdp->isp_lvdmode || period < 0xc) {
    587  1.16.2.1  wrstuden 				switch (period) {
    588  1.16.2.1  wrstuden 				case 0xa:
    589  1.16.2.1  wrstuden 					mhz = 40;
    590  1.16.2.1  wrstuden 					break;
    591  1.16.2.1  wrstuden 				case 0xb:
    592  1.16.2.1  wrstuden 					mhz = 33;
    593  1.16.2.1  wrstuden 					break;
    594  1.16.2.1  wrstuden 				case 0xc:
    595  1.16.2.1  wrstuden 					mhz = 25;
    596  1.16.2.1  wrstuden 					break;
    597  1.16.2.1  wrstuden 				default:
    598      1.12    mjacob 					mhz = 1000 / (period * 4);
    599  1.16.2.1  wrstuden 					break;
    600      1.12    mjacob 				}
    601       1.9    mjacob 			} else {
    602  1.16.2.1  wrstuden 				mhz = 1000 / (period * 4);
    603       1.9    mjacob 			}
    604  1.16.2.1  wrstuden 		} else {
    605  1.16.2.1  wrstuden 			mhz = 0;
    606  1.16.2.1  wrstuden 		}
    607  1.16.2.1  wrstuden 		switch (flags & (DPARM_WIDE|DPARM_TQING)) {
    608  1.16.2.1  wrstuden 		case DPARM_WIDE:
    609  1.16.2.1  wrstuden 			wt = ", 16 bit wide\n";
    610  1.16.2.1  wrstuden 			break;
    611  1.16.2.1  wrstuden 		case DPARM_TQING:
    612  1.16.2.1  wrstuden 			wt = ", Tagged Queueing Enabled\n";
    613  1.16.2.1  wrstuden 			break;
    614  1.16.2.1  wrstuden 		case DPARM_WIDE|DPARM_TQING:
    615  1.16.2.1  wrstuden 			wt = ", 16 bit wide, Tagged Queueing Enabled\n";
    616  1.16.2.1  wrstuden 			break;
    617  1.16.2.1  wrstuden 		default:
    618  1.16.2.1  wrstuden 			wt = "\n";
    619  1.16.2.1  wrstuden 			break;
    620  1.16.2.1  wrstuden 		}
    621  1.16.2.1  wrstuden 		if (mhz) {
    622  1.16.2.1  wrstuden 			CFGPRINTF("%s: Bus %d Target %d at %dMHz Max "
    623  1.16.2.1  wrstuden 			    "Offset %d%s", isp->isp_name, bus, tgt, mhz,
    624  1.16.2.1  wrstuden 			    sdp->isp_devparam[tgt].cur_offset, wt);
    625  1.16.2.1  wrstuden 		} else {
    626  1.16.2.1  wrstuden 			CFGPRINTF("%s: Bus %d Target %d Async Mode%s",
    627  1.16.2.1  wrstuden 			    isp->isp_name, bus, tgt, wt);
    628       1.9    mjacob 		}
    629      1.11    mjacob 		break;
    630  1.16.2.1  wrstuden 	}
    631      1.11    mjacob 	case ISPASYNC_BUS_RESET:
    632      1.14    mjacob 		if (arg)
    633      1.14    mjacob 			bus = *((int *) arg);
    634      1.14    mjacob 		else
    635      1.14    mjacob 			bus = 0;
    636      1.14    mjacob 		printf("%s: SCSI bus %d reset detected\n", isp->isp_name, bus);
    637      1.11    mjacob 		break;
    638      1.11    mjacob 	case ISPASYNC_LOOP_DOWN:
    639      1.11    mjacob 		/*
    640      1.11    mjacob 		 * Hopefully we get here in time to minimize the number
    641      1.11    mjacob 		 * of commands we are firing off that are sure to die.
    642      1.11    mjacob 		 */
    643      1.11    mjacob 		isp->isp_osinfo.blocked = 1;
    644      1.11    mjacob 		printf("%s: Loop DOWN\n", isp->isp_name);
    645      1.11    mjacob 		break;
    646      1.11    mjacob         case ISPASYNC_LOOP_UP:
    647      1.11    mjacob 		isp->isp_osinfo.blocked = 0;
    648      1.11    mjacob 		timeout(isp_internal_restart, isp, 1);
    649      1.11    mjacob 		printf("%s: Loop UP\n", isp->isp_name);
    650      1.11    mjacob 		break;
    651      1.15    mjacob 	case ISPASYNC_PDB_CHANGED:
    652  1.16.2.1  wrstuden 	if (IS_FC(isp) && isp->isp_dblev) {
    653      1.15    mjacob 		const char *fmt = "%s: Target %d (Loop 0x%x) Port ID 0x%x "
    654      1.15    mjacob 		    "role %s %s\n Port WWN 0x%08x%08x\n Node WWN 0x%08x%08x\n";
    655      1.15    mjacob 		const static char *roles[4] = {
    656      1.11    mjacob 		    "No", "Target", "Initiator", "Target/Initiator"
    657      1.11    mjacob 		};
    658      1.15    mjacob 		char *ptr;
    659      1.15    mjacob 		fcparam *fcp = isp->isp_param;
    660      1.15    mjacob 		int tgt = *((int *) arg);
    661      1.15    mjacob 		struct lportdb *lp = &fcp->portdb[tgt];
    662      1.15    mjacob 
    663      1.15    mjacob 		if (lp->valid) {
    664      1.15    mjacob 			ptr = "arrived";
    665      1.15    mjacob 		} else {
    666      1.15    mjacob 			ptr = "disappeared";
    667      1.11    mjacob 		}
    668      1.15    mjacob 		printf(fmt, isp->isp_name, tgt, lp->loopid, lp->portid,
    669      1.15    mjacob 		    roles[lp->roles & 0x3], ptr,
    670      1.15    mjacob 		    (u_int32_t) (lp->port_wwn >> 32),
    671      1.15    mjacob 		    (u_int32_t) (lp->port_wwn & 0xffffffffLL),
    672      1.15    mjacob 		    (u_int32_t) (lp->node_wwn >> 32),
    673      1.15    mjacob 		    (u_int32_t) (lp->node_wwn & 0xffffffffLL));
    674      1.11    mjacob 		break;
    675      1.11    mjacob 	}
    676      1.15    mjacob #ifdef	ISP2100_FABRIC
    677      1.11    mjacob 	case ISPASYNC_CHANGE_NOTIFY:
    678      1.11    mjacob 		printf("%s: Name Server Database Changed\n", isp->isp_name);
    679       1.9    mjacob 		break;
    680      1.15    mjacob 	case ISPASYNC_FABRIC_DEV:
    681      1.15    mjacob 	{
    682      1.15    mjacob 		int target;
    683      1.15    mjacob 		struct lportdb *lp;
    684      1.15    mjacob 		sns_scrsp_t *resp = (sns_scrsp_t *) arg;
    685      1.15    mjacob 		u_int32_t portid;
    686      1.15    mjacob 		u_int64_t wwn;
    687      1.15    mjacob 		fcparam *fcp = isp->isp_param;
    688      1.15    mjacob 
    689      1.15    mjacob 		portid =
    690      1.15    mjacob 		    (((u_int32_t) resp->snscb_port_id[0]) << 16) |
    691      1.15    mjacob 		    (((u_int32_t) resp->snscb_port_id[1]) << 8) |
    692      1.15    mjacob 		    (((u_int32_t) resp->snscb_port_id[2]));
    693      1.15    mjacob 		wwn =
    694      1.15    mjacob 		    (((u_int64_t)resp->snscb_portname[0]) << 56) |
    695      1.15    mjacob 		    (((u_int64_t)resp->snscb_portname[1]) << 48) |
    696      1.15    mjacob 		    (((u_int64_t)resp->snscb_portname[2]) << 40) |
    697      1.15    mjacob 		    (((u_int64_t)resp->snscb_portname[3]) << 32) |
    698      1.15    mjacob 		    (((u_int64_t)resp->snscb_portname[4]) << 24) |
    699      1.15    mjacob 		    (((u_int64_t)resp->snscb_portname[5]) << 16) |
    700      1.15    mjacob 		    (((u_int64_t)resp->snscb_portname[6]) <<  8) |
    701      1.15    mjacob 		    (((u_int64_t)resp->snscb_portname[7]));
    702      1.15    mjacob 		printf("%s: Fabric Device (Type 0x%x)@PortID 0x%x WWN "
    703      1.15    mjacob 		    "0x%08x%08x\n", isp->isp_name, resp->snscb_port_type,
    704      1.15    mjacob 		    portid, ((u_int32_t)(wwn >> 32)),
    705      1.15    mjacob 		    ((u_int32_t)(wwn & 0xffffffff)));
    706      1.15    mjacob 		if (resp->snscb_port_type != 2)
    707      1.15    mjacob 			break;
    708      1.15    mjacob 		for (target = FC_SNS_ID+1; target < MAX_FC_TARG; target++) {
    709      1.15    mjacob 			lp = &fcp->portdb[target];
    710      1.15    mjacob 			if (lp->port_wwn == wwn)
    711      1.15    mjacob 				break;
    712      1.15    mjacob 		}
    713      1.15    mjacob 		if (target < MAX_FC_TARG) {
    714      1.15    mjacob 			break;
    715      1.15    mjacob 		}
    716      1.15    mjacob 		for (target = FC_SNS_ID+1; target < MAX_FC_TARG; target++) {
    717      1.15    mjacob 			lp = &fcp->portdb[target];
    718      1.15    mjacob 			if (lp->port_wwn == 0)
    719      1.15    mjacob 				break;
    720      1.15    mjacob 		}
    721      1.15    mjacob 		if (target == MAX_FC_TARG) {
    722      1.15    mjacob 			printf("%s: no more space for fabric devices\n",
    723      1.15    mjacob 			    isp->isp_name);
    724      1.15    mjacob 			return (-1);
    725      1.15    mjacob 		}
    726      1.15    mjacob 		lp->port_wwn = lp->node_wwn = wwn;
    727      1.15    mjacob 		lp->portid = portid;
    728      1.15    mjacob 		break;
    729      1.15    mjacob 	}
    730      1.15    mjacob #endif
    731       1.9    mjacob 	default:
    732       1.9    mjacob 		break;
    733       1.9    mjacob 	}
    734      1.10    mjacob 	(void) splx(s);
    735       1.9    mjacob 	return (0);
    736       1.1    mjacob }
    737