File: /usr/src/linux/drivers/net/sk98lin/skqueue.c

1     /******************************************************************************
2      *
3      * Name:	skqueue.c
4      * Project:	PCI Gigabit Ethernet Adapter
5      * Version:	$Revision: 1.14 $
6      * Date:	$Date: 1998/10/15 15:11:35 $
7      * Purpose:	Management of an event queue.
8      *
9      ******************************************************************************/
10     
11     /******************************************************************************
12      *
13      *	(C)Copyright 1989-1998 SysKonnect,
14      *	a business unit of Schneider & Koch & Co. Datensysteme GmbH.
15      *	All Rights Reserved
16      *
17      *	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SYSKONNECT
18      *	The copyright notice above does not evidence any
19      *	actual or intended publication of such source code.
20      *
21      *	This Module contains Proprietary Information of SysKonnect
22      *	and should be treated as Confidential.
23      *
24      *	The information in this file is provided for the exclusive use of
25      *	the licensees of SysKonnect.
26      *	Such users have the right to use, modify, and incorporate this code
27      *	into products for purposes authorized by the license agreement
28      *	provided they include this notice and the associated copyright notice
29      *	with any such product.
30      *	The information in this file is provided "AS IS" without warranty.
31      *
32      ******************************************************************************/
33     
34     /******************************************************************************
35      *
36      * History:
37      *
38      *	$Log: skqueue.c,v $
39      *	Revision 1.14  1998/10/15 15:11:35  gklug
40      *	fix: ID_sccs to SysKonnectFileId
41      *	
42      *	Revision 1.13  1998/09/08 08:47:52  gklug
43      *	add: init level handling
44      *	
45      *	Revision 1.12  1998/09/08 07:43:20  gklug
46      *	fix: Sirq Event function name
47      *	
48      *	Revision 1.11  1998/09/08 05:54:34  gklug
49      *	chg: define SK_CSUM is replaced by SK_USE_CSUM
50      *	
51      *	Revision 1.10  1998/09/03 14:14:49  gklug
52      *	add: CSUM and HWAC Eventclass and function.
53      *	
54      *	Revision 1.9  1998/08/19 09:50:50  gklug
55      *	fix: remove struct keyword from c-code (see CCC) add typedefs
56      *	
57      *	Revision 1.8  1998/08/17 13:43:11  gklug
58      *	chg: Parameter will be union of 64bit para, 2 times SK_U32 or SK_PTR
59      *	
60      *	Revision 1.7  1998/08/14 07:09:11  gklug
61      *	fix: chg pAc -> pAC
62      *	
63      *	Revision 1.6  1998/08/11 12:13:14  gklug
64      *	add: return code feature of Event service routines
65      *	add: correct Error log calls
66      *	
67      *	Revision 1.5  1998/08/07 12:53:45  gklug
68      *	fix: first compiled version
69      *	
70      *	Revision 1.4  1998/08/07 09:20:48  gklug
71      *	adapt functions to C coding conventions.
72      *	
73      *	Revision 1.3  1998/08/05 11:29:32  gklug
74      *	rmv: Timer event entry. Timer will queue event directly
75      *	
76      *	Revision 1.2  1998/07/31 11:22:40  gklug
77      *	Initial version
78      *	
79      *	Revision 1.1  1998/07/30 15:14:01  gklug
80      *	Initial version. Adapted from SMT
81      *	
82      *	
83      *
84      ******************************************************************************/
85     
86     
87     /*
88     	Event queue and dispatcher
89     */
90     static const char SysKonnectFileId[] =
91     	"$Header: /usr56/projects/ge/schedule/skqueue.c,v 1.14 1998/10/15 15:11:35 gklug Exp $" ;
92     
93     #include "h/skdrv1st.h"		/* Driver Specific Definitions */
94     #include "h/skqueue.h"		/* Queue Definitions */
95     #include "h/skdrv2nd.h"		/* Adapter Control- and Driver specific Def. */
96     
97     #ifdef __C2MAN__
98     /*
99     	Event queue management.
100     
101     	General Description:
102     
103      */
104     intro()
105     {}
106     #endif
107     
108     #define PRINTF(a,b,c)
109     
110     /*
111      * init event queue management
112      *
113      * Must be called during init level 0.
114      */
115     void	SkEventInit(
116     SK_AC	*pAC,	/* Adapter context */
117     SK_IOC	Ioc,	/* IO context */
118     int	Level)	/* Init level */
119     {
120     	switch (Level) {
121     	case SK_INIT_DATA:
122     		pAC->Event.EvPut = pAC->Event.EvGet = pAC->Event.EvQueue ;
123     		break;
124     	default:
125     		break;
126     	}
127     }
128     
129     /*
130      * add event to queue
131      */
132     void	SkEventQueue(
133     SK_AC		*pAC,	/* Adapters context */
134     SK_U32		Class,	/* Event Class */
135     SK_U32		Event,	/* Event to be queued */
136     SK_EVPARA	Para)	/* Event parameter */
137     {
138     	pAC->Event.EvPut->Class = Class ;
139     	pAC->Event.EvPut->Event = Event ;
140     	pAC->Event.EvPut->Para = Para ;
141     	if (++pAC->Event.EvPut == &pAC->Event.EvQueue[SK_MAX_EVENT])
142     		pAC->Event.EvPut = pAC->Event.EvQueue ;
143     
144     	if (pAC->Event.EvPut == pAC->Event.EvGet) {
145     		SK_ERR_LOG(pAC, SK_ERRCL_NORES, SKERR_Q_E001, SKERR_Q_E001MSG) ;
146     	}
147     }
148     
149     /*
150      * event dispatcher
151      *	while event queue is not empty
152      *		get event from queue
153      *		send command to state machine
154      *	end
155      *	return error reported by individual Event function
156      *		0 if no error occured.
157      */
158     int	SkEventDispatcher(
159     SK_AC	*pAC,	/* Adapters Context */
160     SK_IOC	Ioc)	/* Io context */
161     {
162     	SK_EVENTELEM	*pEv ;	/* pointer into queue */
163     	SK_U32			Class ;
164     	int			Rtv ;
165     
166     	pEv = pAC->Event.EvGet ;
167     	PRINTF("dispatch get %x put %x\n",pEv,pAC->Event.ev_put) ;
168     	while (pEv != pAC->Event.EvPut) {
169     		PRINTF("dispatch Class %d Event %d\n",pEv->Class,pEv->Event) ;
170     		switch(Class = pEv->Class) {
171     		case SKGE_DRV :		/* Driver Event */
172     			Rtv = SkDrvEvent(pAC,Ioc,pEv->Event,pEv->Para);
173     			break ;
174     		case SKGE_RLMT :	/* RLMT Event */
175     			Rtv = SkRlmtEvent(pAC,Ioc,pEv->Event,pEv->Para);
176     			break ;
177     		case SKGE_I2C :		/* I2C Event */
178     			Rtv = SkI2cEvent(pAC,Ioc,pEv->Event,pEv->Para);
179     			break ;
180     		case SKGE_PNMI :
181     			Rtv = SkPnmiEvent(pAC,Ioc,pEv->Event,pEv->Para);
182     			break ;
183     		case SKGE_HWAC :
184     			Rtv = SkGeSirqEvent(pAC,Ioc,pEv->Event,pEv->Para);
185     			break ;
186     #ifdef	SK_USE_CSUM
187     		case SKGE_CSUM :
188     			Rtv = SkCsEvent(pAC,Ioc,pEv->Event,pEv->Para);
189     			break ;
190     #endif	/* SK_USE_CSUM */
191     		default :
192     			SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_Q_E002,
193     				SKERR_Q_E002MSG) ;
194     			Rtv = 0;
195     		}
196     
197     		if (Rtv != 0) {
198     			return(Rtv) ;
199     		}
200     
201     		if (++pEv == &pAC->Event.EvQueue[SK_MAX_EVENT])
202     			pEv = pAC->Event.EvQueue ;
203     
204     		/* Renew get: it is used in queue_events to detect overruns */
205     		pAC->Event.EvGet = pEv;
206     	}
207     
208     	return(0) ;
209     }
210     
211     /* End of file */
212