Back to home page

LXR

 
 

    


0001 /******************************************************************************
0002  *
0003  *  (C)Copyright 1998,1999 SysKonnect,
0004  *  a business unit of Schneider & Koch & Co. Datensysteme GmbH.
0005  *
0006  *  See the file "skfddi.c" for further information.
0007  *
0008  *  This program is free software; you can redistribute it and/or modify
0009  *  it under the terms of the GNU General Public License as published by
0010  *  the Free Software Foundation; either version 2 of the License, or
0011  *  (at your option) any later version.
0012  *
0013  *  The information in this file is provided "AS IS" without warranty.
0014  *
0015  ******************************************************************************/
0016 
0017 /*
0018     SMT RMT
0019     Ring Management
0020 */
0021 
0022 /*
0023  * Hardware independent state machine implemantation
0024  * The following external SMT functions are referenced :
0025  *
0026  *      queue_event()
0027  *      smt_timer_start()
0028  *      smt_timer_stop()
0029  *
0030  *  The following external HW dependent functions are referenced :
0031  *      sm_ma_control()
0032  *      sm_mac_check_beacon_claim()
0033  *
0034  *  The following HW dependent events are required :
0035  *      RM_RING_OP
0036  *      RM_RING_NON_OP
0037  *      RM_MY_BEACON
0038  *      RM_OTHER_BEACON
0039  *      RM_MY_CLAIM
0040  *      RM_TRT_EXP
0041  *      RM_VALID_CLAIM
0042  *
0043  */
0044 
0045 #include "h/types.h"
0046 #include "h/fddi.h"
0047 #include "h/smc.h"
0048 
0049 #define KERNEL
0050 #include "h/smtstate.h"
0051 
0052 #ifndef lint
0053 static const char ID_sccs[] = "@(#)rmt.c    2.13 99/07/02 (C) SK " ;
0054 #endif
0055 
0056 /*
0057  * FSM Macros
0058  */
0059 #define AFLAG   0x10
0060 #define GO_STATE(x) (smc->mib.m[MAC0].fddiMACRMTState = (x)|AFLAG)
0061 #define ACTIONS_DONE()  (smc->mib.m[MAC0].fddiMACRMTState &= ~AFLAG)
0062 #define ACTIONS(x)  (x|AFLAG)
0063 
0064 #define RM0_ISOLATED    0
0065 #define RM1_NON_OP  1       /* not operational */
0066 #define RM2_RING_OP 2       /* ring operational */
0067 #define RM3_DETECT  3       /* detect dupl addresses */
0068 #define RM4_NON_OP_DUP  4       /* dupl. addr detected */
0069 #define RM5_RING_OP_DUP 5       /* ring oper. with dupl. addr */
0070 #define RM6_DIRECTED    6       /* sending directed beacons */
0071 #define RM7_TRACE   7       /* trace initiated */
0072 
0073 #ifdef  DEBUG
0074 /*
0075  * symbolic state names
0076  */
0077 static const char * const rmt_states[] = {
0078     "RM0_ISOLATED","RM1_NON_OP","RM2_RING_OP","RM3_DETECT",
0079     "RM4_NON_OP_DUP","RM5_RING_OP_DUP","RM6_DIRECTED",
0080     "RM7_TRACE"
0081 } ;
0082 
0083 /*
0084  * symbolic event names
0085  */
0086 static const char * const rmt_events[] = {
0087     "NONE","RM_RING_OP","RM_RING_NON_OP","RM_MY_BEACON",
0088     "RM_OTHER_BEACON","RM_MY_CLAIM","RM_TRT_EXP","RM_VALID_CLAIM",
0089     "RM_JOIN","RM_LOOP","RM_DUP_ADDR","RM_ENABLE_FLAG",
0090     "RM_TIMEOUT_NON_OP","RM_TIMEOUT_T_STUCK",
0091     "RM_TIMEOUT_ANNOUNCE","RM_TIMEOUT_T_DIRECT",
0092     "RM_TIMEOUT_D_MAX","RM_TIMEOUT_POLL","RM_TX_STATE_CHANGE"
0093 } ;
0094 #endif
0095 
0096 /*
0097  * Globals
0098  * in struct s_rmt
0099  */
0100 
0101 
0102 /*
0103  * function declarations
0104  */
0105 static void rmt_fsm(struct s_smc *smc, int cmd);
0106 static void start_rmt_timer0(struct s_smc *smc, u_long value, int event);
0107 static void start_rmt_timer1(struct s_smc *smc, u_long value, int event);
0108 static void start_rmt_timer2(struct s_smc *smc, u_long value, int event);
0109 static void stop_rmt_timer0(struct s_smc *smc);
0110 static void stop_rmt_timer1(struct s_smc *smc);
0111 static void stop_rmt_timer2(struct s_smc *smc);
0112 static void rmt_dup_actions(struct s_smc *smc);
0113 static void rmt_reinsert_actions(struct s_smc *smc);
0114 static void rmt_leave_actions(struct s_smc *smc);
0115 static void rmt_new_dup_actions(struct s_smc *smc);
0116 
0117 #ifndef SUPERNET_3
0118 extern void restart_trt_for_dbcn() ;
0119 #endif /*SUPERNET_3*/
0120 
0121 /*
0122     init RMT state machine
0123     clear all RMT vars and flags
0124 */
0125 void rmt_init(struct s_smc *smc)
0126 {
0127     smc->mib.m[MAC0].fddiMACRMTState = ACTIONS(RM0_ISOLATED) ;
0128     smc->r.dup_addr_test = DA_NONE ;
0129     smc->r.da_flag = 0 ;
0130     smc->mib.m[MAC0].fddiMACMA_UnitdataAvailable = FALSE ;
0131     smc->r.sm_ma_avail = FALSE ;
0132     smc->r.loop_avail = 0 ;
0133     smc->r.bn_flag = 0 ;
0134     smc->r.jm_flag = 0 ;
0135     smc->r.no_flag = TRUE ;
0136 }
0137 
0138 /*
0139     RMT state machine
0140     called by dispatcher
0141 
0142     do
0143         display state change
0144         process event
0145     until SM is stable
0146 */
0147 void rmt(struct s_smc *smc, int event)
0148 {
0149     int state ;
0150 
0151     do {
0152         DB_RMT("RMT : state %s%s",
0153             (smc->mib.m[MAC0].fddiMACRMTState & AFLAG) ? "ACTIONS " : "",
0154             rmt_states[smc->mib.m[MAC0].fddiMACRMTState & ~AFLAG]) ;
0155         DB_RMT(" event %s\n",rmt_events[event],0) ;
0156         state = smc->mib.m[MAC0].fddiMACRMTState ;
0157         rmt_fsm(smc,event) ;
0158         event = 0 ;
0159     } while (state != smc->mib.m[MAC0].fddiMACRMTState) ;
0160     rmt_state_change(smc,(int)smc->mib.m[MAC0].fddiMACRMTState) ;
0161 }
0162 
0163 /*
0164     process RMT event
0165 */
0166 static void rmt_fsm(struct s_smc *smc, int cmd)
0167 {
0168     /*
0169      * RM00-RM70 : from all states
0170      */
0171     if (!smc->r.rm_join && !smc->r.rm_loop &&
0172         smc->mib.m[MAC0].fddiMACRMTState != ACTIONS(RM0_ISOLATED) &&
0173         smc->mib.m[MAC0].fddiMACRMTState != RM0_ISOLATED) {
0174         RS_SET(smc,RS_NORINGOP) ;
0175         rmt_indication(smc,0) ;
0176         GO_STATE(RM0_ISOLATED) ;
0177         return ;
0178     }
0179 
0180     switch(smc->mib.m[MAC0].fddiMACRMTState) {
0181     case ACTIONS(RM0_ISOLATED) :
0182         stop_rmt_timer0(smc) ;
0183         stop_rmt_timer1(smc) ;
0184         stop_rmt_timer2(smc) ;
0185 
0186         /*
0187          * Disable MAC.
0188          */
0189         sm_ma_control(smc,MA_OFFLINE) ;
0190         smc->mib.m[MAC0].fddiMACMA_UnitdataAvailable = FALSE ;
0191         smc->r.loop_avail = FALSE ;
0192         smc->r.sm_ma_avail = FALSE ;
0193         smc->r.no_flag = TRUE ;
0194         DB_RMTN(1,"RMT : ISOLATED\n",0,0) ;
0195         ACTIONS_DONE() ;
0196         break ;
0197     case RM0_ISOLATED :
0198         /*RM01*/
0199         if (smc->r.rm_join || smc->r.rm_loop) {
0200             /*
0201              * According to the standard the MAC must be reset
0202              * here. The FORMAC will be initialized and Claim
0203              * and Beacon Frames will be uploaded to the MAC.
0204              * So any change of Treq will take effect NOW.
0205              */
0206             sm_ma_control(smc,MA_RESET) ;
0207             GO_STATE(RM1_NON_OP) ;
0208             break ;
0209         }
0210         break ;
0211     case ACTIONS(RM1_NON_OP) :
0212         start_rmt_timer0(smc,smc->s.rmt_t_non_op,RM_TIMEOUT_NON_OP) ;
0213         stop_rmt_timer1(smc) ;
0214         stop_rmt_timer2(smc) ;
0215         sm_ma_control(smc,MA_BEACON) ;
0216         DB_RMTN(1,"RMT : RING DOWN\n",0,0) ;
0217         RS_SET(smc,RS_NORINGOP) ;
0218         smc->r.sm_ma_avail = FALSE ;
0219         rmt_indication(smc,0) ;
0220         ACTIONS_DONE() ;
0221         break ;
0222     case RM1_NON_OP :
0223         /*RM12*/
0224         if (cmd == RM_RING_OP) {
0225             RS_SET(smc,RS_RINGOPCHANGE) ;
0226             GO_STATE(RM2_RING_OP) ;
0227             break ;
0228         }
0229         /*RM13*/
0230         else if (cmd == RM_TIMEOUT_NON_OP) {
0231             smc->r.bn_flag = FALSE ;
0232             smc->r.no_flag = TRUE ;
0233             GO_STATE(RM3_DETECT) ;
0234             break ;
0235         }
0236         break ;
0237     case ACTIONS(RM2_RING_OP) :
0238         stop_rmt_timer0(smc) ;
0239         stop_rmt_timer1(smc) ;
0240         stop_rmt_timer2(smc) ;
0241         smc->r.no_flag = FALSE ;
0242         if (smc->r.rm_loop)
0243             smc->r.loop_avail = TRUE ;
0244         if (smc->r.rm_join) {
0245             smc->r.sm_ma_avail = TRUE ;
0246             if (smc->mib.m[MAC0].fddiMACMA_UnitdataEnable)
0247             smc->mib.m[MAC0].fddiMACMA_UnitdataAvailable = TRUE ;
0248                 else
0249             smc->mib.m[MAC0].fddiMACMA_UnitdataAvailable = FALSE ;
0250         }
0251         DB_RMTN(1,"RMT : RING UP\n",0,0) ;
0252         RS_CLEAR(smc,RS_NORINGOP) ;
0253         RS_SET(smc,RS_RINGOPCHANGE) ;
0254         rmt_indication(smc,1) ;
0255         smt_stat_counter(smc,0) ;
0256         ACTIONS_DONE() ;
0257         break ;
0258     case RM2_RING_OP :
0259         /*RM21*/
0260         if (cmd == RM_RING_NON_OP) {
0261             smc->mib.m[MAC0].fddiMACMA_UnitdataAvailable = FALSE ;
0262             smc->r.loop_avail = FALSE ;
0263             RS_SET(smc,RS_RINGOPCHANGE) ;
0264             GO_STATE(RM1_NON_OP) ;
0265             break ;
0266         }
0267         /*RM22a*/
0268         else if (cmd == RM_ENABLE_FLAG) {
0269             if (smc->mib.m[MAC0].fddiMACMA_UnitdataEnable)
0270             smc->mib.m[MAC0].fddiMACMA_UnitdataAvailable = TRUE ;
0271                 else
0272             smc->mib.m[MAC0].fddiMACMA_UnitdataAvailable = FALSE ;
0273         }
0274         /*RM25*/
0275         else if (smc->r.dup_addr_test == DA_FAILED) {
0276             smc->mib.m[MAC0].fddiMACMA_UnitdataAvailable = FALSE ;
0277             smc->r.loop_avail = FALSE ;
0278             smc->r.da_flag = TRUE ;
0279             GO_STATE(RM5_RING_OP_DUP) ;
0280             break ;
0281         }
0282         break ;
0283     case ACTIONS(RM3_DETECT) :
0284         start_rmt_timer0(smc,smc->s.mac_d_max*2,RM_TIMEOUT_D_MAX) ;
0285         start_rmt_timer1(smc,smc->s.rmt_t_stuck,RM_TIMEOUT_T_STUCK) ;
0286         start_rmt_timer2(smc,smc->s.rmt_t_poll,RM_TIMEOUT_POLL) ;
0287         sm_mac_check_beacon_claim(smc) ;
0288         DB_RMTN(1,"RMT : RM3_DETECT\n",0,0) ;
0289         ACTIONS_DONE() ;
0290         break ;
0291     case RM3_DETECT :
0292         if (cmd == RM_TIMEOUT_POLL) {
0293             start_rmt_timer2(smc,smc->s.rmt_t_poll,RM_TIMEOUT_POLL);
0294             sm_mac_check_beacon_claim(smc) ;
0295             break ;
0296         }
0297         if (cmd == RM_TIMEOUT_D_MAX) {
0298             smc->r.timer0_exp = TRUE ;
0299         }
0300         /*
0301          *jd(22-Feb-1999)
0302          * We need a time ">= 2*mac_d_max" since we had finished
0303          * Claim or Beacon state. So we will restart timer0 at
0304          * every state change.
0305          */
0306         if (cmd == RM_TX_STATE_CHANGE) {
0307             start_rmt_timer0(smc,
0308                      smc->s.mac_d_max*2,
0309                      RM_TIMEOUT_D_MAX) ;
0310         }
0311         /*RM32*/
0312         if (cmd == RM_RING_OP) {
0313             GO_STATE(RM2_RING_OP) ;
0314             break ;
0315         }
0316         /*RM33a*/
0317         else if ((cmd == RM_MY_BEACON || cmd == RM_OTHER_BEACON)
0318             && smc->r.bn_flag) {
0319             smc->r.bn_flag = FALSE ;
0320         }
0321         /*RM33b*/
0322         else if (cmd == RM_TRT_EXP && !smc->r.bn_flag) {
0323             int tx ;
0324             /*
0325              * set bn_flag only if in state T4 or T5:
0326              * only if we're the beaconer should we start the
0327              * trace !
0328              */
0329             if ((tx =  sm_mac_get_tx_state(smc)) == 4 || tx == 5) {
0330             DB_RMTN(2,"RMT : DETECT && TRT_EXPIRED && T4/T5\n",0,0);
0331                 smc->r.bn_flag = TRUE ;
0332                 /*
0333                  * If one of the upstream stations beaconed
0334                  * and the link to the upstream neighbor is
0335                  * lost we need to restart the stuck timer to
0336                  * check the "stuck beacon" condition.
0337                  */
0338                 start_rmt_timer1(smc,smc->s.rmt_t_stuck,
0339                     RM_TIMEOUT_T_STUCK) ;
0340             }
0341             /*
0342              * We do NOT need to clear smc->r.bn_flag in case of
0343              * not being in state T4 or T5, because the flag
0344              * must be cleared in order to get in this condition.
0345              */
0346 
0347             DB_RMTN(2,
0348             "RMT : sm_mac_get_tx_state() = %d (bn_flag = %d)\n",
0349             tx,smc->r.bn_flag) ;
0350         }
0351         /*RM34a*/
0352         else if (cmd == RM_MY_CLAIM && smc->r.timer0_exp) {
0353             rmt_new_dup_actions(smc) ;
0354             GO_STATE(RM4_NON_OP_DUP) ;
0355             break ;
0356         }
0357         /*RM34b*/
0358         else if (cmd == RM_MY_BEACON && smc->r.timer0_exp) {
0359             rmt_new_dup_actions(smc) ;
0360             GO_STATE(RM4_NON_OP_DUP) ;
0361             break ;
0362         }
0363         /*RM34c*/
0364         else if (cmd == RM_VALID_CLAIM) {
0365             rmt_new_dup_actions(smc) ;
0366             GO_STATE(RM4_NON_OP_DUP) ;
0367             break ;
0368         }
0369         /*RM36*/
0370         else if (cmd == RM_TIMEOUT_T_STUCK &&
0371             smc->r.rm_join && smc->r.bn_flag) {
0372             GO_STATE(RM6_DIRECTED) ;
0373             break ;
0374         }
0375         break ;
0376     case ACTIONS(RM4_NON_OP_DUP) :
0377         start_rmt_timer0(smc,smc->s.rmt_t_announce,RM_TIMEOUT_ANNOUNCE);
0378         start_rmt_timer1(smc,smc->s.rmt_t_stuck,RM_TIMEOUT_T_STUCK) ;
0379         start_rmt_timer2(smc,smc->s.rmt_t_poll,RM_TIMEOUT_POLL) ;
0380         sm_mac_check_beacon_claim(smc) ;
0381         DB_RMTN(1,"RMT : RM4_NON_OP_DUP\n",0,0) ;
0382         ACTIONS_DONE() ;
0383         break ;
0384     case RM4_NON_OP_DUP :
0385         if (cmd == RM_TIMEOUT_POLL) {
0386             start_rmt_timer2(smc,smc->s.rmt_t_poll,RM_TIMEOUT_POLL);
0387             sm_mac_check_beacon_claim(smc) ;
0388             break ;
0389         }
0390         /*RM41*/
0391         if (!smc->r.da_flag) {
0392             GO_STATE(RM1_NON_OP) ;
0393             break ;
0394         }
0395         /*RM44a*/
0396         else if ((cmd == RM_MY_BEACON || cmd == RM_OTHER_BEACON) &&
0397             smc->r.bn_flag) {
0398             smc->r.bn_flag = FALSE ;
0399         }
0400         /*RM44b*/
0401         else if (cmd == RM_TRT_EXP && !smc->r.bn_flag) {
0402             int tx ;
0403             /*
0404              * set bn_flag only if in state T4 or T5:
0405              * only if we're the beaconer should we start the
0406              * trace !
0407              */
0408             if ((tx =  sm_mac_get_tx_state(smc)) == 4 || tx == 5) {
0409             DB_RMTN(2,"RMT : NOPDUP && TRT_EXPIRED && T4/T5\n",0,0);
0410                 smc->r.bn_flag = TRUE ;
0411                 /*
0412                  * If one of the upstream stations beaconed
0413                  * and the link to the upstream neighbor is
0414                  * lost we need to restart the stuck timer to
0415                  * check the "stuck beacon" condition.
0416                  */
0417                 start_rmt_timer1(smc,smc->s.rmt_t_stuck,
0418                     RM_TIMEOUT_T_STUCK) ;
0419             }
0420             /*
0421              * We do NOT need to clear smc->r.bn_flag in case of
0422              * not being in state T4 or T5, because the flag
0423              * must be cleared in order to get in this condition.
0424              */
0425 
0426             DB_RMTN(2,
0427             "RMT : sm_mac_get_tx_state() = %d (bn_flag = %d)\n",
0428             tx,smc->r.bn_flag) ;
0429         }
0430         /*RM44c*/
0431         else if (cmd == RM_TIMEOUT_ANNOUNCE && !smc->r.bn_flag) {
0432             rmt_dup_actions(smc) ;
0433         }
0434         /*RM45*/
0435         else if (cmd == RM_RING_OP) {
0436             smc->r.no_flag = FALSE ;
0437             GO_STATE(RM5_RING_OP_DUP) ;
0438             break ;
0439         }
0440         /*RM46*/
0441         else if (cmd == RM_TIMEOUT_T_STUCK &&
0442             smc->r.rm_join && smc->r.bn_flag) {
0443             GO_STATE(RM6_DIRECTED) ;
0444             break ;
0445         }
0446         break ;
0447     case ACTIONS(RM5_RING_OP_DUP) :
0448         stop_rmt_timer0(smc) ;
0449         stop_rmt_timer1(smc) ;
0450         stop_rmt_timer2(smc) ;
0451         DB_RMTN(1,"RMT : RM5_RING_OP_DUP\n",0,0) ;
0452         ACTIONS_DONE() ;
0453         break;
0454     case RM5_RING_OP_DUP :
0455         /*RM52*/
0456         if (smc->r.dup_addr_test == DA_PASSED) {
0457             smc->r.da_flag = FALSE ;
0458             GO_STATE(RM2_RING_OP) ;
0459             break ;
0460         }
0461         /*RM54*/
0462         else if (cmd == RM_RING_NON_OP) {
0463             smc->r.jm_flag = FALSE ;
0464             smc->r.bn_flag = FALSE ;
0465             GO_STATE(RM4_NON_OP_DUP) ;
0466             break ;
0467         }
0468         break ;
0469     case ACTIONS(RM6_DIRECTED) :
0470         start_rmt_timer0(smc,smc->s.rmt_t_direct,RM_TIMEOUT_T_DIRECT) ;
0471         stop_rmt_timer1(smc) ;
0472         start_rmt_timer2(smc,smc->s.rmt_t_poll,RM_TIMEOUT_POLL) ;
0473         sm_ma_control(smc,MA_DIRECTED) ;
0474         RS_SET(smc,RS_BEACON) ;
0475         DB_RMTN(1,"RMT : RM6_DIRECTED\n",0,0) ;
0476         ACTIONS_DONE() ;
0477         break ;
0478     case RM6_DIRECTED :
0479         /*RM63*/
0480         if (cmd == RM_TIMEOUT_POLL) {
0481             start_rmt_timer2(smc,smc->s.rmt_t_poll,RM_TIMEOUT_POLL);
0482             sm_mac_check_beacon_claim(smc) ;
0483 #ifndef SUPERNET_3
0484             /* Because of problems with the Supernet II chip set
0485              * sending of Directed Beacon will stop after 165ms
0486              * therefore restart_trt_for_dbcn(smc) will be called
0487              * to prevent this.
0488              */
0489             restart_trt_for_dbcn(smc) ;
0490 #endif /*SUPERNET_3*/
0491             break ;
0492         }
0493         if ((cmd == RM_MY_BEACON || cmd == RM_OTHER_BEACON) &&
0494             !smc->r.da_flag) {
0495             smc->r.bn_flag = FALSE ;
0496             GO_STATE(RM3_DETECT) ;
0497             break ;
0498         }
0499         /*RM64*/
0500         else if ((cmd == RM_MY_BEACON || cmd == RM_OTHER_BEACON) &&
0501             smc->r.da_flag) {
0502             smc->r.bn_flag = FALSE ;
0503             GO_STATE(RM4_NON_OP_DUP) ;
0504             break ;
0505         }
0506         /*RM67*/
0507         else if (cmd == RM_TIMEOUT_T_DIRECT) {
0508             GO_STATE(RM7_TRACE) ;
0509             break ;
0510         }
0511         break ;
0512     case ACTIONS(RM7_TRACE) :
0513         stop_rmt_timer0(smc) ;
0514         stop_rmt_timer1(smc) ;
0515         stop_rmt_timer2(smc) ;
0516         smc->e.trace_prop |= ENTITY_BIT(ENTITY_MAC) ;
0517         queue_event(smc,EVENT_ECM,EC_TRACE_PROP) ;
0518         DB_RMTN(1,"RMT : RM7_TRACE\n",0,0) ;
0519         ACTIONS_DONE() ;
0520         break ;
0521     case RM7_TRACE :
0522         break ;
0523     default:
0524         SMT_PANIC(smc,SMT_E0122, SMT_E0122_MSG) ;
0525         break;
0526     }
0527 }
0528 
0529 /*
0530  * (jd) RMT duplicate address actions
0531  * leave the ring or reinsert just as configured
0532  */
0533 static void rmt_dup_actions(struct s_smc *smc)
0534 {
0535     if (smc->r.jm_flag) {
0536     }
0537     else {
0538         if (smc->s.rmt_dup_mac_behavior) {
0539             SMT_ERR_LOG(smc,SMT_E0138, SMT_E0138_MSG) ;
0540                         rmt_reinsert_actions(smc) ;
0541         }
0542         else {
0543             SMT_ERR_LOG(smc,SMT_E0135, SMT_E0135_MSG) ;
0544             rmt_leave_actions(smc) ;
0545         }
0546     }
0547 }
0548 
0549 /*
0550  * Reconnect to the Ring
0551  */
0552 static void rmt_reinsert_actions(struct s_smc *smc)
0553 {
0554     queue_event(smc,EVENT_ECM,EC_DISCONNECT) ;
0555     queue_event(smc,EVENT_ECM,EC_CONNECT) ;
0556 }
0557 
0558 /*
0559  * duplicate address detected
0560  */
0561 static void rmt_new_dup_actions(struct s_smc *smc)
0562 {
0563     smc->r.da_flag = TRUE ;
0564     smc->r.bn_flag = FALSE ;
0565     smc->r.jm_flag = FALSE ;
0566     /*
0567      * we have three options : change address, jam or leave
0568      * we leave the ring as default 
0569      * Optionally it's possible to reinsert after leaving the Ring
0570      * but this will not conform with SMT Spec.
0571      */
0572     if (smc->s.rmt_dup_mac_behavior) {
0573         SMT_ERR_LOG(smc,SMT_E0138, SMT_E0138_MSG) ;
0574         rmt_reinsert_actions(smc) ;
0575     }
0576     else {
0577         SMT_ERR_LOG(smc,SMT_E0135, SMT_E0135_MSG) ;
0578         rmt_leave_actions(smc) ;
0579     }
0580 }
0581 
0582 
0583 /*
0584  * leave the ring
0585  */
0586 static void rmt_leave_actions(struct s_smc *smc)
0587 {
0588     queue_event(smc,EVENT_ECM,EC_DISCONNECT) ;
0589     /*
0590      * Note: Do NOT try again later. (with please reconnect)
0591      * The station must be left from the ring!
0592      */
0593 }
0594 
0595 /*
0596  * SMT timer interface
0597  *  start RMT timer 0
0598  */
0599 static void start_rmt_timer0(struct s_smc *smc, u_long value, int event)
0600 {
0601     smc->r.timer0_exp = FALSE ;     /* clear timer event flag */
0602     smt_timer_start(smc,&smc->r.rmt_timer0,value,EV_TOKEN(EVENT_RMT,event));
0603 }
0604 
0605 /*
0606  * SMT timer interface
0607  *  start RMT timer 1
0608  */
0609 static void start_rmt_timer1(struct s_smc *smc, u_long value, int event)
0610 {
0611     smc->r.timer1_exp = FALSE ; /* clear timer event flag */
0612     smt_timer_start(smc,&smc->r.rmt_timer1,value,EV_TOKEN(EVENT_RMT,event));
0613 }
0614 
0615 /*
0616  * SMT timer interface
0617  *  start RMT timer 2
0618  */
0619 static void start_rmt_timer2(struct s_smc *smc, u_long value, int event)
0620 {
0621     smc->r.timer2_exp = FALSE ;     /* clear timer event flag */
0622     smt_timer_start(smc,&smc->r.rmt_timer2,value,EV_TOKEN(EVENT_RMT,event));
0623 }
0624 
0625 /*
0626  * SMT timer interface
0627  *  stop RMT timer 0
0628  */
0629 static void stop_rmt_timer0(struct s_smc *smc)
0630 {
0631     if (smc->r.rmt_timer0.tm_active)
0632         smt_timer_stop(smc,&smc->r.rmt_timer0) ;
0633 }
0634 
0635 /*
0636  * SMT timer interface
0637  *  stop RMT timer 1
0638  */
0639 static void stop_rmt_timer1(struct s_smc *smc)
0640 {
0641     if (smc->r.rmt_timer1.tm_active)
0642         smt_timer_stop(smc,&smc->r.rmt_timer1) ;
0643 }
0644 
0645 /*
0646  * SMT timer interface
0647  *  stop RMT timer 2
0648  */
0649 static void stop_rmt_timer2(struct s_smc *smc)
0650 {
0651     if (smc->r.rmt_timer2.tm_active)
0652         smt_timer_stop(smc,&smc->r.rmt_timer2) ;
0653 }
0654