1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#include "h/types.h"
22#include "h/fddi.h"
23#include "h/smc.h"
24
25#ifndef lint
26static const char ID_sccs[] = "@(#)queue.c 2.9 97/08/04 (C) SK " ;
27#endif
28
29#define PRINTF(a,b,c)
30
31
32
33
34void ev_init(struct s_smc *smc)
35{
36 smc->q.ev_put = smc->q.ev_get = smc->q.ev_queue ;
37}
38
39
40
41
42void queue_event(struct s_smc *smc, int class, int event)
43{
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 ;
49
50 if (smc->q.ev_put == smc->q.ev_get) {
51 SMT_ERR_LOG(smc,SMT_E0137, SMT_E0137_MSG) ;
52 }
53}
54
55
56
57
58void timer_event(struct s_smc *smc, u_long token)
59{
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));
64}
65
66
67
68
69
70
71
72
73void ev_dispatcher(struct s_smc *smc)
74{
75 struct event_queue *ev ;
76 int class ;
77
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 :
84 ecm(smc,(int)ev->event) ;
85 break ;
86 case EVENT_CFM :
87 cfm(smc,(int)ev->event) ;
88 break ;
89 case EVENT_RMT :
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 :
101 case EVENT_PCMB :
102 default :
103 if (class >= EVENT_PCMA &&
104 class < EVENT_PCMA + NUMPHYS) {
105 pcm(smc,class - EVENT_PCMA,(int)ev->event) ;
106 break ;
107 }
108 SMT_PANIC(smc,SMT_E0121, SMT_E0121_MSG) ;
109 return ;
110 }
111
112 if (++ev == &smc->q.ev_queue[MAX_EVENT])
113 ev = smc->q.ev_queue ;
114
115
116 smc->q.ev_get = ev;
117 }
118}
119
120
121
122
123
124
125
126
127u_short smt_online(struct s_smc *smc, int on)
128{
129 queue_event(smc,EVENT_ECM,on ? EC_CONNECT : EC_DISCONNECT) ;
130 ev_dispatcher(smc) ;
131 return smc->mib.fddiSMTCF_State;
132}
133
134
135
136
137
138
139
140#ifdef CONCENTRATOR
141void do_smt_flag(struct s_smc *smc, char *flag, int value)
142{
143#ifdef DEBUG
144 struct smt_debug *deb;
145
146 SK_UNUSED(smc) ;
147
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
172}
173#endif
174