2024-01-07 23:57:24 +01:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Name: skqueue.c
|
2024-01-09 13:43:28 +01:00
|
|
|
* Project: Gigabit Ethernet Adapters, Event Scheduler Module
|
|
|
|
* Version: $Revision: 2.3 $
|
|
|
|
* Date: $Date: 2004/05/14 13:28:18 $
|
2024-01-07 23:57:24 +01:00
|
|
|
* Purpose: Management of an event queue.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
2024-01-09 13:43:28 +01:00
|
|
|
* (C)Copyright 1998-2002 SysKonnect GmbH.
|
|
|
|
* (C)Copyright 2002-2003 Marvell.
|
2024-01-07 23:57:24 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* The information in this file is provided "AS IS" without warranty.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#include <config.h>
|
2024-01-09 13:43:28 +01:00
|
|
|
|
2024-01-07 23:57:24 +01:00
|
|
|
#ifdef CONFIG_SK98
|
|
|
|
|
|
|
|
/*
|
2024-01-09 13:43:28 +01:00
|
|
|
* Event queue and dispatcher
|
|
|
|
*/
|
|
|
|
#if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
|
2024-01-07 23:57:24 +01:00
|
|
|
static const char SysKonnectFileId[] =
|
2024-01-09 13:43:28 +01:00
|
|
|
"@(#) $Id: skqueue.c,v 2.3 2004/05/14 13:28:18 malthoff Exp $ (C) Marvell.";
|
|
|
|
#endif
|
2024-01-07 23:57:24 +01:00
|
|
|
|
|
|
|
#include "h/skdrv1st.h" /* Driver Specific Definitions */
|
|
|
|
#include "h/skqueue.h" /* Queue Definitions */
|
|
|
|
#include "h/skdrv2nd.h" /* Adapter Control- and Driver specific Def. */
|
|
|
|
|
|
|
|
#ifdef __C2MAN__
|
|
|
|
/*
|
|
|
|
Event queue management.
|
|
|
|
|
|
|
|
General Description:
|
|
|
|
|
|
|
|
*/
|
|
|
|
intro()
|
|
|
|
{}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PRINTF(a,b,c)
|
|
|
|
|
2024-01-09 13:43:28 +01:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* SkEventInit() - init event queue management
|
2024-01-07 23:57:24 +01:00
|
|
|
*
|
2024-01-09 13:43:28 +01:00
|
|
|
* Description:
|
|
|
|
* This function initializes event queue management.
|
|
|
|
* It must be called during init level 0.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* nothing
|
2024-01-07 23:57:24 +01:00
|
|
|
*/
|
|
|
|
void SkEventInit(
|
|
|
|
SK_AC *pAC, /* Adapter context */
|
|
|
|
SK_IOC Ioc, /* IO context */
|
2024-01-09 13:43:28 +01:00
|
|
|
int Level) /* Init level */
|
2024-01-07 23:57:24 +01:00
|
|
|
{
|
|
|
|
switch (Level) {
|
|
|
|
case SK_INIT_DATA:
|
2024-01-09 13:43:28 +01:00
|
|
|
pAC->Event.EvPut = pAC->Event.EvGet = pAC->Event.EvQueue;
|
2024-01-07 23:57:24 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-09 13:43:28 +01:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* SkEventQueue() - add event to queue
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function adds an event to the event queue.
|
|
|
|
* At least Init Level 1 is required to queue events,
|
|
|
|
* but will be scheduled add Init Level 2.
|
|
|
|
*
|
|
|
|
* returns:
|
|
|
|
* nothing
|
2024-01-07 23:57:24 +01:00
|
|
|
*/
|
|
|
|
void SkEventQueue(
|
|
|
|
SK_AC *pAC, /* Adapters context */
|
|
|
|
SK_U32 Class, /* Event Class */
|
|
|
|
SK_U32 Event, /* Event to be queued */
|
|
|
|
SK_EVPARA Para) /* Event parameter */
|
|
|
|
{
|
2024-01-09 13:43:28 +01:00
|
|
|
|
|
|
|
if (pAC->GIni.GILevel == SK_INIT_DATA) {
|
|
|
|
SK_ERR_LOG(pAC, SK_ERRCL_NORES, SKERR_Q_E003, SKERR_Q_E003MSG);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pAC->Event.EvPut->Class = Class;
|
|
|
|
pAC->Event.EvPut->Event = Event;
|
|
|
|
pAC->Event.EvPut->Para = Para;
|
|
|
|
|
|
|
|
if (++pAC->Event.EvPut == &pAC->Event.EvQueue[SK_MAX_EVENT])
|
|
|
|
pAC->Event.EvPut = pAC->Event.EvQueue;
|
|
|
|
|
|
|
|
if (pAC->Event.EvPut == pAC->Event.EvGet) {
|
|
|
|
SK_ERR_LOG(pAC, SK_ERRCL_NORES, SKERR_Q_E001, SKERR_Q_E001MSG);
|
|
|
|
}
|
2024-01-07 23:57:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-09 13:43:28 +01:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* 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
|
2024-01-07 23:57:24 +01:00
|
|
|
*/
|
|
|
|
int SkEventDispatcher(
|
|
|
|
SK_AC *pAC, /* Adapters Context */
|
|
|
|
SK_IOC Ioc) /* Io context */
|
|
|
|
{
|
2024-01-09 13:43:28 +01:00
|
|
|
SK_EVENTELEM *pEv; /* pointer into queue */
|
|
|
|
SK_U32 Class;
|
|
|
|
int Rtv;
|
2024-01-07 23:57:24 +01:00
|
|
|
|
2024-01-09 13:43:28 +01:00
|
|
|
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);
|
|
|
|
|
2024-01-07 23:57:24 +01:00
|
|
|
while (pEv != pAC->Event.EvPut) {
|
2024-01-09 13:43:28 +01:00
|
|
|
PRINTF("dispatch Class %d Event %d\n", pEv->Class, pEv->Event);
|
|
|
|
|
|
|
|
switch (Class = pEv->Class) {
|
2024-01-07 23:57:24 +01:00
|
|
|
#ifndef SK_USE_LAC_EV
|
2024-01-09 13:43:28 +01:00
|
|
|
#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;
|
|
|
|
|
|
|
|
#ifdef SK_PNMI_SUPPORT
|
|
|
|
case SKGE_PNMI: /* PNMI Event */
|
|
|
|
Rtv = SkPnmiEvent(pAC, Ioc, pEv->Event, pEv->Para);
|
|
|
|
break;
|
|
|
|
#endif /* SK_PNMI_SUPPORT */
|
|
|
|
|
|
|
|
#endif /* not SK_SLIM */
|
|
|
|
#endif /* not SK_USE_LAC_EV */
|
|
|
|
case SKGE_DRV: /* Driver Event */
|
|
|
|
Rtv = SkDrvEvent(pAC, Ioc, pEv->Event, pEv->Para);
|
|
|
|
break;
|
2024-01-07 23:57:24 +01:00
|
|
|
#ifndef SK_USE_SW_TIMER
|
2024-01-09 13:43:28 +01:00
|
|
|
case SKGE_HWAC:
|
|
|
|
Rtv = SkGeSirqEvent(pAC, Ioc, pEv->Event, pEv->Para);
|
|
|
|
break;
|
2024-01-07 23:57:24 +01:00
|
|
|
#else /* !SK_USE_SW_TIMER */
|
2024-01-09 13:43:28 +01:00
|
|
|
case SKGE_SWT :
|
|
|
|
Rtv = SkSwtEvent(pAC, Ioc, pEv->Event, pEv->Para);
|
|
|
|
break;
|
2024-01-07 23:57:24 +01:00
|
|
|
#endif /* !SK_USE_SW_TIMER */
|
|
|
|
#ifdef SK_USE_LAC_EV
|
|
|
|
case SKGE_LACP :
|
2024-01-09 13:43:28 +01:00
|
|
|
Rtv = SkLacpEvent(pAC, Ioc, pEv->Event, pEv->Para);
|
|
|
|
break;
|
2024-01-07 23:57:24 +01:00
|
|
|
case SKGE_RSF :
|
2024-01-09 13:43:28 +01:00
|
|
|
Rtv = SkRsfEvent(pAC, Ioc, pEv->Event, pEv->Para);
|
|
|
|
break;
|
2024-01-07 23:57:24 +01:00
|
|
|
case SKGE_MARKER :
|
2024-01-09 13:43:28 +01:00
|
|
|
Rtv = SkMarkerEvent(pAC, Ioc, pEv->Event, pEv->Para);
|
|
|
|
break;
|
2024-01-07 23:57:24 +01:00
|
|
|
case SKGE_FD :
|
2024-01-09 13:43:28 +01:00
|
|
|
Rtv = SkFdEvent(pAC, Ioc, pEv->Event, pEv->Para);
|
|
|
|
break;
|
2024-01-07 23:57:24 +01:00
|
|
|
#endif /* SK_USE_LAC_EV */
|
2024-01-09 13:43:28 +01:00
|
|
|
#ifdef SK_ASF
|
|
|
|
case SKGE_ASF :
|
|
|
|
Rtv = SkAsfEvent(pAC,Ioc,pEv->Event,pEv->Para);
|
|
|
|
break ;
|
|
|
|
#endif
|
2024-01-07 23:57:24 +01:00
|
|
|
#ifdef SK_USE_CSUM
|
|
|
|
case SKGE_CSUM :
|
2024-01-09 13:43:28 +01:00
|
|
|
Rtv = SkCsEvent(pAC, Ioc, pEv->Event, pEv->Para);
|
|
|
|
break;
|
2024-01-07 23:57:24 +01:00
|
|
|
#endif /* SK_USE_CSUM */
|
|
|
|
default :
|
2024-01-09 13:43:28 +01:00
|
|
|
#if 0 // u-boot
|
|
|
|
SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_Q_E002, SKERR_Q_E002MSG);
|
|
|
|
#endif
|
2024-01-07 23:57:24 +01:00
|
|
|
Rtv = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Rtv != 0) {
|
2024-01-09 13:43:28 +01:00
|
|
|
/*
|
|
|
|
* 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);
|
2024-01-07 23:57:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (++pEv == &pAC->Event.EvQueue[SK_MAX_EVENT])
|
2024-01-09 13:43:28 +01:00
|
|
|
pEv = pAC->Event.EvQueue;
|
2024-01-07 23:57:24 +01:00
|
|
|
|
|
|
|
/* Renew get: it is used in queue_events to detect overruns */
|
|
|
|
pAC->Event.EvGet = pEv;
|
|
|
|
}
|
|
|
|
|
2024-01-09 13:43:28 +01:00
|
|
|
return(0);
|
2024-01-07 23:57:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* End of file */
|
2024-01-09 13:43:28 +01:00
|
|
|
|
|
|
|
#endif
|