Example #1
0
/*
 * event dispatcher
 *	while event queue is not empty
 *		get event from queue
 *		send command to state machine
 *	end
 *	return error reported by individual Event function
 *		0 if no error occured.
 */
int	SkEventDispatcher(
    SK_AC	*pAC,	/* Adapters Context */
    SK_IOC	Ioc)	/* Io context */
{
    SK_EVENTELEM	*pEv ;	/* pointer into queue */
    SK_U32			Class ;
    int			Rtv ;

    pEv = pAC->Event.EvGet ;
    PRINTF("dispatch get %x put %x\n",pEv,pAC->Event.ev_put) ;
    while (pEv != pAC->Event.EvPut) {
        PRINTF("dispatch Class %d Event %d\n",pEv->Class,pEv->Event) ;
        switch(Class = pEv->Class) {
#ifndef SK_USE_LAC_EV
        case SKGE_RLMT :	/* RLMT Event */
            Rtv = SkRlmtEvent(pAC,Ioc,pEv->Event,pEv->Para);
            break ;
        case SKGE_I2C :		/* I2C Event */
            Rtv = SkI2cEvent(pAC,Ioc,pEv->Event,pEv->Para);
            break ;
        case SKGE_PNMI :
            Rtv = SkPnmiEvent(pAC,Ioc,pEv->Event,pEv->Para);
            break ;
#endif /* SK_USE_LAC_EV */
        case SKGE_DRV :		/* Driver Event */
            Rtv = SkDrvEvent(pAC,Ioc,pEv->Event,pEv->Para);
            break ;
#ifndef SK_USE_SW_TIMER
        case SKGE_HWAC :
            Rtv = SkGeSirqEvent(pAC,Ioc,pEv->Event,pEv->Para);
            break ;
#else /* !SK_USE_SW_TIMER */
        case SKGE_SWT :
            Rtv = SkSwtEvent(pAC,Ioc,pEv->Event,pEv->Para);
            break ;
#endif /* !SK_USE_SW_TIMER */
#ifdef SK_USE_LAC_EV
        case SKGE_LACP :
            Rtv = SkLacpEvent(pAC,Ioc,pEv->Event,pEv->Para);
            break ;
        case SKGE_RSF :
            Rtv = SkRsfEvent(pAC,Ioc,pEv->Event,pEv->Para);
            break ;
        case SKGE_MARKER :
            Rtv = SkMarkerEvent(pAC,Ioc,pEv->Event,pEv->Para);
            break ;
        case SKGE_FD :
            Rtv = SkFdEvent(pAC,Ioc,pEv->Event,pEv->Para);
            break ;
#endif /* SK_USE_LAC_EV */
#ifdef	SK_USE_CSUM
        case SKGE_CSUM :
            Rtv = SkCsEvent(pAC,Ioc,pEv->Event,pEv->Para);
            break ;
#endif	/* SK_USE_CSUM */
        default :
            SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_Q_E002,
                       SKERR_Q_E002MSG) ;
            Rtv = 0;
        }

        if (Rtv != 0) {
            return(Rtv) ;
        }

        if (++pEv == &pAC->Event.EvQueue[SK_MAX_EVENT])
            pEv = pAC->Event.EvQueue ;

        /* Renew get: it is used in queue_events to detect overruns */
        pAC->Event.EvGet = pEv;
    }

    return(0) ;
}
Example #2
0
/******************************************************************************
 *
 *	SkEventDispatcher() -	 Event Dispatcher
 *
 * Description:
 *	The event dispatcher performs the following operations:
 *		o while event queue is not empty
 *			- get event from queue
 *			- send event to state machine
 *		  end
 *
 * CAUTION:
 *	The event functions MUST report an error if performing a reinitialization
 *	of the event queue, e.g. performing level Init 0..2 while in dispatcher
 *	call!
 *  ANY OTHER return value delays scheduling the other events in the
 *	queue. In this case the event blocks the queue until
 *  the error condition is cleared!
 *
 * Returns:
 *	The return value error reported by individual event function
 */
