cfm.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  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. SMT CFM
  18. Configuration Management
  19. DAS with single MAC
  20. */
  21. /*
  22. * Hardware independent state machine implemantation
  23. * The following external SMT functions are referenced :
  24. *
  25. * queue_event()
  26. *
  27. * The following external HW dependent functions are referenced :
  28. * config_mux()
  29. *
  30. * The following HW dependent events are required :
  31. * NONE
  32. */
  33. #include "h/types.h"
  34. #include "h/fddi.h"
  35. #include "h/smc.h"
  36. #define KERNEL
  37. #include "h/smtstate.h"
  38. #ifndef lint
  39. static const char ID_sccs[] = "@(#)cfm.c 2.18 98/10/06 (C) SK " ;
  40. #endif
  41. /*
  42. * FSM Macros
  43. */
  44. #define AFLAG 0x10
  45. #define GO_STATE(x) (smc->mib.fddiSMTCF_State = (x)|AFLAG)
  46. #define ACTIONS_DONE() (smc->mib.fddiSMTCF_State &= ~AFLAG)
  47. #define ACTIONS(x) (x|AFLAG)
  48. #ifdef DEBUG
  49. /*
  50. * symbolic state names
  51. */
  52. static const char * const cfm_states[] = {
  53. "SC0_ISOLATED","CF1","CF2","CF3","CF4",
  54. "SC1_WRAP_A","SC2_WRAP_B","SC5_TRHU_B","SC7_WRAP_S",
  55. "SC9_C_WRAP_A","SC10_C_WRAP_B","SC11_C_WRAP_S","SC4_THRU_A"
  56. } ;
  57. /*
  58. * symbolic event names
  59. */
  60. static const char * const cfm_events[] = {
  61. "NONE","CF_LOOP_A","CF_LOOP_B","CF_JOIN_A","CF_JOIN_B"
  62. } ;
  63. #endif
  64. /*
  65. * map from state to downstream port type
  66. */
  67. static const unsigned char cf_to_ptype[] = {
  68. TNONE,TNONE,TNONE,TNONE,TNONE,
  69. TNONE,TB,TB,TS,
  70. TA,TB,TS,TB
  71. } ;
  72. /*
  73. * CEM port states
  74. */
  75. #define CEM_PST_DOWN 0
  76. #define CEM_PST_UP 1
  77. #define CEM_PST_HOLD 2
  78. /* define portstate array only for A and B port */
  79. /* Do this within the smc structure (use in multiple cards) */
  80. /*
  81. * all Globals are defined in smc.h
  82. * struct s_cfm
  83. */
  84. /*
  85. * function declarations
  86. */
  87. static void cfm_fsm(struct s_smc *smc, int cmd);
  88. /*
  89. init CFM state machine
  90. clear all CFM vars and flags
  91. */
  92. void cfm_init(struct s_smc *smc)
  93. {
  94. smc->mib.fddiSMTCF_State = ACTIONS(SC0_ISOLATED) ;
  95. smc->r.rm_join = 0 ;
  96. smc->r.rm_loop = 0 ;
  97. smc->y[PA].scrub = 0 ;
  98. smc->y[PB].scrub = 0 ;
  99. smc->y[PA].cem_pst = CEM_PST_DOWN ;
  100. smc->y[PB].cem_pst = CEM_PST_DOWN ;
  101. }
  102. /* Some terms conditions used by the selection criteria */
  103. #define THRU_ENABLED(smc) (smc->y[PA].pc_mode != PM_TREE && \
  104. smc->y[PB].pc_mode != PM_TREE)
  105. /* Selection criteria for the ports */
  106. static void selection_criteria (struct s_smc *smc, struct s_phy *phy)
  107. {
  108. switch (phy->mib->fddiPORTMy_Type) {
  109. case TA:
  110. if ( !THRU_ENABLED(smc) && smc->y[PB].cf_join ) {
  111. phy->wc_flag = TRUE ;
  112. } else {
  113. phy->wc_flag = FALSE ;
  114. }
  115. break;
  116. case TB:
  117. /* take precedence over PA */
  118. phy->wc_flag = FALSE ;
  119. break;
  120. case TS:
  121. phy->wc_flag = FALSE ;
  122. break;
  123. case TM:
  124. phy->wc_flag = FALSE ;
  125. break;
  126. }
  127. }
  128. void all_selection_criteria(struct s_smc *smc)
  129. {
  130. struct s_phy *phy ;
  131. int p ;
  132. for ( p = 0,phy = smc->y ; p < NUMPHYS; p++, phy++ ) {
  133. /* Do the selection criteria */
  134. selection_criteria (smc,phy);
  135. }
  136. }
  137. static void cem_priv_state(struct s_smc *smc, int event)
  138. /* State machine for private PORT states: used to optimize dual homing */
  139. {
  140. int np; /* Number of the port */
  141. int i;
  142. /* Do this only in a DAS */
  143. if (smc->s.sas != SMT_DAS )
  144. return ;
  145. np = event - CF_JOIN;
  146. if (np != PA && np != PB) {
  147. return ;
  148. }
  149. /* Change the port state according to the event (portnumber) */
  150. if (smc->y[np].cf_join) {
  151. smc->y[np].cem_pst = CEM_PST_UP ;
  152. } else if (!smc->y[np].wc_flag) {
  153. /* set the port to done only if it is not withheld */
  154. smc->y[np].cem_pst = CEM_PST_DOWN ;
  155. }
  156. /* Don't set an hold port to down */
  157. /* Check all ports of restart conditions */
  158. for (i = 0 ; i < 2 ; i ++ ) {
  159. /* Check all port for PORT is on hold and no withhold is done */
  160. if ( smc->y[i].cem_pst == CEM_PST_HOLD && !smc->y[i].wc_flag ) {
  161. smc->y[i].cem_pst = CEM_PST_DOWN;
  162. queue_event(smc,(int)(EVENT_PCM+i),PC_START) ;
  163. }
  164. if ( smc->y[i].cem_pst == CEM_PST_UP && smc->y[i].wc_flag ) {
  165. smc->y[i].cem_pst = CEM_PST_HOLD;
  166. queue_event(smc,(int)(EVENT_PCM+i),PC_START) ;
  167. }
  168. if ( smc->y[i].cem_pst == CEM_PST_DOWN && smc->y[i].wc_flag ) {
  169. /*
  170. * The port must be restarted when the wc_flag
  171. * will be reset. So set the port on hold.
  172. */
  173. smc->y[i].cem_pst = CEM_PST_HOLD;
  174. }
  175. }
  176. return ;
  177. }
  178. /*
  179. CFM state machine
  180. called by dispatcher
  181. do
  182. display state change
  183. process event
  184. until SM is stable
  185. */
  186. void cfm(struct s_smc *smc, int event)
  187. {
  188. int state ; /* remember last state */
  189. int cond ;
  190. int oldstate ;
  191. /* We will do the following: */
  192. /* - compute the variable WC_Flag for every port (This is where */
  193. /* we can extend the requested path checking !!) */
  194. /* - do the old (SMT 6.2 like) state machine */
  195. /* - do the resulting station states */
  196. all_selection_criteria (smc);
  197. /* We will check now whether a state transition is allowed or not */
  198. /* - change the portstates */
  199. cem_priv_state (smc, event);
  200. oldstate = smc->mib.fddiSMTCF_State ;
  201. do {
  202. DB_CFM("CFM : state %s%s",
  203. (smc->mib.fddiSMTCF_State & AFLAG) ? "ACTIONS " : "",
  204. cfm_states[smc->mib.fddiSMTCF_State & ~AFLAG]) ;
  205. DB_CFM(" event %s\n",cfm_events[event],0) ;
  206. state = smc->mib.fddiSMTCF_State ;
  207. cfm_fsm(smc,event) ;
  208. event = 0 ;
  209. } while (state != smc->mib.fddiSMTCF_State) ;
  210. #ifndef SLIM_SMT
  211. /*
  212. * check peer wrap condition
  213. */
  214. cond = FALSE ;
  215. if ( (smc->mib.fddiSMTCF_State == SC9_C_WRAP_A &&
  216. smc->y[PA].pc_mode == PM_PEER) ||
  217. (smc->mib.fddiSMTCF_State == SC10_C_WRAP_B &&
  218. smc->y[PB].pc_mode == PM_PEER) ||
  219. (smc->mib.fddiSMTCF_State == SC11_C_WRAP_S &&
  220. smc->y[PS].pc_mode == PM_PEER &&
  221. smc->y[PS].mib->fddiPORTNeighborType != TS ) ) {
  222. cond = TRUE ;
  223. }
  224. if (cond != smc->mib.fddiSMTPeerWrapFlag)
  225. smt_srf_event(smc,SMT_COND_SMT_PEER_WRAP,0,cond) ;
  226. #if 0
  227. /*
  228. * Don't send ever MAC_PATH_CHANGE events. Our MAC is hard-wired
  229. * to the primary path.
  230. */
  231. /*
  232. * path change
  233. */
  234. if (smc->mib.fddiSMTCF_State != oldstate) {
  235. smt_srf_event(smc,SMT_EVENT_MAC_PATH_CHANGE,INDEX_MAC,0) ;
  236. }
  237. #endif
  238. #endif /* no SLIM_SMT */
  239. /*
  240. * set MAC port type
  241. */
  242. smc->mib.m[MAC0].fddiMACDownstreamPORTType =
  243. cf_to_ptype[smc->mib.fddiSMTCF_State] ;
  244. cfm_state_change(smc,(int)smc->mib.fddiSMTCF_State) ;
  245. }
  246. /*
  247. process CFM event
  248. */
  249. /*ARGSUSED1*/
  250. static void cfm_fsm(struct s_smc *smc, int cmd)
  251. {
  252. switch(smc->mib.fddiSMTCF_State) {
  253. case ACTIONS(SC0_ISOLATED) :
  254. smc->mib.p[PA].fddiPORTCurrentPath = MIB_PATH_ISOLATED ;
  255. smc->mib.p[PB].fddiPORTCurrentPath = MIB_PATH_ISOLATED ;
  256. smc->mib.p[PA].fddiPORTMACPlacement = 0 ;
  257. smc->mib.p[PB].fddiPORTMACPlacement = 0 ;
  258. smc->mib.fddiSMTStationStatus = MIB_SMT_STASTA_SEPA ;
  259. config_mux(smc,MUX_ISOLATE) ; /* configure PHY Mux */
  260. smc->r.rm_loop = FALSE ;
  261. smc->r.rm_join = FALSE ;
  262. queue_event(smc,EVENT_RMT,RM_JOIN) ;/* signal RMT */
  263. /* Don't do the WC-Flag changing here */
  264. ACTIONS_DONE() ;
  265. DB_CFMN(1,"CFM : %s\n",cfm_states[smc->mib.fddiSMTCF_State],0) ;
  266. break;
  267. case SC0_ISOLATED :
  268. /*SC07*/
  269. /*SAS port can be PA or PB ! */
  270. if (smc->s.sas && (smc->y[PA].cf_join || smc->y[PA].cf_loop ||
  271. smc->y[PB].cf_join || smc->y[PB].cf_loop)) {
  272. GO_STATE(SC11_C_WRAP_S) ;
  273. break ;
  274. }
  275. /*SC01*/
  276. if ((smc->y[PA].cem_pst == CEM_PST_UP && smc->y[PA].cf_join &&
  277. !smc->y[PA].wc_flag) || smc->y[PA].cf_loop) {
  278. GO_STATE(SC9_C_WRAP_A) ;
  279. break ;
  280. }
  281. /*SC02*/
  282. if ((smc->y[PB].cem_pst == CEM_PST_UP && smc->y[PB].cf_join &&
  283. !smc->y[PB].wc_flag) || smc->y[PB].cf_loop) {
  284. GO_STATE(SC10_C_WRAP_B) ;
  285. break ;
  286. }
  287. break ;
  288. case ACTIONS(SC9_C_WRAP_A) :
  289. smc->mib.p[PA].fddiPORTCurrentPath = MIB_PATH_CONCATENATED ;
  290. smc->mib.p[PB].fddiPORTCurrentPath = MIB_PATH_ISOLATED ;
  291. smc->mib.p[PA].fddiPORTMACPlacement = INDEX_MAC ;
  292. smc->mib.p[PB].fddiPORTMACPlacement = 0 ;
  293. smc->mib.fddiSMTStationStatus = MIB_SMT_STASTA_CON ;
  294. config_mux(smc,MUX_WRAPA) ; /* configure PHY mux */
  295. if (smc->y[PA].cf_loop) {
  296. smc->r.rm_join = FALSE ;
  297. smc->r.rm_loop = TRUE ;
  298. queue_event(smc,EVENT_RMT,RM_LOOP) ;/* signal RMT */
  299. }
  300. if (smc->y[PA].cf_join) {
  301. smc->r.rm_loop = FALSE ;
  302. smc->r.rm_join = TRUE ;
  303. queue_event(smc,EVENT_RMT,RM_JOIN) ;/* signal RMT */
  304. }
  305. ACTIONS_DONE() ;
  306. DB_CFMN(1,"CFM : %s\n",cfm_states[smc->mib.fddiSMTCF_State],0) ;
  307. break ;
  308. case SC9_C_WRAP_A :
  309. /*SC10*/
  310. if ( (smc->y[PA].wc_flag || !smc->y[PA].cf_join) &&
  311. !smc->y[PA].cf_loop ) {
  312. GO_STATE(SC0_ISOLATED) ;
  313. break ;
  314. }
  315. /*SC12*/
  316. else if ( (smc->y[PB].cf_loop && smc->y[PA].cf_join &&
  317. smc->y[PA].cem_pst == CEM_PST_UP) ||
  318. ((smc->y[PB].cf_loop ||
  319. (smc->y[PB].cf_join &&
  320. smc->y[PB].cem_pst == CEM_PST_UP)) &&
  321. (smc->y[PA].pc_mode == PM_TREE ||
  322. smc->y[PB].pc_mode == PM_TREE))) {
  323. smc->y[PA].scrub = TRUE ;
  324. GO_STATE(SC10_C_WRAP_B) ;
  325. break ;
  326. }
  327. /*SC14*/
  328. else if (!smc->s.attach_s &&
  329. smc->y[PA].cf_join &&
  330. smc->y[PA].cem_pst == CEM_PST_UP &&
  331. smc->y[PA].pc_mode == PM_PEER && smc->y[PB].cf_join &&
  332. smc->y[PB].cem_pst == CEM_PST_UP &&
  333. smc->y[PB].pc_mode == PM_PEER) {
  334. smc->y[PA].scrub = TRUE ;
  335. smc->y[PB].scrub = TRUE ;
  336. GO_STATE(SC4_THRU_A) ;
  337. break ;
  338. }
  339. /*SC15*/
  340. else if ( smc->s.attach_s &&
  341. smc->y[PA].cf_join &&
  342. smc->y[PA].cem_pst == CEM_PST_UP &&
  343. smc->y[PA].pc_mode == PM_PEER &&
  344. smc->y[PB].cf_join &&
  345. smc->y[PB].cem_pst == CEM_PST_UP &&
  346. smc->y[PB].pc_mode == PM_PEER) {
  347. smc->y[PA].scrub = TRUE ;
  348. smc->y[PB].scrub = TRUE ;
  349. GO_STATE(SC5_THRU_B) ;
  350. break ;
  351. }
  352. break ;
  353. case ACTIONS(SC10_C_WRAP_B) :
  354. smc->mib.p[PA].fddiPORTCurrentPath = MIB_PATH_ISOLATED ;
  355. smc->mib.p[PB].fddiPORTCurrentPath = MIB_PATH_CONCATENATED ;
  356. smc->mib.p[PA].fddiPORTMACPlacement = 0 ;
  357. smc->mib.p[PB].fddiPORTMACPlacement = INDEX_MAC ;
  358. smc->mib.fddiSMTStationStatus = MIB_SMT_STASTA_CON ;
  359. config_mux(smc,MUX_WRAPB) ; /* configure PHY mux */
  360. if (smc->y[PB].cf_loop) {
  361. smc->r.rm_join = FALSE ;
  362. smc->r.rm_loop = TRUE ;
  363. queue_event(smc,EVENT_RMT,RM_LOOP) ;/* signal RMT */
  364. }
  365. if (smc->y[PB].cf_join) {
  366. smc->r.rm_loop = FALSE ;
  367. smc->r.rm_join = TRUE ;
  368. queue_event(smc,EVENT_RMT,RM_JOIN) ;/* signal RMT */
  369. }
  370. ACTIONS_DONE() ;
  371. DB_CFMN(1,"CFM : %s\n",cfm_states[smc->mib.fddiSMTCF_State],0) ;
  372. break ;
  373. case SC10_C_WRAP_B :
  374. /*SC20*/
  375. if ( !smc->y[PB].cf_join && !smc->y[PB].cf_loop ) {
  376. GO_STATE(SC0_ISOLATED) ;
  377. break ;
  378. }
  379. /*SC21*/
  380. else if ( smc->y[PA].cf_loop && smc->y[PA].pc_mode == PM_PEER &&
  381. smc->y[PB].cf_join && smc->y[PB].pc_mode == PM_PEER) {
  382. smc->y[PB].scrub = TRUE ;
  383. GO_STATE(SC9_C_WRAP_A) ;
  384. break ;
  385. }
  386. /*SC24*/
  387. else if (!smc->s.attach_s &&
  388. smc->y[PA].cf_join && smc->y[PA].pc_mode == PM_PEER &&
  389. smc->y[PB].cf_join && smc->y[PB].pc_mode == PM_PEER) {
  390. smc->y[PA].scrub = TRUE ;
  391. smc->y[PB].scrub = TRUE ;
  392. GO_STATE(SC4_THRU_A) ;
  393. break ;
  394. }
  395. /*SC25*/
  396. else if ( smc->s.attach_s &&
  397. smc->y[PA].cf_join && smc->y[PA].pc_mode == PM_PEER &&
  398. smc->y[PB].cf_join && smc->y[PB].pc_mode == PM_PEER) {
  399. smc->y[PA].scrub = TRUE ;
  400. smc->y[PB].scrub = TRUE ;
  401. GO_STATE(SC5_THRU_B) ;
  402. break ;
  403. }
  404. break ;
  405. case ACTIONS(SC4_THRU_A) :
  406. smc->mib.p[PA].fddiPORTCurrentPath = MIB_PATH_THRU ;
  407. smc->mib.p[PB].fddiPORTCurrentPath = MIB_PATH_THRU ;
  408. smc->mib.p[PA].fddiPORTMACPlacement = 0 ;
  409. smc->mib.p[PB].fddiPORTMACPlacement = INDEX_MAC ;
  410. smc->mib.fddiSMTStationStatus = MIB_SMT_STASTA_THRU ;
  411. config_mux(smc,MUX_THRUA) ; /* configure PHY mux */
  412. smc->r.rm_loop = FALSE ;
  413. smc->r.rm_join = TRUE ;
  414. queue_event(smc,EVENT_RMT,RM_JOIN) ;/* signal RMT */
  415. ACTIONS_DONE() ;
  416. DB_CFMN(1,"CFM : %s\n",cfm_states[smc->mib.fddiSMTCF_State],0) ;
  417. break ;
  418. case SC4_THRU_A :
  419. /*SC41*/
  420. if (smc->y[PB].wc_flag || !smc->y[PB].cf_join) {
  421. smc->y[PA].scrub = TRUE ;
  422. GO_STATE(SC9_C_WRAP_A) ;
  423. break ;
  424. }
  425. /*SC42*/
  426. else if (!smc->y[PA].cf_join || smc->y[PA].wc_flag) {
  427. smc->y[PB].scrub = TRUE ;
  428. GO_STATE(SC10_C_WRAP_B) ;
  429. break ;
  430. }
  431. /*SC45*/
  432. else if (smc->s.attach_s) {
  433. smc->y[PB].scrub = TRUE ;
  434. GO_STATE(SC5_THRU_B) ;
  435. break ;
  436. }
  437. break ;
  438. case ACTIONS(SC5_THRU_B) :
  439. smc->mib.p[PA].fddiPORTCurrentPath = MIB_PATH_THRU ;
  440. smc->mib.p[PB].fddiPORTCurrentPath = MIB_PATH_THRU ;
  441. smc->mib.p[PA].fddiPORTMACPlacement = INDEX_MAC ;
  442. smc->mib.p[PB].fddiPORTMACPlacement = 0 ;
  443. smc->mib.fddiSMTStationStatus = MIB_SMT_STASTA_THRU ;
  444. config_mux(smc,MUX_THRUB) ; /* configure PHY mux */
  445. smc->r.rm_loop = FALSE ;
  446. smc->r.rm_join = TRUE ;
  447. queue_event(smc,EVENT_RMT,RM_JOIN) ;/* signal RMT */
  448. ACTIONS_DONE() ;
  449. DB_CFMN(1,"CFM : %s\n",cfm_states[smc->mib.fddiSMTCF_State],0) ;
  450. break ;
  451. case SC5_THRU_B :
  452. /*SC51*/
  453. if (!smc->y[PB].cf_join || smc->y[PB].wc_flag) {
  454. smc->y[PA].scrub = TRUE ;
  455. GO_STATE(SC9_C_WRAP_A) ;
  456. break ;
  457. }
  458. /*SC52*/
  459. else if (!smc->y[PA].cf_join || smc->y[PA].wc_flag) {
  460. smc->y[PB].scrub = TRUE ;
  461. GO_STATE(SC10_C_WRAP_B) ;
  462. break ;
  463. }
  464. /*SC54*/
  465. else if (!smc->s.attach_s) {
  466. smc->y[PA].scrub = TRUE ;
  467. GO_STATE(SC4_THRU_A) ;
  468. break ;
  469. }
  470. break ;
  471. case ACTIONS(SC11_C_WRAP_S) :
  472. smc->mib.p[PS].fddiPORTCurrentPath = MIB_PATH_CONCATENATED ;
  473. smc->mib.p[PS].fddiPORTMACPlacement = INDEX_MAC ;
  474. smc->mib.fddiSMTStationStatus = MIB_SMT_STASTA_CON ;
  475. config_mux(smc,MUX_WRAPS) ; /* configure PHY mux */
  476. if (smc->y[PA].cf_loop || smc->y[PB].cf_loop) {
  477. smc->r.rm_join = FALSE ;
  478. smc->r.rm_loop = TRUE ;
  479. queue_event(smc,EVENT_RMT,RM_LOOP) ;/* signal RMT */
  480. }
  481. if (smc->y[PA].cf_join || smc->y[PB].cf_join) {
  482. smc->r.rm_loop = FALSE ;
  483. smc->r.rm_join = TRUE ;
  484. queue_event(smc,EVENT_RMT,RM_JOIN) ;/* signal RMT */
  485. }
  486. ACTIONS_DONE() ;
  487. DB_CFMN(1,"CFM : %s\n",cfm_states[smc->mib.fddiSMTCF_State],0) ;
  488. break ;
  489. case SC11_C_WRAP_S :
  490. /*SC70*/
  491. if ( !smc->y[PA].cf_join && !smc->y[PA].cf_loop &&
  492. !smc->y[PB].cf_join && !smc->y[PB].cf_loop) {
  493. GO_STATE(SC0_ISOLATED) ;
  494. break ;
  495. }
  496. break ;
  497. default:
  498. SMT_PANIC(smc,SMT_E0106, SMT_E0106_MSG) ;
  499. break;
  500. }
  501. }
  502. /*
  503. * get MAC's input Port
  504. * return :
  505. * PA or PB
  506. */
  507. int cfm_get_mac_input(struct s_smc *smc)
  508. {
  509. return (smc->mib.fddiSMTCF_State == SC10_C_WRAP_B ||
  510. smc->mib.fddiSMTCF_State == SC5_THRU_B) ? PB : PA;
  511. }
  512. /*
  513. * get MAC's output Port
  514. * return :
  515. * PA or PB
  516. */
  517. int cfm_get_mac_output(struct s_smc *smc)
  518. {
  519. return (smc->mib.fddiSMTCF_State == SC10_C_WRAP_B ||
  520. smc->mib.fddiSMTCF_State == SC4_THRU_A) ? PB : PA;
  521. }
  522. static char path_iso[] = {
  523. 0,0, 0,RES_PORT, 0,PA + INDEX_PORT, 0,PATH_ISO,
  524. 0,0, 0,RES_MAC, 0,INDEX_MAC, 0,PATH_ISO,
  525. 0,0, 0,RES_PORT, 0,PB + INDEX_PORT, 0,PATH_ISO
  526. } ;
  527. static char path_wrap_a[] = {
  528. 0,0, 0,RES_PORT, 0,PA + INDEX_PORT, 0,PATH_PRIM,
  529. 0,0, 0,RES_MAC, 0,INDEX_MAC, 0,PATH_PRIM,
  530. 0,0, 0,RES_PORT, 0,PB + INDEX_PORT, 0,PATH_ISO
  531. } ;
  532. static char path_wrap_b[] = {
  533. 0,0, 0,RES_PORT, 0,PB + INDEX_PORT, 0,PATH_PRIM,
  534. 0,0, 0,RES_MAC, 0,INDEX_MAC, 0,PATH_PRIM,
  535. 0,0, 0,RES_PORT, 0,PA + INDEX_PORT, 0,PATH_ISO
  536. } ;
  537. static char path_thru[] = {
  538. 0,0, 0,RES_PORT, 0,PA + INDEX_PORT, 0,PATH_PRIM,
  539. 0,0, 0,RES_MAC, 0,INDEX_MAC, 0,PATH_PRIM,
  540. 0,0, 0,RES_PORT, 0,PB + INDEX_PORT, 0,PATH_PRIM
  541. } ;
  542. static char path_wrap_s[] = {
  543. 0,0, 0,RES_PORT, 0,PS + INDEX_PORT, 0,PATH_PRIM,
  544. 0,0, 0,RES_MAC, 0,INDEX_MAC, 0,PATH_PRIM,
  545. } ;
  546. static char path_iso_s[] = {
  547. 0,0, 0,RES_PORT, 0,PS + INDEX_PORT, 0,PATH_ISO,
  548. 0,0, 0,RES_MAC, 0,INDEX_MAC, 0,PATH_ISO,
  549. } ;
  550. int cem_build_path(struct s_smc *smc, char *to, int path_index)
  551. {
  552. char *path ;
  553. int len ;
  554. switch (smc->mib.fddiSMTCF_State) {
  555. default :
  556. case SC0_ISOLATED :
  557. path = smc->s.sas ? path_iso_s : path_iso ;
  558. len = smc->s.sas ? sizeof(path_iso_s) : sizeof(path_iso) ;
  559. break ;
  560. case SC9_C_WRAP_A :
  561. path = path_wrap_a ;
  562. len = sizeof(path_wrap_a) ;
  563. break ;
  564. case SC10_C_WRAP_B :
  565. path = path_wrap_b ;
  566. len = sizeof(path_wrap_b) ;
  567. break ;
  568. case SC4_THRU_A :
  569. path = path_thru ;
  570. len = sizeof(path_thru) ;
  571. break ;
  572. case SC11_C_WRAP_S :
  573. path = path_wrap_s ;
  574. len = sizeof(path_wrap_s) ;
  575. break ;
  576. }
  577. memcpy(to,path,len) ;
  578. LINT_USE(path_index);
  579. return len;
  580. }