mmc: sdhci-of-esdhc: use of_property_read_bool
[linux/fpc-iii.git] / drivers / net / fddi / skfp / queue.c
blobc1a0df455a5958089bc4bae4c6dcfe8b9539042b
1 /******************************************************************************
3 * (C)Copyright 1998,1999 SysKonnect,
4 * a business unit of Schneider & Koch & Co. Datensysteme GmbH.
6 * See the file "skfddi.c" for further information.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * The information in this file is provided "AS IS" without warranty.
15 ******************************************************************************/
18 SMT Event Queue Management
21 #include "h/types.h"
22 #include "h/fddi.h"
23 #include "h/smc.h"
25 #ifndef lint
26 static const char ID_sccs[] = "@(#)queue.c 2.9 97/08/04 (C) SK " ;
27 #endif
29 #define PRINTF(a,b,c)
32 * init event queue management
34 void ev_init(struct s_smc *smc)
36 smc->q.ev_put = smc->q.ev_get = smc->q.ev_queue ;
40 * add event to queue
42 void queue_event(struct s_smc *smc, int class, int event)
44 PRINTF("queue class %d event %d\n",class,event) ;
45 smc->q.ev_put->class = class ;
46 smc->q.ev_put->event = event ;
47 if (++smc->q.ev_put == &smc->q.ev_queue[MAX_EVENT])
48 smc->q.ev_put = smc->q.ev_queue ;
50 if (smc->q.ev_put == smc->q.ev_get) {
51 SMT_ERR_LOG(smc,SMT_E0137, SMT_E0137_MSG) ;
56 * timer_event is called from HW timer package.
58 void timer_event(struct s_smc *smc, u_long token)
60 PRINTF("timer event class %d token %d\n",
61 EV_T_CLASS(token),
62 EV_T_EVENT(token)) ;
63 queue_event(smc,EV_T_CLASS(token),EV_T_EVENT(token));
67 * event dispatcher
68 * while event queue is not empty
69 * get event from queue
70 * send command to state machine
71 * end
73 void ev_dispatcher(struct s_smc *smc)
75 struct event_queue *ev ; /* pointer into queue */
76 int class ;
78 ev = smc->q.ev_get ;
79 PRINTF("dispatch get %x put %x\n",ev,smc->q.ev_put) ;
80 while (ev != smc->q.ev_put) {
81 PRINTF("dispatch class %d event %d\n",ev->class,ev->event) ;
82 switch(class = ev->class) {
83 case EVENT_ECM : /* Entity Corordination Man. */
84 ecm(smc,(int)ev->event) ;
85 break ;
86 case EVENT_CFM : /* Configuration Man. */
87 cfm(smc,(int)ev->event) ;
88 break ;
89 case EVENT_RMT : /* Ring Man. */
90 rmt(smc,(int)ev->event) ;
91 break ;
92 case EVENT_SMT :
93 smt_event(smc,(int)ev->event) ;
94 break ;
95 #ifdef CONCENTRATOR
96 case 99 :
97 timer_test_event(smc,(int)ev->event) ;
98 break ;
99 #endif
100 case EVENT_PCMA : /* PHY A */
101 case EVENT_PCMB : /* PHY B */
102 default :
103 if (class >= EVENT_PCMA &&
104 class < EVENT_PCMA + NUMPHYS) {
105 pcm(smc,class - EVENT_PCMA,(int)ev->event) ;
106 break ;
108 SMT_PANIC(smc,SMT_E0121, SMT_E0121_MSG) ;
109 return ;
112 if (++ev == &smc->q.ev_queue[MAX_EVENT])
113 ev = smc->q.ev_queue ;
115 /* Renew get: it is used in queue_events to detect overruns */
116 smc->q.ev_get = ev;
121 * smt_online connects to or disconnects from the ring
122 * MUST be called to initiate connection establishment
124 * on 0 disconnect
125 * on 1 connect
127 u_short smt_online(struct s_smc *smc, int on)
129 queue_event(smc,EVENT_ECM,on ? EC_CONNECT : EC_DISCONNECT) ;
130 ev_dispatcher(smc) ;
131 return smc->mib.fddiSMTCF_State;
135 * set SMT flag to value
136 * flag flag name
137 * value flag value
138 * dump current flag setting
140 #ifdef CONCENTRATOR
141 void do_smt_flag(struct s_smc *smc, char *flag, int value)
143 #ifdef DEBUG
144 struct smt_debug *deb;
146 SK_UNUSED(smc) ;
148 #ifdef DEBUG_BRD
149 deb = &smc->debug;
150 #else
151 deb = &debug;
152 #endif
153 if (!strcmp(flag,"smt"))
154 deb->d_smt = value ;
155 else if (!strcmp(flag,"smtf"))
156 deb->d_smtf = value ;
157 else if (!strcmp(flag,"pcm"))
158 deb->d_pcm = value ;
159 else if (!strcmp(flag,"rmt"))
160 deb->d_rmt = value ;
161 else if (!strcmp(flag,"cfm"))
162 deb->d_cfm = value ;
163 else if (!strcmp(flag,"ecm"))
164 deb->d_ecm = value ;
165 printf("smt %d\n",deb->d_smt) ;
166 printf("smtf %d\n",deb->d_smtf) ;
167 printf("pcm %d\n",deb->d_pcm) ;
168 printf("rmt %d\n",deb->d_rmt) ;
169 printf("cfm %d\n",deb->d_cfm) ;
170 printf("ecm %d\n",deb->d_ecm) ;
171 #endif /* DEBUG */
173 #endif