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