skqueue.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /******************************************************************************
  2. *
  3. * Name: skqueue.c
  4. * Project: Gigabit Ethernet Adapters, Event Scheduler Module
  5. * Version: $Revision: 1.20 $
  6. * Date: $Date: 2003/09/16 13:44:00 $
  7. * Purpose: Management of an event queue.
  8. *
  9. ******************************************************************************/
  10. /******************************************************************************
  11. *
  12. * (C)Copyright 1998-2002 SysKonnect GmbH.
  13. * (C)Copyright 2002-2003 Marvell.
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * The information in this file is provided "AS IS" without warranty.
  21. *
  22. ******************************************************************************/
  23. /*
  24. * Event queue and dispatcher
  25. */
  26. #if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
  27. static const char SysKonnectFileId[] =
  28. "@(#) $Id: skqueue.c,v 1.20 2003/09/16 13:44:00 rschmidt Exp $ (C) Marvell.";
  29. #endif
  30. #include "h/skdrv1st.h" /* Driver Specific Definitions */
  31. #include "h/skqueue.h" /* Queue Definitions */
  32. #include "h/skdrv2nd.h" /* Adapter Control- and Driver specific Def. */
  33. #ifdef __C2MAN__
  34. /*
  35. Event queue management.
  36. General Description:
  37. */
  38. intro()
  39. {}
  40. #endif
  41. #define PRINTF(a,b,c)
  42. /*
  43. * init event queue management
  44. *
  45. * Must be called during init level 0.
  46. */
  47. void SkEventInit(
  48. SK_AC *pAC, /* Adapter context */
  49. SK_IOC Ioc, /* IO context */
  50. int Level) /* Init level */
  51. {
  52. switch (Level) {
  53. case SK_INIT_DATA:
  54. pAC->Event.EvPut = pAC->Event.EvGet = pAC->Event.EvQueue;
  55. break;
  56. default:
  57. break;
  58. }
  59. }
  60. /*
  61. * add event to queue
  62. */
  63. void SkEventQueue(
  64. SK_AC *pAC, /* Adapters context */
  65. SK_U32 Class, /* Event Class */
  66. SK_U32 Event, /* Event to be queued */
  67. SK_EVPARA Para) /* Event parameter */
  68. {
  69. pAC->Event.EvPut->Class = Class;
  70. pAC->Event.EvPut->Event = Event;
  71. pAC->Event.EvPut->Para = Para;
  72. if (++pAC->Event.EvPut == &pAC->Event.EvQueue[SK_MAX_EVENT])
  73. pAC->Event.EvPut = pAC->Event.EvQueue;
  74. if (pAC->Event.EvPut == pAC->Event.EvGet) {
  75. SK_ERR_LOG(pAC, SK_ERRCL_NORES, SKERR_Q_E001, SKERR_Q_E001MSG);
  76. }
  77. }
  78. /*
  79. * event dispatcher
  80. * while event queue is not empty
  81. * get event from queue
  82. * send command to state machine
  83. * end
  84. * return error reported by individual Event function
  85. * 0 if no error occured.
  86. */
  87. int SkEventDispatcher(
  88. SK_AC *pAC, /* Adapters Context */
  89. SK_IOC Ioc) /* Io context */
  90. {
  91. SK_EVENTELEM *pEv; /* pointer into queue */
  92. SK_U32 Class;
  93. int Rtv;
  94. pEv = pAC->Event.EvGet;
  95. PRINTF("dispatch get %x put %x\n", pEv, pAC->Event.ev_put);
  96. while (pEv != pAC->Event.EvPut) {
  97. PRINTF("dispatch Class %d Event %d\n", pEv->Class, pEv->Event);
  98. switch (Class = pEv->Class) {
  99. #ifndef SK_USE_LAC_EV
  100. #ifndef SK_SLIM
  101. case SKGE_RLMT: /* RLMT Event */
  102. Rtv = SkRlmtEvent(pAC, Ioc, pEv->Event, pEv->Para);
  103. break;
  104. case SKGE_I2C: /* I2C Event */
  105. Rtv = SkI2cEvent(pAC, Ioc, pEv->Event, pEv->Para);
  106. break;
  107. case SKGE_PNMI: /* PNMI Event */
  108. Rtv = SkPnmiEvent(pAC, Ioc, pEv->Event, pEv->Para);
  109. break;
  110. #endif /* not SK_SLIM */
  111. #endif /* not SK_USE_LAC_EV */
  112. case SKGE_DRV: /* Driver Event */
  113. Rtv = SkDrvEvent(pAC, Ioc, pEv->Event, pEv->Para);
  114. break;
  115. #ifndef SK_USE_SW_TIMER
  116. case SKGE_HWAC:
  117. Rtv = SkGeSirqEvent(pAC, Ioc, pEv->Event, pEv->Para);
  118. break;
  119. #else /* !SK_USE_SW_TIMER */
  120. case SKGE_SWT :
  121. Rtv = SkSwtEvent(pAC, Ioc, pEv->Event, pEv->Para);
  122. break;
  123. #endif /* !SK_USE_SW_TIMER */
  124. #ifdef SK_USE_LAC_EV
  125. case SKGE_LACP :
  126. Rtv = SkLacpEvent(pAC, Ioc, pEv->Event, pEv->Para);
  127. break;
  128. case SKGE_RSF :
  129. Rtv = SkRsfEvent(pAC, Ioc, pEv->Event, pEv->Para);
  130. break;
  131. case SKGE_MARKER :
  132. Rtv = SkMarkerEvent(pAC, Ioc, pEv->Event, pEv->Para);
  133. break;
  134. case SKGE_FD :
  135. Rtv = SkFdEvent(pAC, Ioc, pEv->Event, pEv->Para);
  136. break;
  137. #endif /* SK_USE_LAC_EV */
  138. #ifdef SK_USE_CSUM
  139. case SKGE_CSUM :
  140. Rtv = SkCsEvent(pAC, Ioc, pEv->Event, pEv->Para);
  141. break;
  142. #endif /* SK_USE_CSUM */
  143. default :
  144. SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_Q_E002, SKERR_Q_E002MSG);
  145. Rtv = 0;
  146. }
  147. if (Rtv != 0) {
  148. return(Rtv);
  149. }
  150. if (++pEv == &pAC->Event.EvQueue[SK_MAX_EVENT])
  151. pEv = pAC->Event.EvQueue;
  152. /* Renew get: it is used in queue_events to detect overruns */
  153. pAC->Event.EvGet = pEv;
  154. }
  155. return(0);
  156. }
  157. /* End of file */