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
34 void ev_init(struct s_smc
*smc
)
36 smc
->q
.ev_put
= smc
->q
.ev_get
= smc
->q
.ev_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",
63 queue_event(smc
,EV_T_CLASS(token
),EV_T_EVENT(token
));
68 * while event queue is not empty
69 * get event from queue
70 * send command to state machine
73 void ev_dispatcher(struct s_smc
*smc
)
75 struct event_queue
*ev
; /* pointer into queue */
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
) ;
86 case EVENT_CFM
: /* Configuration Man. */
87 cfm(smc
,(int)ev
->event
) ;
89 case EVENT_RMT
: /* Ring Man. */
90 rmt(smc
,(int)ev
->event
) ;
93 smt_event(smc
,(int)ev
->event
) ;
97 timer_test_event(smc
,(int)ev
->event
) ;
100 case EVENT_PCMA
: /* PHY A */
101 case EVENT_PCMB
: /* PHY B */
103 if (class >= EVENT_PCMA
&&
104 class < EVENT_PCMA
+ NUMPHYS
) {
105 pcm(smc
,class - EVENT_PCMA
,(int)ev
->event
) ;
108 SMT_PANIC(smc
,SMT_E0121
, SMT_E0121_MSG
) ;
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 */
121 * smt_online connects to or disconnects from the ring
122 * MUST be called to initiate connection establishment
127 u_short
smt_online(struct s_smc
*smc
, int on
)
129 queue_event(smc
,EVENT_ECM
,on
? EC_CONNECT
: EC_DISCONNECT
) ;
131 return(smc
->mib
.fddiSMTCF_State
) ;
135 * set SMT flag to value
138 * dump current flag setting
141 void do_smt_flag(struct s_smc
*smc
, char *flag
, int value
)
144 struct smt_debug
*deb
;
153 if (!strcmp(flag
,"smt"))
155 else if (!strcmp(flag
,"smtf"))
156 deb
->d_smtf
= value
;
157 else if (!strcmp(flag
,"pcm"))
159 else if (!strcmp(flag
,"rmt"))
161 else if (!strcmp(flag
,"cfm"))
163 else if (!strcmp(flag
,"ecm"))
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
) ;