File: /usr/src/linux/drivers/net/skfp/rmt.c

1     /******************************************************************************
2      *
3      *	(C)Copyright 1998,1999 SysKonnect,
4      *	a business unit of Schneider & Koch & Co. Datensysteme GmbH.
5      *
6      *	See the file "skfddi.c" for further information.
7      *
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.
12      *
13      *	The information in this file is provided "AS IS" without warranty.
14      *
15      ******************************************************************************/
16     
17     /*
18     	SMT RMT
19     	Ring Management
20     */
21     
22     /*
23      * Hardware independant state machine implemantation
24      * The following external SMT functions are referenced :
25      *
26      * 		queue_event()
27      * 		smt_timer_start()
28      * 		smt_timer_stop()
29      *
30      * 	The following external HW dependant functions are referenced :
31      *		sm_ma_control()
32      *		sm_mac_check_beacon_claim()
33      *
34      * 	The following HW dependant events are required :
35      *		RM_RING_OP
36      *		RM_RING_NON_OP
37      *		RM_MY_BEACON
38      *		RM_OTHER_BEACON
39      *		RM_MY_CLAIM
40      *		RM_TRT_EXP
41      *		RM_VALID_CLAIM
42      *
43      */
44     
45     #include "h/types.h"
46     #include "h/fddi.h"
47     #include "h/smc.h"
48     
49     #define KERNEL
50     #include "h/smtstate.h"
51     
52     #ifndef	lint
53     static const char ID_sccs[] = "@(#)rmt.c	2.13 99/07/02 (C) SK " ;
54     #endif
55     
56     /*
57      * FSM Macros
58      */
59     #define AFLAG	0x10
60     #define GO_STATE(x)	(smc->mib.m[MAC0].fddiMACRMTState = (x)|AFLAG)
61     #define ACTIONS_DONE()	(smc->mib.m[MAC0].fddiMACRMTState &= ~AFLAG)
62     #define ACTIONS(x)	(x|AFLAG)
63     
64     #define RM0_ISOLATED	0
65     #define RM1_NON_OP	1		/* not operational */
66     #define RM2_RING_OP	2		/* ring operational */
67     #define RM3_DETECT	3		/* detect dupl addresses */
68     #define RM4_NON_OP_DUP	4		/* dupl. addr detected */
69     #define RM5_RING_OP_DUP	5		/* ring oper. with dupl. addr */
70     #define RM6_DIRECTED	6		/* sending directed beacons */
71     #define RM7_TRACE	7		/* trace initiated */
72     
73     #ifdef	DEBUG
74     /*
75      * symbolic state names
76      */
77     static const char * const rmt_states[] = {
78     	"RM0_ISOLATED","RM1_NON_OP","RM2_RING_OP","RM3_DETECT",
79     	"RM4_NON_OP_DUP","RM5_RING_OP_DUP","RM6_DIRECTED",
80     	"RM7_TRACE"
81     } ;
82     
83     /*
84      * symbolic event names
85      */
86     static const char * const rmt_events[] = {
87     	"NONE","RM_RING_OP","RM_RING_NON_OP","RM_MY_BEACON",
88     	"RM_OTHER_BEACON","RM_MY_CLAIM","RM_TRT_EXP","RM_VALID_CLAIM",
89     	"RM_JOIN","RM_LOOP","RM_DUP_ADDR","RM_ENABLE_FLAG",
90     	"RM_TIMEOUT_NON_OP","RM_TIMEOUT_T_STUCK",
91     	"RM_TIMEOUT_ANNOUNCE","RM_TIMEOUT_T_DIRECT",
92     	"RM_TIMEOUT_D_MAX","RM_TIMEOUT_POLL","RM_TX_STATE_CHANGE"
93     } ;
94     #endif
95     
96     /*
97      * Globals
98      * in struct s_rmt
99      */
100     
101     
102     /*
103      * function declarations
104      */
105     static void rmt_fsm() ;
106     static void start_rmt_timer0() ;
107     static void start_rmt_timer1() ;
108     static void start_rmt_timer2() ;
109     static void stop_rmt_timer0() ;
110     static void stop_rmt_timer1() ;
111     static void stop_rmt_timer2() ;
112     static void rmt_dup_actions() ;
113     static void rmt_reinsert_actions() ;
114     static void rmt_leave_actions() ;
115     static void rmt_new_dup_actions() ;
116     
117     #ifndef SUPERNET_3
118     extern void restart_trt_for_dbcn() ;
119     #endif /*SUPERNET_3*/
120     
121     /*
122     	init RMT state machine
123     	clear all RMT vars and flags
124     */
125     void rmt_init(smc)
126     struct s_smc *smc ;
127     {
128     	smc->mib.m[MAC0].fddiMACRMTState = ACTIONS(RM0_ISOLATED) ;
129     	smc->r.dup_addr_test = DA_NONE ;
130     	smc->r.da_flag = 0 ;
131     	smc->mib.m[MAC0].fddiMACMA_UnitdataAvailable = FALSE ;
132     	smc->r.sm_ma_avail = FALSE ;
133     	smc->r.loop_avail = 0 ;
134     	smc->r.bn_flag = 0 ;
135     	smc->r.jm_flag = 0 ;
136     	smc->r.no_flag = TRUE ;
137     }
138     
139     /*
140     	RMT state machine
141     	called by dispatcher
142     
143     	do
144     		display state change
145     		process event
146     	until SM is stable
147     */
148     void rmt(smc,event)
149     struct s_smc *smc ;
150     int event ;
151     {
152     	int	state ;
153     
154     	do {
155     		DB_RMT("RMT : state %s%s",
156     			(smc->mib.m[MAC0].fddiMACRMTState & AFLAG) ? "ACTIONS " : "",
157     			rmt_states[smc->mib.m[MAC0].fddiMACRMTState & ~AFLAG]) ;
158     		DB_RMT(" event %s\n",rmt_events[event],0) ;
159     		state = smc->mib.m[MAC0].fddiMACRMTState ;
160     		rmt_fsm(smc,event) ;
161     		event = 0 ;
162     	} while (state != smc->mib.m[MAC0].fddiMACRMTState) ;
163     	rmt_state_change(smc,(int)smc->mib.m[MAC0].fddiMACRMTState) ;
164     }
165     
166     /*
167     	process RMT event
168     */
169     static void rmt_fsm(smc,cmd)
170     struct s_smc *smc ;
171     int cmd ;
172     {
173     	/*
174     	 * RM00-RM70 : from all states
175     	 */
176     	if (!smc->r.rm_join && !smc->r.rm_loop &&
177     		smc->mib.m[MAC0].fddiMACRMTState != ACTIONS(RM0_ISOLATED) &&
178     		smc->mib.m[MAC0].fddiMACRMTState != RM0_ISOLATED) {
179     		RS_SET(smc,RS_NORINGOP) ;
180     		rmt_indication(smc,0) ;
181     		GO_STATE(RM0_ISOLATED) ;
182     		return ;
183     	}
184     
185     	switch(smc->mib.m[MAC0].fddiMACRMTState) {
186     	case ACTIONS(RM0_ISOLATED) :
187     		stop_rmt_timer0(smc) ;
188     		stop_rmt_timer1(smc) ;
189     		stop_rmt_timer2(smc) ;
190     
191     		/*
192     		 * Disable MAC.
193     		 */
194     		sm_ma_control(smc,MA_OFFLINE) ;
195     		smc->mib.m[MAC0].fddiMACMA_UnitdataAvailable = FALSE ;
196     		smc->r.loop_avail = FALSE ;
197     		smc->r.sm_ma_avail = FALSE ;
198     		smc->r.no_flag = TRUE ;
199     		DB_RMTN(1,"RMT : ISOLATED\n",0,0) ;
200     		ACTIONS_DONE() ;
201     		break ;
202     	case RM0_ISOLATED :
203     		/*RM01*/
204     		if (smc->r.rm_join || smc->r.rm_loop) {
205     			/*
206     			 * According to the standard the MAC must be reset
207     			 * here. The FORMAC will be initialized and Claim
208     			 * and Beacon Frames will be uploaded to the MAC.
209     			 * So any change of Treq will take effect NOW.
210     			 */
211     			sm_ma_control(smc,MA_RESET) ;
212     			GO_STATE(RM1_NON_OP) ;
213     			break ;
214     		}
215     		break ;
216     	case ACTIONS(RM1_NON_OP) :
217     		start_rmt_timer0(smc,smc->s.rmt_t_non_op,RM_TIMEOUT_NON_OP) ;
218     		stop_rmt_timer1(smc) ;
219     		stop_rmt_timer2(smc) ;
220     		sm_ma_control(smc,MA_BEACON) ;
221     		DB_RMTN(1,"RMT : RING DOWN\n",0,0) ;
222     		RS_SET(smc,RS_NORINGOP) ;
223     		smc->r.sm_ma_avail = FALSE ;
224     		rmt_indication(smc,0) ;
225     		ACTIONS_DONE() ;
226     		break ;
227     	case RM1_NON_OP :
228     		/*RM12*/
229     		if (cmd == RM_RING_OP) {
230     			RS_SET(smc,RS_RINGOPCHANGE) ;
231     			GO_STATE(RM2_RING_OP) ;
232     			break ;
233     		}
234     		/*RM13*/
235     		else if (cmd == RM_TIMEOUT_NON_OP) {
236     			smc->r.bn_flag = FALSE ;
237     			smc->r.no_flag = TRUE ;
238     			GO_STATE(RM3_DETECT) ;
239     			break ;
240     		}
241     		break ;
242     	case ACTIONS(RM2_RING_OP) :
243     		stop_rmt_timer0(smc) ;
244     		stop_rmt_timer1(smc) ;
245     		stop_rmt_timer2(smc) ;
246     		smc->r.no_flag = FALSE ;
247     		if (smc->r.rm_loop)
248     			smc->r.loop_avail = TRUE ;
249     		if (smc->r.rm_join) {
250     			smc->r.sm_ma_avail = TRUE ;
251     			if (smc->mib.m[MAC0].fddiMACMA_UnitdataEnable)
252     			smc->mib.m[MAC0].fddiMACMA_UnitdataAvailable = TRUE ;
253     				else
254     			smc->mib.m[MAC0].fddiMACMA_UnitdataAvailable = FALSE ;
255     		}
256     		DB_RMTN(1,"RMT : RING UP\n",0,0) ;
257     		RS_CLEAR(smc,RS_NORINGOP) ;
258     		RS_SET(smc,RS_RINGOPCHANGE) ;
259     		rmt_indication(smc,1) ;
260     		smt_stat_counter(smc,0) ;
261     		ACTIONS_DONE() ;
262     		break ;
263     	case RM2_RING_OP :
264     		/*RM21*/
265     		if (cmd == RM_RING_NON_OP) {
266     			smc->mib.m[MAC0].fddiMACMA_UnitdataAvailable = FALSE ;
267     			smc->r.loop_avail = FALSE ;
268     			RS_SET(smc,RS_RINGOPCHANGE) ;
269     			GO_STATE(RM1_NON_OP) ;
270     			break ;
271     		}
272     		/*RM22a*/
273     		else if (cmd == RM_ENABLE_FLAG) {
274     			if (smc->mib.m[MAC0].fddiMACMA_UnitdataEnable)
275     			smc->mib.m[MAC0].fddiMACMA_UnitdataAvailable = TRUE ;
276     				else
277     			smc->mib.m[MAC0].fddiMACMA_UnitdataAvailable = FALSE ;
278     		}
279     		/*RM25*/
280     		else if (smc->r.dup_addr_test == DA_FAILED) {
281     			smc->mib.m[MAC0].fddiMACMA_UnitdataAvailable = FALSE ;
282     			smc->r.loop_avail = FALSE ;
283     			smc->r.da_flag = TRUE ;
284     			GO_STATE(RM5_RING_OP_DUP) ;
285     			break ;
286     		}
287     		break ;
288     	case ACTIONS(RM3_DETECT) :
289     		start_rmt_timer0(smc,smc->s.mac_d_max*2,RM_TIMEOUT_D_MAX) ;
290     		start_rmt_timer1(smc,smc->s.rmt_t_stuck,RM_TIMEOUT_T_STUCK) ;
291     		start_rmt_timer2(smc,smc->s.rmt_t_poll,RM_TIMEOUT_POLL) ;
292     		sm_mac_check_beacon_claim(smc) ;
293     		DB_RMTN(1,"RMT : RM3_DETECT\n",0,0) ;
294     		ACTIONS_DONE() ;
295     		break ;
296     	case RM3_DETECT :
297     		if (cmd == RM_TIMEOUT_POLL) {
298     			start_rmt_timer2(smc,smc->s.rmt_t_poll,RM_TIMEOUT_POLL);
299     			sm_mac_check_beacon_claim(smc) ;
300     			break ;
301     		}
302     		if (cmd == RM_TIMEOUT_D_MAX) {
303     			smc->r.timer0_exp = TRUE ;
304     		}
305     		/*
306     		 *jd(22-Feb-1999)
307     		 * We need a time ">= 2*mac_d_max" since we had finished
308     		 * Claim or Beacon state. So we will restart timer0 at
309     		 * every state change.
310     		 */
311     		if (cmd == RM_TX_STATE_CHANGE) {
312     			start_rmt_timer0(smc,
313     					 smc->s.mac_d_max*2,
314     					 RM_TIMEOUT_D_MAX) ;
315     		}
316     		/*RM32*/
317     		if (cmd == RM_RING_OP) {
318     			GO_STATE(RM2_RING_OP) ;
319     			break ;
320     		}
321     		/*RM33a*/
322     		else if ((cmd == RM_MY_BEACON || cmd == RM_OTHER_BEACON)
323     			&& smc->r.bn_flag) {
324     			smc->r.bn_flag = FALSE ;
325     		}
326     		/*RM33b*/
327     		else if (cmd == RM_TRT_EXP && !smc->r.bn_flag) {
328     			int	tx ;
329     			/*
330     			 * set bn_flag only if in state T4 or T5:
331     			 * only if we're the beaconer should we start the
332     			 * trace !
333     			 */
334     			if ((tx =  sm_mac_get_tx_state(smc)) == 4 || tx == 5) {
335     			DB_RMTN(2,"RMT : DETECT && TRT_EXPIRED && T4/T5\n",0,0);
336     				smc->r.bn_flag = TRUE ;
337     				/*
338     				 * If one of the upstream stations beaconed
339     				 * and the link to the upstream neighbor is
340     				 * lost we need to restart the stuck timer to
341     				 * check the "stuck beacon" condition.
342     				 */
343     				start_rmt_timer1(smc,smc->s.rmt_t_stuck,
344     					RM_TIMEOUT_T_STUCK) ;
345     			}
346     			/*
347     			 * We do NOT need to clear smc->r.bn_flag in case of
348     			 * not being in state T4 or T5, because the flag
349     			 * must be cleared in order to get in this condition.
350     			 */
351     
352     			DB_RMTN(2,
353     			"RMT : sm_mac_get_tx_state() = %d (bn_flag = %d)\n",
354     			tx,smc->r.bn_flag) ;
355     		}
356     		/*RM34a*/
357     		else if (cmd == RM_MY_CLAIM && smc->r.timer0_exp) {
358     			rmt_new_dup_actions(smc) ;
359     			GO_STATE(RM4_NON_OP_DUP) ;
360     			break ;
361     		}
362     		/*RM34b*/
363     		else if (cmd == RM_MY_BEACON && smc->r.timer0_exp) {
364     			rmt_new_dup_actions(smc) ;
365     			GO_STATE(RM4_NON_OP_DUP) ;
366     			break ;
367     		}
368     		/*RM34c*/
369     		else if (cmd == RM_VALID_CLAIM) {
370     			rmt_new_dup_actions(smc) ;
371     			GO_STATE(RM4_NON_OP_DUP) ;
372     			break ;
373     		}
374     		/*RM36*/
375     		else if (cmd == RM_TIMEOUT_T_STUCK &&
376     			smc->r.rm_join && smc->r.bn_flag) {
377     			GO_STATE(RM6_DIRECTED) ;
378     			break ;
379     		}
380     		break ;
381     	case ACTIONS(RM4_NON_OP_DUP) :
382     		start_rmt_timer0(smc,smc->s.rmt_t_announce,RM_TIMEOUT_ANNOUNCE);
383     		start_rmt_timer1(smc,smc->s.rmt_t_stuck,RM_TIMEOUT_T_STUCK) ;
384     		start_rmt_timer2(smc,smc->s.rmt_t_poll,RM_TIMEOUT_POLL) ;
385     		sm_mac_check_beacon_claim(smc) ;
386     		DB_RMTN(1,"RMT : RM4_NON_OP_DUP\n",0,0) ;
387     		ACTIONS_DONE() ;
388     		break ;
389     	case RM4_NON_OP_DUP :
390     		if (cmd == RM_TIMEOUT_POLL) {
391     			start_rmt_timer2(smc,smc->s.rmt_t_poll,RM_TIMEOUT_POLL);
392     			sm_mac_check_beacon_claim(smc) ;
393     			break ;
394     		}
395     		/*RM41*/
396     		if (!smc->r.da_flag) {
397     			GO_STATE(RM1_NON_OP) ;
398     			break ;
399     		}
400     		/*RM44a*/
401     		else if ((cmd == RM_MY_BEACON || cmd == RM_OTHER_BEACON) &&
402     			smc->r.bn_flag) {
403     			smc->r.bn_flag = FALSE ;
404     		}
405     		/*RM44b*/
406     		else if (cmd == RM_TRT_EXP && !smc->r.bn_flag) {
407     			int	tx ;
408     			/*
409     			 * set bn_flag only if in state T4 or T5:
410     			 * only if we're the beaconer should we start the
411     			 * trace !
412     			 */
413     			if ((tx =  sm_mac_get_tx_state(smc)) == 4 || tx == 5) {
414     			DB_RMTN(2,"RMT : NOPDUP && TRT_EXPIRED && T4/T5\n",0,0);
415     				smc->r.bn_flag = TRUE ;
416     				/*
417     				 * If one of the upstream stations beaconed
418     				 * and the link to the upstream neighbor is
419     				 * lost we need to restart the stuck timer to
420     				 * check the "stuck beacon" condition.
421     				 */
422     				start_rmt_timer1(smc,smc->s.rmt_t_stuck,
423     					RM_TIMEOUT_T_STUCK) ;
424     			}
425     			/*
426     			 * We do NOT need to clear smc->r.bn_flag in case of
427     			 * not being in state T4 or T5, because the flag
428     			 * must be cleared in order to get in this condition.
429     			 */
430     
431     			DB_RMTN(2,
432     			"RMT : sm_mac_get_tx_state() = %d (bn_flag = %d)\n",
433     			tx,smc->r.bn_flag) ;
434     		}
435     		/*RM44c*/
436     		else if (cmd == RM_TIMEOUT_ANNOUNCE && !smc->r.bn_flag) {
437     			rmt_dup_actions(smc) ;
438     		}
439     		/*RM45*/
440     		else if (cmd == RM_RING_OP) {
441     			smc->r.no_flag = FALSE ;
442     			GO_STATE(RM5_RING_OP_DUP) ;
443     			break ;
444     		}
445     		/*RM46*/
446     		else if (cmd == RM_TIMEOUT_T_STUCK &&
447     			smc->r.rm_join && smc->r.bn_flag) {
448     			GO_STATE(RM6_DIRECTED) ;
449     			break ;
450     		}
451     		break ;
452     	case ACTIONS(RM5_RING_OP_DUP) :
453     		stop_rmt_timer0(smc) ;
454     		stop_rmt_timer1(smc) ;
455     		stop_rmt_timer2(smc) ;
456     		DB_RMTN(1,"RMT : RM5_RING_OP_DUP\n",0,0) ;
457     		ACTIONS_DONE() ;
458     		break;
459     	case RM5_RING_OP_DUP :
460     		/*RM52*/
461     		if (smc->r.dup_addr_test == DA_PASSED) {
462     			smc->r.da_flag = FALSE ;
463     			GO_STATE(RM2_RING_OP) ;
464     			break ;
465     		}
466     		/*RM54*/
467     		else if (cmd == RM_RING_NON_OP) {
468     			smc->r.jm_flag = FALSE ;
469     			smc->r.bn_flag = FALSE ;
470     			GO_STATE(RM4_NON_OP_DUP) ;
471     			break ;
472     		}
473     		break ;
474     	case ACTIONS(RM6_DIRECTED) :
475     		start_rmt_timer0(smc,smc->s.rmt_t_direct,RM_TIMEOUT_T_DIRECT) ;
476     		stop_rmt_timer1(smc) ;
477     		start_rmt_timer2(smc,smc->s.rmt_t_poll,RM_TIMEOUT_POLL) ;
478     		sm_ma_control(smc,MA_DIRECTED) ;
479     		RS_SET(smc,RS_BEACON) ;
480     		DB_RMTN(1,"RMT : RM6_DIRECTED\n",0,0) ;
481     		ACTIONS_DONE() ;
482     		break ;
483     	case RM6_DIRECTED :
484     		/*RM63*/
485     		if (cmd == RM_TIMEOUT_POLL) {
486     			start_rmt_timer2(smc,smc->s.rmt_t_poll,RM_TIMEOUT_POLL);
487     			sm_mac_check_beacon_claim(smc) ;
488     #ifndef SUPERNET_3
489     			/* Because of problems with the Supernet II chip set
490     			 * sending of Directed Beacon will stop after 165ms
491     			 * therefore restart_trt_for_dbcn(smc) will be called
492     			 * to prevent this.
493     			 */
494     			restart_trt_for_dbcn(smc) ;
495     #endif /*SUPERNET_3*/
496     			break ;
497     		}
498     		if ((cmd == RM_MY_BEACON || cmd == RM_OTHER_BEACON) &&
499     			!smc->r.da_flag) {
500     			smc->r.bn_flag = FALSE ;
501     			GO_STATE(RM3_DETECT) ;
502     			break ;
503     		}
504     		/*RM64*/
505     		else if ((cmd == RM_MY_BEACON || cmd == RM_OTHER_BEACON) &&
506     			smc->r.da_flag) {
507     			smc->r.bn_flag = FALSE ;
508     			GO_STATE(RM4_NON_OP_DUP) ;
509     			break ;
510     		}
511     		/*RM67*/
512     		else if (cmd == RM_TIMEOUT_T_DIRECT) {
513     			GO_STATE(RM7_TRACE) ;
514     			break ;
515     		}
516     		break ;
517     	case ACTIONS(RM7_TRACE) :
518     		stop_rmt_timer0(smc) ;
519     		stop_rmt_timer1(smc) ;
520     		stop_rmt_timer2(smc) ;
521     		smc->e.trace_prop |= ENTITY_BIT(ENTITY_MAC) ;
522     		queue_event(smc,EVENT_ECM,EC_TRACE_PROP) ;
523     		DB_RMTN(1,"RMT : RM7_TRACE\n",0,0) ;
524     		ACTIONS_DONE() ;
525     		break ;
526     	case RM7_TRACE :
527     		break ;
528     	default:
529     		SMT_PANIC(smc,SMT_E0122, SMT_E0122_MSG) ;
530     		break;
531     	}
532     }
533     
534     /*
535      * (jd) RMT duplicate address actions
536      * leave the ring or reinsert just as configured
537      */
538     static void rmt_dup_actions(smc)
539     struct s_smc *smc ;
540     {
541     	if (smc->r.jm_flag) {
542     	}
543     	else {
544     		if (smc->s.rmt_dup_mac_behavior) {
545     			SMT_ERR_LOG(smc,SMT_E0138, SMT_E0138_MSG) ;
546                             rmt_reinsert_actions(smc) ;
547     		}
548     		else {
549     			SMT_ERR_LOG(smc,SMT_E0135, SMT_E0135_MSG) ;
550     			rmt_leave_actions(smc) ;
551     		}
552     	}
553     }
554     
555     /*
556      * Reconnect to the Ring
557      */
558     static void rmt_reinsert_actions(smc)
559     struct s_smc *smc ;
560     {
561     	queue_event(smc,EVENT_ECM,EC_DISCONNECT) ;
562     	queue_event(smc,EVENT_ECM,EC_CONNECT) ;
563     }
564     
565     /*
566      * duplicate address detected
567      */
568     static void rmt_new_dup_actions(smc)
569     struct s_smc *smc ;
570     {
571     	smc->r.da_flag = TRUE ;
572     	smc->r.bn_flag = FALSE ;
573     	smc->r.jm_flag = FALSE ;
574     	/*
575     	 * we have three options : change address, jam or leave
576     	 * we leave the ring as default 
577     	 * Optionally it's possible to reinsert after leaving the Ring
578     	 * but this will not conform with SMT Spec.
579     	 */
580     	if (smc->s.rmt_dup_mac_behavior) {
581     		SMT_ERR_LOG(smc,SMT_E0138, SMT_E0138_MSG) ;
582     		rmt_reinsert_actions(smc) ;
583     	}
584     	else {
585     		SMT_ERR_LOG(smc,SMT_E0135, SMT_E0135_MSG) ;
586     		rmt_leave_actions(smc) ;
587     	}
588     }
589     
590     
591     /*
592      * leave the ring
593      */
594     static void rmt_leave_actions(smc)
595     struct s_smc *smc ;
596     {
597     	queue_event(smc,EVENT_ECM,EC_DISCONNECT) ;
598     	/*
599     	 * Note: Do NOT try again later. (with please reconnect)
600     	 * The station must be left from the ring!
601     	 */
602     }
603     
604     /*
605      * SMT timer interface
606      *	start RMT timer 0
607      */
608     static void start_rmt_timer0(smc,value,event)
609     struct s_smc *smc ;
610     u_long value ;
611     int event ;
612     {
613     	smc->r.timer0_exp = FALSE ;		/* clear timer event flag */
614     	smt_timer_start(smc,&smc->r.rmt_timer0,value,EV_TOKEN(EVENT_RMT,event));
615     }
616     
617     /*
618      * SMT timer interface
619      *	start RMT timer 1
620      */
621     static void start_rmt_timer1(smc,value,event)
622     struct s_smc *smc ;
623     u_long value ;
624     int event ;
625     {
626     	smc->r.timer1_exp = FALSE ;	/* clear timer event flag */
627     	smt_timer_start(smc,&smc->r.rmt_timer1,value,EV_TOKEN(EVENT_RMT,event));
628     }
629     
630     /*
631      * SMT timer interface
632      *	start RMT timer 2
633      */
634     static void start_rmt_timer2(smc,value,event)
635     struct s_smc *smc ;
636     u_long value ;
637     int event ;
638     {
639     	smc->r.timer2_exp = FALSE ;		/* clear timer event flag */
640     	smt_timer_start(smc,&smc->r.rmt_timer2,value,EV_TOKEN(EVENT_RMT,event));
641     }
642     
643     /*
644      * SMT timer interface
645      *	stop RMT timer 0
646      */
647     static void stop_rmt_timer0(smc)
648     struct s_smc *smc ;
649     {
650     	if (smc->r.rmt_timer0.tm_active)
651     		smt_timer_stop(smc,&smc->r.rmt_timer0) ;
652     }
653     
654     /*
655      * SMT timer interface
656      *	stop RMT timer 1
657      */
658     static void stop_rmt_timer1(smc)
659     struct s_smc *smc ;
660     {
661     	if (smc->r.rmt_timer1.tm_active)
662     		smt_timer_stop(smc,&smc->r.rmt_timer1) ;
663     }
664     
665     /*
666      * SMT timer interface
667      *	stop RMT timer 2
668      */
669     static void stop_rmt_timer2(smc)
670     struct s_smc *smc ;
671     {
672     	if (smc->r.rmt_timer2.tm_active)
673     		smt_timer_stop(smc,&smc->r.rmt_timer2) ;
674     }
675