summaryrefslogtreecommitdiffstats
path: root/drivers/sk98lin/skqueue.c
blob: c9740e316baa045e0ff8b863b472efd35e8f4c76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/******************************************************************************
 *
 * Name:	skqueue.c
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
 * Version:	$Revision: 1.18 $
 * Date:	$Date: 2002/05/07 14:11:11 $
 * Purpose:	Management of an event queue.
 *
 ******************************************************************************/

/******************************************************************************
 *
 *	(C)Copyright 1998,1999 SysKonnect,
 *	a business unit of Schneider & Koch & Co. Datensysteme GmbH.
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation; either version 2 of the License, or
 *	(at your option) any later version.
 *
 *	The information in this file is provided "AS IS" without warranty.
 *
 ******************************************************************************/

/******************************************************************************
 *
 * History:
 *
 *	$Log: skqueue.c,v $
 *	Revision 1.18  2002/05/07 14:11:11  rwahl
 *	Fixed Watcom Precompiler error.
 *	
 *	Revision 1.17  2002/03/25 10:06:41  mkunz
 *	SkIgnoreEvent deleted
 *	
 *	Revision 1.16  2002/03/15 10:51:59  mkunz
 *	Added event classes for link aggregation
 *	
 *	Revision 1.15  1999/11/22 13:36:29  cgoos
 *	Changed license header to GPL.
 *	
 *	Revision 1.14  1998/10/15 15:11:35  gklug
 *	fix: ID_sccs to SysKonnectFileId
 *	
 *	Revision 1.13  1998/09/08 08:47:52  gklug
 *	add: init level handling
 *	
 *	Revision 1.12  1998/09/08 07:43:20  gklug
 *	fix: Sirq Event function name
 *	
 *	Revision 1.11  1998/09/08 05:54:34  gklug
 *	chg: define SK_CSUM is replaced by SK_USE_CSUM
 *	
 *	Revision 1.10  1998/09/03 14:14:49  gklug
 *	add: CSUM and HWAC Eventclass and function.
 *	
 *	Revision 1.9  1998/08/19 09:50:50  gklug
 *	fix: remove struct keyword from c-code (see CCC) add typedefs
 *	
 *	Revision 1.8  1998/08/17 13:43:11  gklug
 *	chg: Parameter will be union of 64bit para, 2 times SK_U32 or SK_PTR
 *	
 *	Revision 1.7  1998/08/14 07:09:11  gklug
 *	fix: chg pAc -> pAC
 *	
 *	Revision 1.6  1998/08/11 12:13:14  gklug
 *	add: return code feature of Event service routines
 *	add: correct Error log calls
 *	
 *	Revision 1.5  1998/08/07 12:53:45  gklug
 *	fix: first compiled version
 *	
 *	Revision 1.4  1998/08/07 09:20:48  gklug
 *	adapt functions to C coding conventions.
 *	
 *	Revision 1.3  1998/08/05 11:29:32  gklug
 *	rmv: Timer event entry. Timer will queue event directly
 *	
 *	Revision 1.2  1998/07/31 11:22:40  gklug
 *	Initial version
 *	
 *	Revision 1.1  1998/07/30 15:14:01  gklug
 *	Initial version. Adapted from SMT
 *	
 *	
 *
 ******************************************************************************/


#include <config.h>

#ifdef CONFIG_SK98

/*
	Event queue and dispatcher
*/
static const char SysKonnectFileId[] =
	"$Header: /usr56/projects/ge/schedule/skqueue.c,v 1.18 2002/05/07 14:11:11 rwahl Exp $" ;

#include "h/skdrv1st.h"		/* Driver Specific Definitions */
#include "h/skqueue.h"		/* Queue Definitions */
#include "h/skdrv2nd.h"		/* Adapter Control- and Driver specific Def. */

#ifdef __C2MAN__
/*
	Event queue management.

	General Description:

 */
intro()
{}
#endif

#define PRINTF(a,b,c)

/*
 * init event queue management
 *
 * Must be called during init level 0.
 */
void	SkEventInit(
SK_AC	*pAC,	/* Adapter context */
SK_IOC	Ioc,	/* IO context */
int	Level)	/* Init level */
{
	switch (Level) {
	case SK_INIT_DATA:
		pAC->Event.EvPut = pAC->Event.EvGet = pAC->Event.EvQueue ;
		break;
	default:
		break;
	}
}

