FreeBSD/sys/dev/isp/isp.c
/*
 * Parse an ASYNC mailbox complete
 *
 * Return non-zero if the event has been acknowledged.
 */
Parse an ASYNC mailbox complete
Return non-zero if the event has been acknowledged.
Parse an ASYNC mailbox complete Return non - zero if the event has been acknowledged .
static int
isp_parse_async(ispsoftc_t *isp, uint16_t mbox)
{
	int acked = 0;
	uint32_t h1 = 0, h2 = 0;
	uint16_t chan = 0;
	if (mbox != ASYNC_RIO32_2) {
		if (IS_DUALBUS(isp)) {
			chan = ISP_READ(isp, OUTMAILBOX6);
		}
	}
	isp_prt(isp, ISP_LOGDEBUG2, "Async Mbox 0x%x", mbox);
	switch (mbox) {
	case ASYNC_BUS_RESET:
		ISP_SET_SENDMARKER(isp, chan, 1);
#ifdef	ISP_TARGET_MODE
		if (isp_target_async(isp, chan, mbox)) {
			acked = 1;
		}
#endif
		isp_async(isp, ISPASYNC_BUS_RESET, chan);
		break;
	case ASYNC_SYSTEM_ERROR:
		isp->isp_dead = 1;
		isp->isp_state = ISP_CRASHED;
		if (isp->isp_mboxbsy) {
			isp->isp_obits = 1;
			isp->isp_mboxtmp[0] = MBOX_HOST_INTERFACE_ERROR;
			MBOX_NOTIFY_COMPLETE(isp);
		}
		isp_async(isp, ISPASYNC_FW_CRASH);
		acked = 1;
		break;
	case ASYNC_RQS_XFER_ERR:
		isp_prt(isp, ISP_LOGERR, "Request Queue Transfer Error");
		break;
	case ASYNC_RSP_XFER_ERR:
		isp_prt(isp, ISP_LOGERR, "Response Queue Transfer Error");
		break;
	case ASYNC_QWAKEUP:
		mbox = ISP_READ(isp, isp->isp_rqstoutrp);
		break;
	case ASYNC_TIMEOUT_RESET:
		isp_prt(isp, ISP_LOGWARN, "timeout initiated SCSI bus reset of chan %d", chan);
		ISP_SET_SENDMARKER(isp, chan, 1);
#ifdef	ISP_TARGET_MODE
		if (isp_target_async(isp, chan, mbox)) {
			acked = 1;
		}
#endif
		break;
	case ASYNC_DEVICE_RESET:
		isp_prt(isp, ISP_LOGINFO, "device reset on chan %d", chan);
		ISP_SET_SENDMARKER(isp, chan, 1);
#ifdef	ISP_TARGET_MODE
		if (isp_target_async(isp, chan, mbox)) {
			acked = 1;
		}
#endif
		break;
	case ASYNC_EXTMSG_UNDERRUN:
		isp_prt(isp, ISP_LOGWARN, "extended message underrun");
		break;
	case ASYNC_SCAM_INT:
		isp_prt(isp, ISP_LOGINFO, "SCAM interrupt");
		break;
	case ASYNC_HUNG_SCSI:
		isp_prt(isp, ISP_LOGERR, "stalled SCSI Bus after DATA Overrun");
		break;
	case ASYNC_KILLED_BUS:
		isp_prt(isp, ISP_LOGERR, "SCSI Bus reset after DATA Overrun");
		break;
	case ASYNC_BUS_TRANSIT:
		mbox = ISP_READ(isp, OUTMAILBOX2);
		switch (mbox & SXP_PINS_MODE_MASK) {
		case SXP_PINS_LVD_MODE:
			isp_prt(isp, ISP_LOGINFO, "Transition to LVD mode");
			SDPARAM(isp, chan)->isp_diffmode = 0;
			SDPARAM(isp, chan)->isp_ultramode = 0;
			SDPARAM(isp, chan)->isp_lvdmode = 1;
			break;
		case SXP_PINS_HVD_MODE:
			isp_prt(isp, ISP_LOGINFO,
			    "Transition to Differential mode");
			SDPARAM(isp, chan)->isp_diffmode = 1;
			SDPARAM(isp, chan)->isp_ultramode = 0;
			SDPARAM(isp, chan)->isp_lvdmode = 0;
			break;
		case SXP_PINS_SE_MODE:
			isp_prt(isp, ISP_LOGINFO,
			    "Transition to Single Ended mode");
			SDPARAM(isp, chan)->isp_diffmode = 0;
			SDPARAM(isp, chan)->isp_ultramode = 1;
			SDPARAM(isp, chan)->isp_lvdmode = 0;
			break;
		default:
			isp_prt(isp, ISP_LOGWARN,
			    "Transition to Unknown Mode 0x%x", mbox);
			break;
		}
		ISP_SET_SENDMARKER(isp, chan, 1);
		break;
	case ASYNC_CMD_CMPLT:
	case ASYNC_RIO32_1:
		if (!IS_ULTRA3(isp)) {
			isp_prt(isp, ISP_LOGERR, "unexpected fast posting completion");
			break;
		}
		h1 = (ISP_READ(isp, OUTMAILBOX2) << 16) | ISP_READ(isp, OUTMAILBOX1);
		break;
	case ASYNC_RIO32_2:
		h1 = (ISP_READ(isp, OUTMAILBOX2) << 16) | ISP_READ(isp, OUTMAILBOX1);
		h2 = (ISP_READ(isp, OUTMAILBOX7) << 16) | ISP_READ(isp, OUTMAILBOX6);
		break;
	case ASYNC_RIO16_5:
	case ASYNC_RIO16_4:
	case ASYNC_RIO16_3:
	case ASYNC_RIO16_2:
	case ASYNC_RIO16_1:
		isp_prt(isp, ISP_LOGERR, "unexpected 16 bit RIO handle");
		break;
	default:
		isp_prt(isp, ISP_LOGWARN, "%s: unhandled async code 0x%x", __func__, mbox);
		break;
	}
	if (h1 || h2) {
		isp_prt(isp, ISP_LOGDEBUG3, "fast post/rio completion of 0x%08x", h1);
		isp_fastpost_complete(isp, h1);
		if (h2) {
			isp_prt(isp, ISP_LOGDEBUG3, "fast post/rio completion of 0x%08x", h2);
			isp_fastpost_complete(isp, h2);
			if (isp->isp_fpcchiwater < 2) {
				isp->isp_fpcchiwater = 2;
			}
		} else {
			if (isp->isp_fpcchiwater < 1) {
				isp->isp_fpcchiwater = 1;
			}
		}
	} else {
		isp->isp_intoasync++;
	}
	return (acked);
}
static int isp_parse_async ( ispsoftc_t * isp , uint16_t mbox ) { int acked = 0 ; uint32_t h1 = 0 , h2 = 0 ; uint16_t chan = 0 ; if ( mbox != ASYNC_RIO32_2 ) { if ( IS_DUALBUS ( isp ) ) { chan = ISP_READ ( isp , OUTMAILBOX6 ) ; } } isp_prt ( isp , ISP_LOGDEBUG2 , " " , mbox ) ; switch ( mbox ) { case ASYNC_BUS_RESET : ISP_SET_SENDMARKER ( isp , chan , 1 ) ; #ifdef ISP_TARGET_MODE if ( isp_target_async ( isp , chan , mbox ) ) { acked = 1 ; } #endif isp_async ( isp , ISPASYNC_BUS_RESET , chan ) ; break ; case ASYNC_SYSTEM_ERROR : isp -> isp_dead = 1 ; isp -> isp_state = ISP_CRASHED ; if ( isp -> isp_mboxbsy ) { isp -> isp_obits = 1 ; isp -> isp_mboxtmp [ 0 ] = MBOX_HOST_INTERFACE_ERROR ; MBOX_NOTIFY_COMPLETE ( isp ) ; } isp_async ( isp , ISPASYNC_FW_CRASH ) ; acked = 1 ; break ; case ASYNC_RQS_XFER_ERR : isp_prt ( isp , ISP_LOGERR , " " ) ; break ; case ASYNC_RSP_XFER_ERR : isp_prt ( isp , ISP_LOGERR , " " ) ; break ; case ASYNC_QWAKEUP : mbox = ISP_READ ( isp , isp -> isp_rqstoutrp ) ; break ; case ASYNC_TIMEOUT_RESET : isp_prt ( isp , ISP_LOGWARN , " " , chan ) ; ISP_SET_SENDMARKER ( isp , chan , 1 ) ; #ifdef ISP_TARGET_MODE if ( isp_target_async ( isp , chan , mbox ) ) { acked = 1 ; } #endif break ; case ASYNC_DEVICE_RESET : isp_prt ( isp , ISP_LOGINFO , " " , chan ) ; ISP_SET_SENDMARKER ( isp , chan , 1 ) ; #ifdef ISP_TARGET_MODE if ( isp_target_async ( isp , chan , mbox ) ) { acked = 1 ; } #endif break ; case ASYNC_EXTMSG_UNDERRUN : isp_prt ( isp , ISP_LOGWARN , " " ) ; break ; case ASYNC_SCAM_INT : isp_prt ( isp , ISP_LOGINFO , " " ) ; break ; case ASYNC_HUNG_SCSI : isp_prt ( isp , ISP_LOGERR , " " ) ; break ; case ASYNC_KILLED_BUS : isp_prt ( isp , ISP_LOGERR , " " ) ; break ; case ASYNC_BUS_TRANSIT : mbox = ISP_READ ( isp , OUTMAILBOX2 ) ; switch ( mbox & SXP_PINS_MODE_MASK ) { case SXP_PINS_LVD_MODE : isp_prt ( isp , ISP_LOGINFO , " " ) ; SDPARAM ( isp , chan ) -> isp_diffmode = 0 ; SDPARAM ( isp , chan ) -> isp_ultramode = 0 ; SDPARAM ( isp , chan ) -> isp_lvdmode = 1 ; break ; case SXP_PINS_HVD_MODE : isp_prt ( isp , ISP_LOGINFO , " " ) ; SDPARAM ( isp , chan ) -> isp_diffmode = 1 ; SDPARAM ( isp , chan ) -> isp_ultramode = 0 ; SDPARAM ( isp , chan ) -> isp_lvdmode = 0 ; break ; case SXP_PINS_SE_MODE : isp_prt ( isp , ISP_LOGINFO , " " ) ; SDPARAM ( isp , chan ) -> isp_diffmode = 0 ; SDPARAM ( isp , chan ) -> isp_ultramode = 1 ; SDPARAM ( isp , chan ) -> isp_lvdmode = 0 ; break ; default : isp_prt ( isp , ISP_LOGWARN , " " , mbox ) ; break ; } ISP_SET_SENDMARKER ( isp , chan , 1 ) ; break ; case ASYNC_CMD_CMPLT : case ASYNC_RIO32_1 : if ( ! IS_ULTRA3 ( isp ) ) { isp_prt ( isp , ISP_LOGERR , " " ) ; break ; } h1 = ( ISP_READ ( isp , OUTMAILBOX2 ) << 16 ) | ISP_READ ( isp , OUTMAILBOX1 ) ; break ; case ASYNC_RIO32_2 : h1 = ( ISP_READ ( isp , OUTMAILBOX2 ) << 16 ) | ISP_READ ( isp , OUTMAILBOX1 ) ; h2 = ( ISP_READ ( isp , OUTMAILBOX7 ) << 16 ) | ISP_READ ( isp , OUTMAILBOX6 ) ; break ; case ASYNC_RIO16_5 : case ASYNC_RIO16_4 : case ASYNC_RIO16_3 : case ASYNC_RIO16_2 : case ASYNC_RIO16_1 : isp_prt ( isp , ISP_LOGERR , " " ) ; break ; default : isp_prt ( isp , ISP_LOGWARN , " " , __func__ , mbox ) ; break ; } if ( h1 || h2 ) { isp_prt ( isp , ISP_LOGDEBUG3 , " " , h1 ) ; isp_fastpost_complete ( isp , h1 ) ; if ( h2 ) { isp_prt ( isp , ISP_LOGDEBUG3 , " " , h2 ) ; isp_fastpost_complete ( isp , h2 ) ; if ( isp -> isp_fpcchiwater < 2 ) { isp -> isp_fpcchiwater = 2 ; } } else { if ( isp -> isp_fpcchiwater < 1 ) { isp -> isp_fpcchiwater = 1 ; } } } else { isp -> isp_intoasync ++ ; } return ( acked ) ; }
Parse an ASYNC mailbox complete
 Return non-zero if the event has been acknowledged.
Parse an ASYNC mailbox complete Return non - zero if the event has been acknowledged .
/*
	 * Pick up the channel, but not if this is a ASYNC_RIO32_2,
	 * where Mailboxes 6/7 have the second handle.
	 */ /*
		 * Were we waiting for a mailbox command to complete?
		 * If so, it's dead, so wake up the waiter.
		 */ /*
		 * It's up to the handler for isp_async to reinit stuff and
		 * restart the firmware
		 */ /*
		 * 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.
		 */ /* XXX: Need to issue SCSI reset at this point */ /*
		 * XXX: Set up to renegotiate again!
		 */ /* Can only be for a 1080... */ /* FALLTHROUGH */