skqueue.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /******************************************************************************
  2. *
  3. * Name: skqueue.c
  4. * Project: GEnesis, PCI Gigabit Ethernet Adapter
  5. * Version: $Revision: 1.18 $
  6. * Date: $Date: 2002/05/07 14:11:11 $
  7. * Purpose: Management of an event queue.
  8. *
  9. ******************************************************************************/
  10. /******************************************************************************
  11. *
  12. * (C)Copyright 1998,1999 SysKonnect,
  13. * a business unit of Schneider & Koch & Co. Datensysteme GmbH.
  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. *
  25. * History:
  26. *
  27. * $Log: skqueue.c,v $
  28. * Revision 1.18 2002/05/07 14:11:11 rwahl
  29. * Fixed Watcom Precompiler error.
  30. *
  31. * Revision 1.17 2002/03/25 10:06:41 mkunz
  32. * SkIgnoreEvent deleted
  33. *
  34. * Revision 1.16 2002/03/15 10:51:59 mkunz
  35. * Added event classes for link aggregation
  36. *
  37. * Revision 1.15 1999/11/22 13:36:29 cgoos
  38. * Changed license header to GPL.
  39. *
  40. * Revision 1.14 1998/10/15 15:11:35 gklug
  41. * fix: ID_sccs to SysKonnectFileId
  42. *
  43. * Revision 1.13 1998/09/08 08:47:52 gklug
  44. * add: init level handling
  45. *
  46. * Revision 1.12 1998/09/08 07:43:20 gklug
  47. * fix: Sirq Event function name
  48. *
  49. * Revision 1.11 1998/09/08 05:54:34 gklug
  50. * chg: define SK_CSUM is replaced by SK_USE_CSUM
  51. *
  52. * Revision 1.10 1998/09/03 14:14:49 gklug
  53. * add: CSUM and HWAC Eventclass and function.
  54. *
  55. * Revision 1.9 1998/08/19 09:50:50 gklug
  56. * fix: remove struct keyword from c-code (see CCC) add typedefs
  57. *
  58. * Revision 1.8 1998/08/17 13:43:11 gklug
  59. * chg: Parameter will be union of 64bit para, 2 times SK_U32 or SK_PTR
  60. *
  61. * Revision 1.7 1998/08/14 07:09:11 gklug
  62. * fix: chg pAc -> pAC
  63. *
  64. * Revision 1.6 1998/08/11 12:13:14 gklug
  65. * add: return code feature of Event service routines
  66. * add: correct Error log calls
  67. *
  68. * Revision 1.5 1998/08/07 12:53:45 gklug
  69. * fix: first compiled version
  70. *
  71. * Revision 1.4 1998/08/07 09:20:48 gklug
  72. * adapt functions to C coding conventions.
  73. *
  74. * Revision 1.3 1998/08/05 11:29:32 gklug
  75. * rmv: Timer event entry. Timer will queue event directly
  76. *
  77. * Revision 1.2 1998/07/31 11:22:40 gklug
  78. * Initial version
  79. *
  80. * Revision 1.1 1998/07/30 15:14:01 gklug
  81. * Initial version. Adapted from SMT
  82. *
  83. *
  84. *
  85. ******************************************************************************/
  86. #include <config.h>
  87. #ifdef CONFIG_SK98
  88. /*
  89. Event queue and dispatcher
  90. */
  91. static const char SysKonnectFileId[] =
  92. "$Header: /usr56/projects/ge/schedule/skqueue.c,v 1.18 2002/05/07 14:11:11 rwahl Exp $" ;
  93. #include "h/skdrv1st.h" /* Driver Specific Definitions */
  94. #include "h/skqueue.h" /* Queue Definitions */
  95. #include "h/skdrv2nd.h" /* Adapter Control- and Driver specific Def. */
  96. #ifdef __C2MAN__
  97. /*
  98. Event queue management.
  99. General Description:
  100. */
  101. intro()
  102. {}
  103. #endif
  104. #define PRINTF(a,b,c)
  105. /*
  106. * init event queue management
  107. *
  108. * Must be called during init level 0.
  109. */
  110. void SkEventInit(
  111. SK_AC *pAC, /* Adapter context */
  112. SK_IOC Ioc, /* IO context */
  113. int Level) /* Init level */
  114. {
  115. switch (Level) {
  116. case SK_INIT_DATA:
  117. pAC->Event.EvPut = pAC->Event.EvGet = pAC->Event.EvQueue ;
  118. break;
  119. default:
  120. break;
  121. }
  122. }
  123. /*
  124. * add event to queue
  125. */
  126. void SkEventQueue(
  127. SK_AC *pAC, /* Adapters context */
  128. SK_U32 Class, /* Event Class */
  129. SK_U32 Event, /* Event to be queued */
  130. SK_EVPARA Para) /* Event parameter */
  131. {
  132. pAC->Event.EvPut->Class = Class ;
  133. pAC->Event.EvPut->Event = Event ;
  134. pAC->Event.EvPut->Para = Para ;
  135. if (++pAC->Event.EvPut == &pAC->Event.EvQueue[SK_MAX_EVENT])
  136. pAC->Event.EvPut = pAC->Event.EvQueue ;
  137. if (pAC->Event.EvPut == pAC->Event.EvGet) {
  138. SK_ERR_LOG(pAC, SK_ERRCL_NORES, SKERR_Q_E001, SKERR_Q_E001MSG) ;
  139. }
  140. }
  141. /*
  142. * event dispatcher
  143. * while event queue is not empty
  144. * get event from queue
  145. * send command to state machine
  146. * end
  147. * return error reported by individual Event function
  148. * 0 if no error occured.
  149. */
  150. int SkEventDispatcher(
  151. SK_AC *pAC, /* Adapters Context */
  152. SK_IOC Ioc) /* Io context */
  153. {
  154. SK_EVENTELEM *pEv ; /* pointer into queue */
  155. SK_U32 Class ;
  156. int Rtv ;
  157. pEv = pAC->Event.EvGet ;
  158. PRINTF("dispatch get %x put %x\n",pEv,pAC->Event.ev_put) ;
  159. while (pEv != pAC->Event.EvPut) {
  160. PRINTF("dispatch Class %d Event %d\n",pEv->Class,pEv->Event) ;
  161. switch(Class = pEv->Class) {
  162. #ifndef SK_USE_LAC_EV
  163. case SKGE_RLMT : /* RLMT Event */
  164. Rtv = SkRlmtEvent(pAC,Ioc,pEv->Event,pEv->Para);
  165. break ;
  166. case SKGE_I2C : /* I2C Event */
  167. Rtv = SkI2cEvent(pAC,Ioc,pEv->Event,pEv->Para);
  168. break ;
  169. case SKGE_PNMI :
  170. Rtv = SkPnmiEvent(pAC,Ioc,pEv->Event,pEv->Para);
  171. break ;
  172. #endif /* SK_USE_LAC_EV */
  173. case SKGE_DRV : /* Driver Event */
  174. Rtv = SkDrvEvent(pAC,Ioc,pEv->Event,pEv->Para);
  175. break ;
  176. #ifndef SK_USE_SW_TIMER
  177. case SKGE_HWAC :
  178. Rtv = SkGeSirqEvent(pAC,Ioc,pEv->Event,pEv->Para);
  179. break ;
  180. #else /* !SK_USE_SW_TIMER */
  181. case SKGE_SWT :
  182. Rtv = SkSwtEvent(pAC,Ioc,pEv->Event,pEv->Para);
  183. break ;
  184. #endif /* !SK_USE_SW_TIMER */
  185. #ifdef SK_USE_LAC_EV
  186. case SKGE_LACP :
  187. Rtv = SkLacpEvent(pAC,Ioc,pEv->Event,pEv->Para);
  188. break ;
  189. case SKGE_RSF :
  190. Rtv = SkRsfEvent(pAC,Ioc,pEv->Event,pEv->Para);
  191. break ;
  192. case SKGE_MARKER :
  193. Rtv = SkMarkerEvent(pAC,Ioc,pEv->Event,pEv->Para);
  194. break ;
  195. case SKGE_FD :
  196. Rtv = SkFdEvent(pAC,Ioc,pEv->Event,pEv->Para);
  197. break ;
  198. #endif /* SK_USE_LAC_EV */
  199. #ifdef SK_USE_CSUM
  200. case SKGE_CSUM :
  201. Rtv = SkCsEvent(pAC,Ioc,pEv->Event,pEv->Para);
  202. break ;
  203. #endif /* SK_USE_CSUM */
  204. default :
  205. SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_Q_E002,
  206. SKERR_Q_E002MSG) ;
  207. Rtv = 0;
  208. }
  209. if (Rtv != 0) {
  210. return(Rtv) ;
  211. }
  212. if (++pEv == &pAC->Event.EvQueue[SK_MAX_EVENT])
  213. pEv = pAC->Event.EvQueue ;
  214. /* Renew get: it is used in queue_events to detect overruns */
  215. pAC->Event.EvGet = pEv;
  216. }
  217. return(0) ;
  218. }
  219. #endif /* CONFIG_SK98 */
  220. /* End of file */