53 static const char ID_sccs[] =
"@(#)rmt.c 2.13 99/07/02 (C) SK " ;
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)
64 #define RM0_ISOLATED 0
68 #define RM4_NON_OP_DUP 4
69 #define RM5_RING_OP_DUP 5
70 #define RM6_DIRECTED 6
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",
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"
109 static void stop_rmt_timer0(
struct s_smc *
smc);
110 static void stop_rmt_timer1(
struct s_smc *
smc);
111 static void stop_rmt_timer2(
struct s_smc *
smc);
112 static void rmt_dup_actions(
struct s_smc *
smc);
113 static void rmt_reinsert_actions(
struct s_smc *
smc);
114 static void rmt_leave_actions(
struct s_smc *
smc);
115 static void rmt_new_dup_actions(
struct s_smc *
smc);
131 smc->
r.sm_ma_avail =
FALSE ;
132 smc->
r.loop_avail = 0 ;
135 smc->
r.no_flag =
TRUE ;
152 DB_RMT(
"RMT : state %s%s",
153 (smc->
mib.m[
MAC0].fddiMACRMTState &
AFLAG) ?
"ACTIONS " :
"",
154 rmt_states[smc->
mib.m[
MAC0].fddiMACRMTState & ~AFLAG]) ;
155 DB_RMT(
" event %s\n",rmt_events[event],0) ;
156 state = smc->
mib.m[
MAC0].fddiMACRMTState ;
159 }
while (state != smc->
mib.m[
MAC0].fddiMACRMTState) ;
171 if (!smc->
r.rm_join && !smc->
r.rm_loop &&
180 switch(smc->
mib.m[
MAC0].fddiMACRMTState) {
182 stop_rmt_timer0(smc) ;
183 stop_rmt_timer1(smc) ;
184 stop_rmt_timer2(smc) ;
191 smc->
r.loop_avail =
FALSE ;
192 smc->
r.sm_ma_avail =
FALSE ;
193 smc->
r.no_flag =
TRUE ;
194 DB_RMTN(1,
"RMT : ISOLATED\n",0,0) ;
199 if (smc->
r.rm_join || smc->
r.rm_loop) {
213 stop_rmt_timer1(smc) ;
214 stop_rmt_timer2(smc) ;
216 DB_RMTN(1,
"RMT : RING DOWN\n",0,0) ;
218 smc->
r.sm_ma_avail =
FALSE ;
232 smc->
r.no_flag =
TRUE ;
238 stop_rmt_timer0(smc) ;
239 stop_rmt_timer1(smc) ;
240 stop_rmt_timer2(smc) ;
243 smc->
r.loop_avail =
TRUE ;
244 if (smc->
r.rm_join) {
245 smc->
r.sm_ma_avail =
TRUE ;
246 if (smc->
mib.m[
MAC0].fddiMACMA_UnitdataEnable)
247 smc->
mib.m[
MAC0].fddiMACMA_UnitdataAvailable =
TRUE ;
251 DB_RMTN(1,
"RMT : RING UP\n",0,0) ;
262 smc->
r.loop_avail =
FALSE ;
269 if (smc->
mib.m[
MAC0].fddiMACMA_UnitdataEnable)
270 smc->
mib.m[
MAC0].fddiMACMA_UnitdataAvailable =
TRUE ;
277 smc->
r.loop_avail =
FALSE ;
278 smc->
r.da_flag =
TRUE ;
288 DB_RMTN(1,
"RMT : RM3_DETECT\n",0,0) ;
298 smc->
r.timer0_exp =
TRUE ;
307 start_rmt_timer0(smc,
330 DB_RMTN(2,
"RMT : DETECT && TRT_EXPIRED && T4/T5\n",0,0);
331 smc->
r.bn_flag =
TRUE ;
338 start_rmt_timer1(smc,smc->
s.rmt_t_stuck,
348 "RMT : sm_mac_get_tx_state() = %d (bn_flag = %d)\n",
353 rmt_new_dup_actions(smc) ;
359 rmt_new_dup_actions(smc) ;
365 rmt_new_dup_actions(smc) ;
371 smc->
r.rm_join && smc->
r.bn_flag) {
381 DB_RMTN(1,
"RMT : RM4_NON_OP_DUP\n",0,0) ;
391 if (!smc->
r.da_flag) {
409 DB_RMTN(2,
"RMT : NOPDUP && TRT_EXPIRED && T4/T5\n",0,0);
410 smc->
r.bn_flag =
TRUE ;
417 start_rmt_timer1(smc,smc->
s.rmt_t_stuck,
427 "RMT : sm_mac_get_tx_state() = %d (bn_flag = %d)\n",
432 rmt_dup_actions(smc) ;
442 smc->
r.rm_join && smc->
r.bn_flag) {
448 stop_rmt_timer0(smc) ;
449 stop_rmt_timer1(smc) ;
450 stop_rmt_timer2(smc) ;
451 DB_RMTN(1,
"RMT : RM5_RING_OP_DUP\n",0,0) ;
471 stop_rmt_timer1(smc) ;
475 DB_RMTN(1,
"RMT : RM6_DIRECTED\n",0,0) ;
513 stop_rmt_timer0(smc) ;
514 stop_rmt_timer1(smc) ;
515 stop_rmt_timer2(smc) ;
518 DB_RMTN(1,
"RMT : RM7_TRACE\n",0,0) ;
533 static void rmt_dup_actions(
struct s_smc *smc)
535 if (smc->
r.jm_flag) {
538 if (smc->
s.rmt_dup_mac_behavior) {
540 rmt_reinsert_actions(smc) ;
544 rmt_leave_actions(smc) ;
552 static void rmt_reinsert_actions(
struct s_smc *smc)
561 static void rmt_new_dup_actions(
struct s_smc *smc)
563 smc->
r.da_flag =
TRUE ;
572 if (smc->
s.rmt_dup_mac_behavior) {
574 rmt_reinsert_actions(smc) ;
578 rmt_leave_actions(smc) ;
586 static void rmt_leave_actions(
struct s_smc *smc)
601 smc->
r.timer0_exp =
FALSE ;
609 static void start_rmt_timer1(
struct s_smc *smc,
u_long value,
int event)
611 smc->
r.timer1_exp =
FALSE ;
619 static void start_rmt_timer2(
struct s_smc *smc,
u_long value,
int event)
621 smc->
r.timer2_exp =
FALSE ;
629 static void stop_rmt_timer0(
struct s_smc *smc)
631 if (smc->
r.rmt_timer0.tm_active)
639 static void stop_rmt_timer1(
struct s_smc *smc)
641 if (smc->
r.rmt_timer1.tm_active)
649 static void stop_rmt_timer2(
struct s_smc *smc)
651 if (smc->
r.rmt_timer2.tm_active)