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