blob: c49baed4f04a1f8088ec9307766e4f8b5c54958a [file] [log] [blame]
wdenk7152b1d2003-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.
wdenk42d1f032003-10-15 23:53:47 +000032 *
wdenk7152b1d2003-09-05 23:19:14 +000033 * Revision 1.17 2002/03/25 10:06:41 mkunz
34 * SkIgnoreEvent deleted
wdenk42d1f032003-10-15 23:53:47 +000035 *
wdenk7152b1d2003-09-05 23:19:14 +000036 * Revision 1.16 2002/03/15 10:51:59 mkunz
37 * Added event classes for link aggregation
wdenk42d1f032003-10-15 23:53:47 +000038 *
wdenk7152b1d2003-09-05 23:19:14 +000039 * Revision 1.15 1999/11/22 13:36:29 cgoos
40 * Changed license header to GPL.
wdenk42d1f032003-10-15 23:53:47 +000041 *
wdenk7152b1d2003-09-05 23:19:14 +000042 * Revision 1.14 1998/10/15 15:11:35 gklug
43 * fix: ID_sccs to SysKonnectFileId
wdenk42d1f032003-10-15 23:53:47 +000044 *
wdenk7152b1d2003-09-05 23:19:14 +000045 * Revision 1.13 1998/09/08 08:47:52 gklug
46 * add: init level handling
wdenk42d1f032003-10-15 23:53:47 +000047 *
wdenk7152b1d2003-09-05 23:19:14 +000048 * Revision 1.12 1998/09/08 07:43:20 gklug
49 * fix: Sirq Event function name
wdenk42d1f032003-10-15 23:53:47 +000050 *
wdenk7152b1d2003-09-05 23:19:14 +000051 * Revision 1.11 1998/09/08 05:54:34 gklug
52 * chg: define SK_CSUM is replaced by SK_USE_CSUM
wdenk42d1f032003-10-15 23:53:47 +000053 *
wdenk7152b1d2003-09-05 23:19:14 +000054 * Revision 1.10 1998/09/03 14:14:49 gklug
55 * add: CSUM and HWAC Eventclass and function.
wdenk42d1f032003-10-15 23:53:47 +000056 *
wdenk7152b1d2003-09-05 23:19:14 +000057 * Revision 1.9 1998/08/19 09:50:50 gklug
58 * fix: remove struct keyword from c-code (see CCC) add typedefs
wdenk42d1f032003-10-15 23:53:47 +000059 *
wdenk7152b1d2003-09-05 23:19:14 +000060 * 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
wdenk42d1f032003-10-15 23:53:47 +000062 *
wdenk7152b1d2003-09-05 23:19:14 +000063 * Revision 1.7 1998/08/14 07:09:11 gklug
64 * fix: chg pAc -> pAC
wdenk42d1f032003-10-15 23:53:47 +000065 *
wdenk7152b1d2003-09-05 23:19:14 +000066 * 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
wdenk42d1f032003-10-15 23:53:47 +000069 *
wdenk7152b1d2003-09-05 23:19:14 +000070 * Revision 1.5 1998/08/07 12:53:45 gklug
71 * fix: first compiled version
wdenk42d1f032003-10-15 23:53:47 +000072 *
wdenk7152b1d2003-09-05 23:19:14 +000073 * Revision 1.4 1998/08/07 09:20:48 gklug
74 * adapt functions to C coding conventions.
wdenk42d1f032003-10-15 23:53:47 +000075 *
wdenk7152b1d2003-09-05 23:19:14 +000076 * Revision 1.3 1998/08/05 11:29:32 gklug
77 * rmv: Timer event entry. Timer will queue event directly
wdenk42d1f032003-10-15 23:53:47 +000078 *
wdenk7152b1d2003-09-05 23:19:14 +000079 * Revision 1.2 1998/07/31 11:22:40 gklug
80 * Initial version
wdenk42d1f032003-10-15 23:53:47 +000081 *
wdenk7152b1d2003-09-05 23:19:14 +000082 * Revision 1.1 1998/07/30 15:14:01 gklug
83 * Initial version. Adapted from SMT
wdenk42d1f032003-10-15 23:53:47 +000084 *
85 *
wdenk7152b1d2003-09-05 23:19:14 +000086 *
87 ******************************************************************************/
88
89
wdenk149dded2003-09-10 18:20:28 +000090#include <config.h>
91
92#ifdef CONFIG_SK98
93
wdenk7152b1d2003-09-05 23:19:14 +000094/*
95 Event queue and dispatcher
96*/
97static const char SysKonnectFileId[] =
98 "$Header: /usr56/projects/ge/schedule/skqueue.c,v 1.18 2002/05/07 14:11:11 rwahl Exp $" ;
99
100#include "h/skdrv1st.h" /* Driver Specific Definitions */
101#include "h/skqueue.h" /* Queue Definitions */
102#include "h/skdrv2nd.h" /* Adapter Control- and Driver specific Def. */
103
104#ifdef __C2MAN__
105/*
106 Event queue management.
107
108 General Description:
109
110 */
111intro()
112{}
113#endif
114
115#define PRINTF(a,b,c)
116
117/*
118 * init event queue management
119 *
120 * Must be called during init level 0.
121 */
122void SkEventInit(
123SK_AC *pAC, /* Adapter context */
124SK_IOC Ioc, /* IO context */
125int Level) /* Init level */
126{
127 switch (Level) {
128 case SK_INIT_DATA:
129 pAC->Event.EvPut = pAC->Event.EvGet = pAC->Event.EvQueue ;
130 break;
131 default:
132 break;
133 }
134}
135
136/*
137 * add event to queue
138 */
139void SkEventQueue(
140SK_AC *pAC, /* Adapters context */
141SK_U32 Class, /* Event Class */
142SK_U32 Event, /* Event to be queued */
143SK_EVPARA Para) /* Event parameter */
144{
145 pAC->Event.EvPut->Class = Class ;
146 pAC->Event.EvPut->Event = Event ;
147 pAC->Event.EvPut->Para = Para ;
148 if (++pAC->Event.EvPut == &pAC->Event.EvQueue[SK_MAX_EVENT])
149 pAC->Event.EvPut = pAC->Event.EvQueue ;
150
151 if (pAC->Event.EvPut == pAC->Event.EvGet) {
152 SK_ERR_LOG(pAC, SK_ERRCL_NORES, SKERR_Q_E001, SKERR_Q_E001MSG) ;
153 }
154}
155
156/*
157 * event dispatcher
158 * while event queue is not empty
159 * get event from queue
160 * send command to state machine
161 * end
162 * return error reported by individual Event function
163 * 0 if no error occured.
164 */
165int SkEventDispatcher(
166SK_AC *pAC, /* Adapters Context */
167SK_IOC Ioc) /* Io context */
168{
169 SK_EVENTELEM *pEv ; /* pointer into queue */
170 SK_U32 Class ;
171 int Rtv ;
172
173 pEv = pAC->Event.EvGet ;
174 PRINTF("dispatch get %x put %x\n",pEv,pAC->Event.ev_put) ;
175 while (pEv != pAC->Event.EvPut) {
176 PRINTF("dispatch Class %d Event %d\n",pEv->Class,pEv->Event) ;
177 switch(Class = pEv->Class) {
wdenk42d1f032003-10-15 23:53:47 +0000178#ifndef SK_USE_LAC_EV
wdenk7152b1d2003-09-05 23:19:14 +0000179 case SKGE_RLMT : /* RLMT Event */
180 Rtv = SkRlmtEvent(pAC,Ioc,pEv->Event,pEv->Para);
181 break ;
182 case SKGE_I2C : /* I2C Event */
183 Rtv = SkI2cEvent(pAC,Ioc,pEv->Event,pEv->Para);
184 break ;
185 case SKGE_PNMI :
186 Rtv = SkPnmiEvent(pAC,Ioc,pEv->Event,pEv->Para);
187 break ;
188#endif /* SK_USE_LAC_EV */
189 case SKGE_DRV : /* Driver Event */
190 Rtv = SkDrvEvent(pAC,Ioc,pEv->Event,pEv->Para);
191 break ;
wdenk42d1f032003-10-15 23:53:47 +0000192#ifndef SK_USE_SW_TIMER
wdenk7152b1d2003-09-05 23:19:14 +0000193 case SKGE_HWAC :
194 Rtv = SkGeSirqEvent(pAC,Ioc,pEv->Event,pEv->Para);
195 break ;
196#else /* !SK_USE_SW_TIMER */
wdenk42d1f032003-10-15 23:53:47 +0000197 case SKGE_SWT :
wdenk7152b1d2003-09-05 23:19:14 +0000198 Rtv = SkSwtEvent(pAC,Ioc,pEv->Event,pEv->Para);
199 break ;
200#endif /* !SK_USE_SW_TIMER */
wdenk42d1f032003-10-15 23:53:47 +0000201#ifdef SK_USE_LAC_EV
wdenk7152b1d2003-09-05 23:19:14 +0000202 case SKGE_LACP :
203 Rtv = SkLacpEvent(pAC,Ioc,pEv->Event,pEv->Para);
204 break ;
205 case SKGE_RSF :
206 Rtv = SkRsfEvent(pAC,Ioc,pEv->Event,pEv->Para);
207 break ;
208 case SKGE_MARKER :
209 Rtv = SkMarkerEvent(pAC,Ioc,pEv->Event,pEv->Para);
210 break ;
211 case SKGE_FD :
212 Rtv = SkFdEvent(pAC,Ioc,pEv->Event,pEv->Para);
213 break ;
214#endif /* SK_USE_LAC_EV */
215#ifdef SK_USE_CSUM
216 case SKGE_CSUM :
217 Rtv = SkCsEvent(pAC,Ioc,pEv->Event,pEv->Para);
218 break ;
219#endif /* SK_USE_CSUM */
220 default :
221 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_Q_E002,
222 SKERR_Q_E002MSG) ;
223 Rtv = 0;
224 }
225
226 if (Rtv != 0) {
227 return(Rtv) ;
228 }
229
230 if (++pEv == &pAC->Event.EvQueue[SK_MAX_EVENT])
231 pEv = pAC->Event.EvQueue ;
232
233 /* Renew get: it is used in queue_events to detect overruns */
234 pAC->Event.EvGet = pEv;
235 }
236
237 return(0) ;
238}
239
wdenk149dded2003-09-10 18:20:28 +0000240#endif /* CONFIG_SK98 */
241
wdenk7152b1d2003-09-05 23:19:14 +0000242/* End of file */