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
24 * init event queue management
26 void ev_init(struct s_smc
*smc
)
28 smc
->q
.ev_put
= smc
->q
.ev_get
= smc
->q
.ev_queue
;
34 void queue_event(struct s_smc
*smc
, int class, int event
)
36 PRINTF("queue class %d event %d\n",class,event
) ;
37 smc
->q
.ev_put
->class = class ;
38 smc
->q
.ev_put
->event
= event
;
39 if (++smc
->q
.ev_put
== &smc
->q
.ev_queue
[MAX_EVENT
])
40 smc
->q
.ev_put
= smc
->q
.ev_queue
;
42 if (smc
->q
.ev_put
== smc
->q
.ev_get
) {
43 SMT_ERR_LOG(smc
,SMT_E0137
, SMT_E0137_MSG
) ;
48 * timer_event is called from HW timer package.
50 void timer_event(struct s_smc
*smc
, u_long token
)
52 PRINTF("timer event class %d token %d\n",
55 queue_event(smc
,EV_T_CLASS(token
),EV_T_EVENT(token
));
60 * while event queue is not empty
61 * get event from queue
62 * send command to state machine
65 void ev_dispatcher(struct s_smc
*smc
)
67 struct event_queue
*ev
; /* pointer into queue */
71 PRINTF("dispatch get %x put %x\n",ev
,smc
->q
.ev_put
) ;
72 while (ev
!= smc
->q
.ev_put
) {
73 PRINTF("dispatch class %d event %d\n",ev
->class,ev
->event
) ;
74 switch(class = ev
->class) {
75 case EVENT_ECM
: /* Entity Corordination Man. */
76 ecm(smc
,(int)ev
->event
) ;
78 case EVENT_CFM
: /* Configuration Man. */
79 cfm(smc
,(int)ev
->event
) ;
81 case EVENT_RMT
: /* Ring Man. */
82 rmt(smc
,(int)ev
->event
) ;
85 smt_event(smc
,(int)ev
->event
) ;
89 timer_test_event(smc
,(int)ev
->event
) ;
92 case EVENT_PCMA
: /* PHY A */
93 case EVENT_PCMB
: /* PHY B */
95 if (class >= EVENT_PCMA
&&
96 class < EVENT_PCMA
+ NUMPHYS
) {
97 pcm(smc
,class - EVENT_PCMA
,(int)ev
->event
) ;
100 SMT_PANIC(smc
,SMT_E0121
, SMT_E0121_MSG
) ;
104 if (++ev
== &smc
->q
.ev_queue
[MAX_EVENT
])
105 ev
= smc
->q
.ev_queue
;
107 /* Renew get: it is used in queue_events to detect overruns */
113 * smt_online connects to or disconnects from the ring
114 * MUST be called to initiate connection establishment
119 u_short
smt_online(struct s_smc
*smc
, int on
)
121 queue_event(smc
,EVENT_ECM
,on
? EC_CONNECT
: EC_DISCONNECT
) ;
123 return smc
->mib
.fddiSMTCF_State
;
127 * set SMT flag to value
130 * dump current flag setting
133 void do_smt_flag(struct s_smc
*smc
, char *flag
, int value
)
136 struct smt_debug
*deb
;
145 if (!strcmp(flag
,"smt"))
147 else if (!strcmp(flag
,"smtf"))
148 deb
->d_smtf
= value
;
149 else if (!strcmp(flag
,"pcm"))
151 else if (!strcmp(flag
,"rmt"))
153 else if (!strcmp(flag
,"cfm"))
155 else if (!strcmp(flag
,"ecm"))
157 printf("smt %d\n",deb
->d_smt
) ;
158 printf("smtf %d\n",deb
->d_smtf
) ;
159 printf("pcm %d\n",deb
->d_pcm
) ;
160 printf("rmt %d\n",deb
->d_rmt
) ;
161 printf("cfm %d\n",deb
->d_cfm
) ;
162 printf("ecm %d\n",deb
->d_ecm
) ;