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