/*
 * add event to queue
 */
void	SkEventQueue(
SK_AC		*pAC,	/* Adapters context */
SK_U32		Class,	/* Event Class */
SK_U32		Event,	/* Event to be queued */
SK_EVPARA	Para)	/* Event parameter */
{
	pAC->Event.EvPut->Class = Class ;
	pAC->Event.EvPut->Event = Event ;
	pAC->Event.EvPut->Para = Para ;
	if (++pAC->Event.EvPut == &pAC->Event.EvQueue[SK_MAX_EVENT])
		pAC->Event.EvPut = pAC->Event.EvQueue ;

	if (pAC->Event.EvPut == pAC->Event.EvGet) {
		SK_ERR_LOG(pAC, SK_ERRCL_NORES, SKERR_Q_E001, SKERR_Q_E001MSG) ;
	}
}

/*
 * event dispatcher
 *	while event queue is not empty
 *		get event from queue
 *		send command to state machine
 *	end
 *	return error reported by individual Event function
 *		0 if no error occured.
 */
int	SkEventDispatcher(
SK_AC	*pAC,	/* Adapters Context */
SK_IOC	Ioc)	/* Io context */
{
	SK_EVENTELEM	*pEv ;	/* pointer into queue */
	SK_U32			Class ;
	int			Rtv ;

	pEv = pAC->Event.EvGet ;
	PRINTF("dispatch get %x put %x\n",pEv,pAC->Event.ev_put) ;
	while (pEv != pAC->Event.EvPut) {
		PRINTF("dispatch Class %d Event %d\n",pEv->Class,pEv->Event) ;
		switch(Class = pEv->Class) {
#ifndef SK_USE_LAC_EV        
		case SKGE_RLMT :	/* RLMT Event */
			Rtv = SkRlmtEvent(pAC,Ioc,pEv->Event,pEv->Para);
			break ;
		case SKGE_I2C :		/* I2C Event */
			Rtv = SkI2cEvent(pAC,Ioc,pEv->Event,pEv->Para);
			break ;
		case SKGE_PNMI :
			Rtv = SkPnmiEvent(pAC,Ioc,pEv->Event,pEv->Para);
			break ;
#endif /* SK_USE_LAC_EV */
		case SKGE_DRV :		/* Driver Event */
			Rtv = SkDrvEvent(pAC,Ioc,pEv->Event,pEv->Para);
			break ;
#ifndef SK_USE_SW_TIMER        
		case SKGE_HWAC :
			Rtv = SkGeSirqEvent(pAC,Ioc,pEv->Event,pEv->Para);
			break ;
#else /* !SK_USE_SW_TIMER */
        case SKGE_SWT : 
			Rtv = SkSwtEvent(pAC,Ioc,pEv->Event,pEv->Para);
			break ;
#endif /* !SK_USE_SW_TIMER */
#ifdef SK_USE_LAC_EV        
		case SKGE_LACP :
			Rtv = SkLacpEvent(pAC,Ioc,pEv->Event,pEv->Para);
			break ;
		case SKGE_RSF :
			Rtv = SkRsfEvent(pAC,Ioc,pEv->Event,pEv->Para);
			break ;
		case SKGE_MARKER :
			Rtv = SkMarkerEvent(pAC,Ioc,pEv->Event,pEv->Para);
			break ;
		case SKGE_FD :
			Rtv = SkFdEvent(pAC,Ioc,pEv->Event,pEv->Para);
			break ;
#endif /* SK_USE_LAC_EV */
#ifdef	SK_USE_CSUM
		case SKGE_CSUM :
			Rtv = SkCsEvent(pAC,Ioc,pEv->Event,pEv->Para);
			break ;
#endif	/* SK_USE_CSUM */
		default :
			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_Q_E002,
				SKERR_Q_E002MSG) ;
			Rtv = 0;
		}

		if (Rtv != 0) {
			return(Rtv) ;
		}

		if (++pEv == &pAC->Event.EvQueue[SK_MAX_EVENT])
			pEv = pAC->Event.EvQueue ;

		/* Renew get: it is used in queue_events to detect overruns */
		pAC->Event.EvGet = pEv;
	}

	return(0) ;
}

#endif /* CONFIG_SK98 */

/* End of file */
OpenPOWER on IntegriCloud