int	SkEventDispatcher(
SK_AC	*pAC,	/* Adapters Context */
SK_IOC	Ioc)	/* Io context */
{
	SK_EVENTELEM	*pEv;	/* pointer into queue */
	SK_U32			Class;
	int			Rtv;

	if (pAC->GIni.GILevel != SK_INIT_RUN) {
		SK_ERR_LOG(pAC, SK_ERRCL_NORES, SKERR_Q_E005, SKERR_Q_E005MSG);
	}

	pEv = pAC->Event.EvGet;
	
	PRINTF("dispatch get %x put %x\n", pEv, pAC->Event.ev_put);
	
	while (pEv != pAC->Event.EvPut) {
		PRINTF("dispatch Class %d Event %d\n", pEv->Class, pEv->Event);

		switch (Class = pEv->Class) {
#ifndef SK_USE_LAC_EV
#ifndef SK_SLIM
		case SKGE_RLMT:		/* RLMT Event */
			Rtv = SkRlmtEvent(pAC, Ioc, pEv->Event, pEv->Para);
			break;
		case SKGE_I2C:		/* I2C Event */
			Rtv = SkI2cEvent(pAC, Ioc, pEv->Event, pEv->Para);
			break;
		case SKGE_PNMI:		/* PNMI Event */
			Rtv = SkPnmiEvent(pAC, Ioc, pEv->Event, pEv->Para);
			break;
#endif	/* not SK_SLIM */
#endif	/* not SK_USE_LAC_EV */
		case SKGE_DRV:		/* Driver Event */
			Rtv = SkDrvEvent(pAC, Ioc, pEv->Event, pEv->Para);
			break;
#ifndef SK_USE_SW_TIMER
		case SKGE_HWAC:
			Rtv = SkGeSirqEvent(pAC, Ioc, pEv->Event, pEv->Para);
			break;
#else /* !SK_USE_SW_TIMER */
        case SKGE_SWT :
			Rtv = SkSwtEvent(pAC, Ioc, pEv->Event, pEv->Para);
			break;
#endif /* !SK_USE_SW_TIMER */
#if defined(SK_USE_LAC_EV) || defined(SK_LBFO)
		case SKGE_LACP :
			Rtv = SkLacpEvent(pAC, Ioc, pEv->Event, pEv->Para);
			break;
		case SKGE_RSF :
			Rtv = SkRsfEvent(pAC, Ioc, pEv->Event, pEv->Para);
			break;
		case SKGE_MARKER :
			Rtv = SkMarkerEvent(pAC, Ioc, pEv->Event, pEv->Para);
			break;
		case SKGE_FD :
			Rtv = SkFdEvent(pAC, Ioc, pEv->Event, pEv->Para);
			break;
#endif /* SK_USE_LAC_EV */
#ifdef SK_ASF
		case SKGE_ASF :
			Rtv = SkAsfEvent(pAC,Ioc,pEv->Event,pEv->Para);
			break ;
#endif
#ifdef	SK_USE_CSUM
		case SKGE_CSUM :
			Rtv = SkCsEvent(pAC, Ioc, pEv->Event, pEv->Para);
			break;
#endif	/* SK_USE_CSUM */
		default :
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_Q_E002, SKERR_Q_E002MSG);
			Rtv = 0;
		}

		if (Rtv != 0) {
			/* 
			 * Special Case: See CAUTION statement above.
			 * We assume the event queue is reset.
			 */
			if (pAC->Event.EvGet != pAC->Event.EvQueue &&
				pAC->Event.EvGet != pEv) {
				/*
				 * Create an error log entry if the
				 * event queue isn't reset.
				 * In this case it may be blocked.
				 */
				SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_Q_E004, SKERR_Q_E004MSG);
			}

			return(Rtv);
		}

		if (++pEv == &pAC->Event.EvQueue[SK_MAX_EVENT])
			pEv = pAC->Event.EvQueue;

		/* Renew get: it is used in queue_events to detect overruns */
		pAC->Event.EvGet = pEv;
	}

	return(0);
}