1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /******************************************************************************
4 * (C)Copyright 1998,1999 SysKonnect,
5 * a business unit of Schneider & Koch & Co. Datensysteme GmbH.
7 * See the file "skfddi.c" for further information.
9 * The information in this file is provided "AS IS" without warranty.
11 ******************************************************************************/
14 SMT Event Queue Management
22 static const char ID_sccs[] = "@(#)queue.c 2.9 97/08/04 (C) SK " ;
28 * init event queue management
30 void ev_init(struct s_smc *smc)
32 smc->q.ev_put = smc->q.ev_get = smc->q.ev_queue ;
38 void queue_event(struct s_smc *smc, int class, int event)
40 PRINTF("queue class %d event %d\n",class,event) ;
41 smc->q.ev_put->class = class ;
42 smc->q.ev_put->event = event ;
43 if (++smc->q.ev_put == &smc->q.ev_queue[MAX_EVENT])
44 smc->q.ev_put = smc->q.ev_queue ;
46 if (smc->q.ev_put == smc->q.ev_get) {
47 SMT_ERR_LOG(smc,SMT_E0137, SMT_E0137_MSG) ;
52 * timer_event is called from HW timer package.
54 void timer_event(struct s_smc *smc, u_long token)
56 PRINTF("timer event class %d token %d\n",
59 queue_event(smc,EV_T_CLASS(token),EV_T_EVENT(token));
64 * while event queue is not empty
65 * get event from queue
66 * send command to state machine
69 void ev_dispatcher(struct s_smc *smc)
71 struct event_queue *ev ; /* pointer into queue */
75 PRINTF("dispatch get %x put %x\n",ev,smc->q.ev_put) ;
76 while (ev != smc->q.ev_put) {
77 PRINTF("dispatch class %d event %d\n",ev->class,ev->event) ;
78 switch(class = ev->class) {
79 case EVENT_ECM : /* Entity Corordination Man. */
80 ecm(smc,(int)ev->event) ;
82 case EVENT_CFM : /* Configuration Man. */
83 cfm(smc,(int)ev->event) ;
85 case EVENT_RMT : /* Ring Man. */
86 rmt(smc,(int)ev->event) ;
89 smt_event(smc,(int)ev->event) ;
93 timer_test_event(smc,(int)ev->event) ;
96 case EVENT_PCMA : /* PHY A */
97 case EVENT_PCMB : /* PHY B */
99 if (class >= EVENT_PCMA &&
100 class < EVENT_PCMA + NUMPHYS) {
101 pcm(smc,class - EVENT_PCMA,(int)ev->event) ;
104 SMT_PANIC(smc,SMT_E0121, SMT_E0121_MSG) ;
108 if (++ev == &smc->q.ev_queue[MAX_EVENT])
109 ev = smc->q.ev_queue ;
111 /* Renew get: it is used in queue_events to detect overruns */
117 * smt_online connects to or disconnects from the ring
118 * MUST be called to initiate connection establishment
123 u_short smt_online(struct s_smc *smc, int on)
125 queue_event(smc,EVENT_ECM,on ? EC_CONNECT : EC_DISCONNECT) ;
127 return smc->mib.fddiSMTCF_State;
131 * set SMT flag to value
134 * dump current flag setting
137 void do_smt_flag(struct s_smc *smc, char *flag, int value)
140 struct smt_debug *deb;
149 if (!strcmp(flag,"smt"))
151 else if (!strcmp(flag,"smtf"))
152 deb->d_smtf = value ;
153 else if (!strcmp(flag,"pcm"))
155 else if (!strcmp(flag,"rmt"))
157 else if (!strcmp(flag,"cfm"))
159 else if (!strcmp(flag,"ecm"))
161 printf("smt %d\n",deb->d_smt) ;
162 printf("smtf %d\n",deb->d_smtf) ;
163 printf("pcm %d\n",deb->d_pcm) ;
164 printf("rmt %d\n",deb->d_rmt) ;
165 printf("cfm %d\n",deb->d_cfm) ;
166 printf("ecm %d\n",deb->d_ecm) ;