FreeBSD/sys/dev/isp/isp_target.c
/*
 * These are either broadcast events or specifically CTIO fast completion
 */
These are either broadcast events or specifically CTIO fast completion
These are either broadcast events or specifically CTIO fast completion
int
isp_target_async(ispsoftc_t *isp, int bus, int event)
{
	isp_notify_t notify;
	ISP_MEMZERO(&notify, sizeof (isp_notify_t));
	notify.nt_hba = isp;
	notify.nt_wwn = INI_ANY;
	notify.nt_nphdl = NIL_HANDLE;
	notify.nt_sid = PORT_ANY;
	notify.nt_did = PORT_ANY;
	notify.nt_tgt = TGT_ANY;
	notify.nt_channel = bus;
	notify.nt_lun = LUN_ANY;
	notify.nt_tagval = TAG_ANY;
	notify.nt_tagval |= (((uint64_t)(isp->isp_serno++)) << 32);
	switch (event) {
	case ASYNC_LOOP_UP:
	case ASYNC_PTPMODE:
		isp_prt(isp, ISP_LOGTDEBUG0, "%s: LOOP UP", __func__);
		notify.nt_ncode = NT_LINK_UP;
		isp_async(isp, ISPASYNC_TARGET_NOTIFY, &notify);
		break;
	case ASYNC_LOOP_DOWN:
		isp_prt(isp, ISP_LOGTDEBUG0, "%s: LOOP DOWN", __func__);
		notify.nt_ncode = NT_LINK_DOWN;
		isp_async(isp, ISPASYNC_TARGET_NOTIFY, &notify);
		break;
	case ASYNC_LIP_ERROR:
	case ASYNC_LIP_NOS_OLS_RECV:
	case ASYNC_LIP_OCCURRED:
	case ASYNC_LOOP_RESET:
		isp_prt(isp, ISP_LOGTDEBUG0, "%s: LIP RESET", __func__);
		notify.nt_ncode = NT_LIP_RESET;
		isp_async(isp, ISPASYNC_TARGET_NOTIFY, &notify);
		break;
	case ASYNC_BUS_RESET:
	case ASYNC_TIMEOUT_RESET:	
		isp_prt(isp, ISP_LOGTDEBUG0, "%s: BUS RESET", __func__);
		notify.nt_ncode = NT_BUS_RESET;
		isp_async(isp, ISPASYNC_TARGET_NOTIFY, &notify);
		break;
	case ASYNC_DEVICE_RESET:
		isp_prt(isp, ISP_LOGTDEBUG0, "%s: DEVICE RESET", __func__);
		notify.nt_ncode = NT_TARGET_RESET;
		isp_async(isp, ISPASYNC_TARGET_NOTIFY, &notify);
		break;
	case ASYNC_CTIO_DONE:
	{
		uint8_t storage[QENTRY_LEN];
		isp_prt(isp, ISP_LOGTDEBUG0, "%s: CTIO DONE", __func__);
		memset(storage, 0, QENTRY_LEN);
		if (IS_24XX(isp)) {
			ct7_entry_t *ct = (ct7_entry_t *) storage;
			ct->ct_header.rqs_entry_type = RQSTYPE_CTIO7;
			ct->ct_nphdl = CT7_OK;
			ct->ct_syshandle = bus;
			ct->ct_flags = CT7_SENDSTATUS;
		} else {
			ct2_entry_t *ct = (ct2_entry_t *) storage;
			ct->ct_header.rqs_entry_type = RQSTYPE_CTIO2;
			ct->ct_status = CT_OK;
			ct->ct_syshandle = bus;
			ct->ct_flags = CT2_SENDSTATUS|CT2_FASTPOST;
		}
		isp_async(isp, ISPASYNC_TARGET_ACTION, storage);
		break;
	}
	default:
		isp_prt(isp, ISP_LOGERR, "%s: unknown event 0x%x", __func__, event);
		if (isp->isp_state == ISP_RUNSTATE) {
			isp_async(isp, ISPASYNC_TARGET_NOTIFY_ACK, NULL);
		}
		break;
	}
	return (0);
}
int isp_target_async ( ispsoftc_t * isp , int bus , int event ) { isp_notify_t notify ; ISP_MEMZERO ( & notify , sizeof ( isp_notify_t ) ) ; notify . nt_hba = isp ; notify . nt_wwn = INI_ANY ; notify . nt_nphdl = NIL_HANDLE ; notify . nt_sid = PORT_ANY ; notify . nt_did = PORT_ANY ; notify . nt_tgt = TGT_ANY ; notify . nt_channel = bus ; notify . nt_lun = LUN_ANY ; notify . nt_tagval = TAG_ANY ; notify . nt_tagval |= ( ( ( uint64_t ) ( isp -> isp_serno ++ ) ) << 32 ) ; switch ( event ) { case ASYNC_LOOP_UP : case ASYNC_PTPMODE : isp_prt ( isp , ISP_LOGTDEBUG0 , " " , __func__ ) ; notify . nt_ncode = NT_LINK_UP ; isp_async ( isp , ISPASYNC_TARGET_NOTIFY , & notify ) ; break ; case ASYNC_LOOP_DOWN : isp_prt ( isp , ISP_LOGTDEBUG0 , " " , __func__ ) ; notify . nt_ncode = NT_LINK_DOWN ; isp_async ( isp , ISPASYNC_TARGET_NOTIFY , & notify ) ; break ; case ASYNC_LIP_ERROR : case ASYNC_LIP_NOS_OLS_RECV : case ASYNC_LIP_OCCURRED : case ASYNC_LOOP_RESET : isp_prt ( isp , ISP_LOGTDEBUG0 , " " , __func__ ) ; notify . nt_ncode = NT_LIP_RESET ; isp_async ( isp , ISPASYNC_TARGET_NOTIFY , & notify ) ; break ; case ASYNC_BUS_RESET : case ASYNC_TIMEOUT_RESET : isp_prt ( isp , ISP_LOGTDEBUG0 , " " , __func__ ) ; notify . nt_ncode = NT_BUS_RESET ; isp_async ( isp , ISPASYNC_TARGET_NOTIFY , & notify ) ; break ; case ASYNC_DEVICE_RESET : isp_prt ( isp , ISP_LOGTDEBUG0 , " " , __func__ ) ; notify . nt_ncode = NT_TARGET_RESET ; isp_async ( isp , ISPASYNC_TARGET_NOTIFY , & notify ) ; break ; case ASYNC_CTIO_DONE : { uint8_t storage [ QENTRY_LEN ] ; isp_prt ( isp , ISP_LOGTDEBUG0 , " " , __func__ ) ; memset ( storage , 0 , QENTRY_LEN ) ; if ( IS_24XX ( isp ) ) { ct7_entry_t * ct = ( ct7_entry_t * ) storage ; ct -> ct_header . rqs_entry_type = RQSTYPE_CTIO7 ; ct -> ct_nphdl = CT7_OK ; ct -> ct_syshandle = bus ; ct -> ct_flags = CT7_SENDSTATUS ; } else { ct2_entry_t * ct = ( ct2_entry_t * ) storage ; ct -> ct_header . rqs_entry_type = RQSTYPE_CTIO2 ; ct -> ct_status = CT_OK ; ct -> ct_syshandle = bus ; ct -> ct_flags = CT2_SENDSTATUS | CT2_FASTPOST ; } isp_async ( isp , ISPASYNC_TARGET_ACTION , storage ) ; break ; } default : isp_prt ( isp , ISP_LOGERR , " " , __func__ , event ) ; if ( isp -> isp_state == ISP_RUNSTATE ) { isp_async ( isp , ISPASYNC_TARGET_NOTIFY_ACK , NULL ) ; } break ; } return ( 0 ) ; }
These are either broadcast events or specifically CTIO fast completion
These are either broadcast events or specifically CTIO fast completion
/* XXX: where does this come from ? */ /* This should also suffice for 2K login code */