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
26 static const char ID_sccs[] = "@(#)queue.c 2.9 97/08/04 (C) SK " ;
32 * init event queue management
37 smc->q.ev_put = smc->q.ev_get = smc->q.ev_queue ;
43 void queue_event(smc,class,event)
48 PRINTF("queue class %d event %d\n",class,event) ;
49 smc->q.ev_put->class = class ;
50 smc->q.ev_put->event = event ;
51 if (++smc->q.ev_put == &smc->q.ev_queue[MAX_EVENT])
52 smc->q.ev_put = smc->q.ev_queue ;
54 if (smc->q.ev_put == smc->q.ev_get) {
55 SMT_ERR_LOG(smc,SMT_E0137, SMT_E0137_MSG) ;
60 * timer_event is called from HW timer package.
62 void timer_event(smc,token)
66 PRINTF("timer event class %d token %d\n",
69 queue_event(smc,EV_T_CLASS(token),EV_T_EVENT(token));
74 * while event queue is not empty
75 * get event from queue
76 * send command to state machine
79 void ev_dispatcher(smc)
82 struct event_queue *ev ; /* pointer into queue */
86 PRINTF("dispatch get %x put %x\n",ev,smc->q.ev_put) ;
87 while (ev != smc->q.ev_put) {
88 PRINTF("dispatch class %d event %d\n",ev->class,ev->event) ;
89 switch(class = ev->class) {
90 case EVENT_ECM : /* Entity Corordination Man. */
91 ecm(smc,(int)ev->event) ;
93 case EVENT_CFM : /* Configuration Man. */
94 cfm(smc,(int)ev->event) ;
96 case EVENT_RMT : /* Ring Man. */
97 rmt(smc,(int)ev->event) ;
100 smt_event(smc,(int)ev->event) ;
104 timer_test_event(smc,(int)ev->event) ;
107 case EVENT_PCMA : /* PHY A */
108 case EVENT_PCMB : /* PHY B */
110 if (class >= EVENT_PCMA &&
111 class < EVENT_PCMA + NUMPHYS) {
112 pcm(smc,class - EVENT_PCMA,(int)ev->event) ;
115 SMT_PANIC(smc,SMT_E0121, SMT_E0121_MSG) ;
119 if (++ev == &smc->q.ev_queue[MAX_EVENT])
120 ev = smc->q.ev_queue ;
122 /* Renew get: it is used in queue_events to detect overruns */
128 * smt_online connects to or disconnects from the ring
129 * MUST be called to initiate connection establishment
134 u_short smt_online(smc,on)
138 queue_event(smc,EVENT_ECM,on ? EC_CONNECT : EC_DISCONNECT) ;
140 return(smc->mib.fddiSMTCF_State) ;
144 * set SMT flag to value
147 * dump current flag setting
150 void do_smt_flag(smc,flag,value)
156 struct smt_debug *deb;
165 if (!strcmp(flag,"smt"))
167 else if (!strcmp(flag,"smtf"))
168 deb->d_smtf = value ;
169 else if (!strcmp(flag,"pcm"))
171 else if (!strcmp(flag,"rmt"))
173 else if (!strcmp(flag,"cfm"))
175 else if (!strcmp(flag,"ecm"))
177 printf("smt %d\n",deb->d_smt) ;
178 printf("smtf %d\n",deb->d_smtf) ;
179 printf("pcm %d\n",deb->d_pcm) ;
180 printf("rmt %d\n",deb->d_rmt) ;
181 printf("cfm %d\n",deb->d_cfm) ;
182 printf("ecm %d\n",deb->d_ecm) ;