smc.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. /******************************************************************************
  2. *
  3. * (C)Copyright 1998,1999 SysKonnect,
  4. * a business unit of Schneider & Koch & Co. Datensysteme GmbH.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * The information in this file is provided "AS IS" without warranty.
  12. *
  13. ******************************************************************************/
  14. #ifndef _SCMECM_
  15. #define _SCMECM_
  16. #if defined(PCI) && !defined(OSDEF)
  17. /*
  18. * In the case of the PCI bus the file osdef1st.h must be present
  19. */
  20. #define OSDEF
  21. #endif
  22. #ifdef PCI
  23. #ifndef SUPERNET_3
  24. #define SUPERNET_3
  25. #endif
  26. #ifndef TAG_MODE
  27. #define TAG_MODE
  28. #endif
  29. #endif
  30. /*
  31. * include all other files in required order
  32. * the following files must have been included before:
  33. * types.h
  34. * fddi.h
  35. */
  36. #ifdef OSDEF
  37. #include "osdef1st.h"
  38. #endif /* OSDEF */
  39. #ifdef OEM_CONCEPT
  40. #include "oemdef.h"
  41. #endif /* OEM_CONCEPT */
  42. #include "smt.h"
  43. #include "cmtdef.h"
  44. #include "fddimib.h"
  45. #include "targethw.h" /* all target hw dependencies */
  46. #include "targetos.h" /* all target os dependencies */
  47. #ifdef ESS
  48. #include "sba.h"
  49. #endif
  50. /*
  51. * Event Queue
  52. * queue.c
  53. * events are class/value pairs
  54. * class is addressee, e.g. RMT, PCM etc.
  55. * value is command, e.g. line state change, ring op change etc.
  56. */
  57. struct event_queue {
  58. u_short class ; /* event class */
  59. u_short event ; /* event value */
  60. } ;
  61. /*
  62. * define event queue as circular buffer
  63. */
  64. #ifdef CONCENTRATOR
  65. #define MAX_EVENT 128
  66. #else /* nCONCENTRATOR */
  67. #define MAX_EVENT 64
  68. #endif /* nCONCENTRATOR */
  69. struct s_queue {
  70. struct event_queue ev_queue[MAX_EVENT];
  71. struct event_queue *ev_put ;
  72. struct event_queue *ev_get ;
  73. } ;
  74. /*
  75. * ECM - Entity Coordination Management
  76. * ecm.c
  77. */
  78. struct s_ecm {
  79. u_char path_test ; /* ECM path test variable */
  80. u_char sb_flag ; /* ECM stuck bypass */
  81. u_char DisconnectFlag ; /* jd 05-Aug-1999 Bug #10419
  82. * ECM disconnected */
  83. u_char ecm_line_state ; /* flag to dispatcher : line states */
  84. u_long trace_prop ; /* ECM Trace_Prop flag >= 16 bits !! */
  85. /* NUMPHYS note:
  86. * this variable must have enough bits to hold all entiies in
  87. * the station. So NUMPHYS may not be greater than 31.
  88. */
  89. char ec_pad[2] ;
  90. struct smt_timer ecm_timer ; /* timer */
  91. } ;
  92. /*
  93. * RMT - Ring Management
  94. * rmt.c
  95. */
  96. struct s_rmt {
  97. u_char dup_addr_test ; /* state of dupl. addr. test */
  98. u_char da_flag ; /* flag : duplicate address det. */
  99. u_char loop_avail ; /* flag : MAC available for loopback */
  100. u_char sm_ma_avail ; /* flag : MAC available for SMT */
  101. u_char no_flag ; /* flag : ring not operational */
  102. u_char bn_flag ; /* flag : MAC reached beacon state */
  103. u_char jm_flag ; /* flag : jamming in NON_OP_DUP */
  104. u_char rm_join ; /* CFM flag RM_Join */
  105. u_char rm_loop ; /* CFM flag RM_Loop */
  106. long fast_rm_join ; /* bit mask of active ports */
  107. /*
  108. * timer and flags
  109. */
  110. struct smt_timer rmt_timer0 ; /* timer 0 */
  111. struct smt_timer rmt_timer1 ; /* timer 1 */
  112. struct smt_timer rmt_timer2 ; /* timer 2 */
  113. u_char timer0_exp ; /* flag : timer 0 expired */
  114. u_char timer1_exp ; /* flag : timer 1 expired */
  115. u_char timer2_exp ; /* flag : timer 2 expired */
  116. u_char rm_pad1[1] ;
  117. } ;
  118. /*
  119. * CFM - Configuration Management
  120. * cfm.c
  121. * used for SAS and DAS
  122. */
  123. struct s_cfm {
  124. u_char cf_state; /* CFM state machine current state */
  125. u_char cf_pad[3] ;
  126. } ;
  127. /*
  128. * CEM - Configuration Element Management
  129. * cem.c
  130. * used for Concentrator
  131. */
  132. #ifdef CONCENTRATOR
  133. struct s_cem {
  134. int ce_state ; /* CEM state */
  135. int ce_port ; /* PA PB PM PM+1 .. */
  136. int ce_type ; /* TA TB TS TM */
  137. } ;
  138. /*
  139. * linked list of CCEs in current token path
  140. */
  141. struct s_c_ring {
  142. struct s_c_ring *c_next ;
  143. char c_entity ;
  144. } ;
  145. struct mib_path_config {
  146. u_long fddimibPATHConfigSMTIndex;
  147. u_long fddimibPATHConfigPATHIndex;
  148. u_long fddimibPATHConfigTokenOrder;
  149. u_long fddimibPATHConfigResourceType;
  150. #define SNMP_RES_TYPE_MAC 2 /* Resource is a MAC */
  151. #define SNMP_RES_TYPE_PORT 4 /* Resource is a PORT */
  152. u_long fddimibPATHConfigResourceIndex;
  153. u_long fddimibPATHConfigCurrentPath;
  154. #define SNMP_PATH_ISOLATED 1 /* Current path is isolated */
  155. #define SNMP_PATH_LOCAL 2 /* Current path is local */
  156. #define SNMP_PATH_SECONDARY 3 /* Current path is secondary */
  157. #define SNMP_PATH_PRIMARY 4 /* Current path is primary */
  158. #define SNMP_PATH_CONCATENATED 5 /* Current path is concatenated */
  159. #define SNMP_PATH_THRU 6 /* Current path is thru */
  160. };
  161. #endif
  162. /*
  163. * PCM connect states
  164. */
  165. #define PCM_DISABLED 0
  166. #define PCM_CONNECTING 1
  167. #define PCM_STANDBY 2
  168. #define PCM_ACTIVE 3
  169. struct s_pcm {
  170. u_char pcm_pad[3] ;
  171. } ;
  172. /*
  173. * PHY struct
  174. * one per physical port
  175. */
  176. struct s_phy {
  177. /* Inter Module Globals */
  178. struct fddi_mib_p *mib ;
  179. u_char np ; /* index 0 .. NUMPHYS */
  180. u_char cf_join ;
  181. u_char cf_loop ;
  182. u_char wc_flag ; /* withhold connection flag */
  183. u_char pc_mode ; /* Holds the negotiated mode of the PCM */
  184. u_char pc_lem_fail ; /* flag : LCT failed */
  185. u_char lc_test ;
  186. u_char scrub ; /* CFM flag Scrub -> PCM */
  187. char phy_name ;
  188. u_char pmd_type[2] ; /* SK connector/transceiver type codes */
  189. #define PMD_SK_CONN 0 /* pmd_type[PMD_SK_CONN] = Connector */
  190. #define PMD_SK_PMD 1 /* pmd_type[PMD_SK_PMD] = Xver */
  191. u_char pmd_scramble ; /* scrambler on/off */
  192. /* inner Module Globals */
  193. u_char curr_ls ; /* current line state */
  194. u_char ls_flag ;
  195. u_char rc_flag ;
  196. u_char tc_flag ;
  197. u_char td_flag ;
  198. u_char bitn ;
  199. u_char tr_flag ; /* trace recvd while in active */
  200. u_char twisted ; /* flag to indicate an A-A or B-B connection */
  201. u_char t_val[NUMBITS] ; /* transmit bits for signaling */
  202. u_char r_val[NUMBITS] ; /* receive bits for signaling */
  203. u_long t_next[NUMBITS] ;
  204. struct smt_timer pcm_timer0 ;
  205. struct smt_timer pcm_timer1 ;
  206. struct smt_timer pcm_timer2 ;
  207. u_char timer0_exp ;
  208. u_char timer1_exp ;
  209. u_char timer2_exp ;
  210. u_char pcm_pad1[1] ;
  211. int cem_pst ; /* CEM privae state; used for dual homing */
  212. struct lem_counter lem ;
  213. #ifdef AMDPLC
  214. struct s_plc plc ;
  215. #endif
  216. } ;
  217. /*
  218. * timer package
  219. * smttimer.c
  220. */
  221. struct s_timer {
  222. struct smt_timer *st_queue ;
  223. struct smt_timer st_fast ;
  224. } ;
  225. /*
  226. * SRF types and data
  227. */
  228. #define SMT_EVENT_BASE 1
  229. #define SMT_EVENT_MAC_PATH_CHANGE (SMT_EVENT_BASE+0)
  230. #define SMT_EVENT_MAC_NEIGHBOR_CHANGE (SMT_EVENT_BASE+1)
  231. #define SMT_EVENT_PORT_PATH_CHANGE (SMT_EVENT_BASE+2)
  232. #define SMT_EVENT_PORT_CONNECTION (SMT_EVENT_BASE+3)
  233. #define SMT_IS_CONDITION(x) ((x)>=SMT_COND_BASE)
  234. #define SMT_COND_BASE (SMT_EVENT_PORT_CONNECTION+1)
  235. #define SMT_COND_SMT_PEER_WRAP (SMT_COND_BASE+0)
  236. #define SMT_COND_SMT_HOLD (SMT_COND_BASE+1)
  237. #define SMT_COND_MAC_FRAME_ERROR (SMT_COND_BASE+2)
  238. #define SMT_COND_MAC_DUP_ADDR (SMT_COND_BASE+3)
  239. #define SMT_COND_MAC_NOT_COPIED (SMT_COND_BASE+4)
  240. #define SMT_COND_PORT_EB_ERROR (SMT_COND_BASE+5)
  241. #define SMT_COND_PORT_LER (SMT_COND_BASE+6)
  242. #define SR0_WAIT 0
  243. #define SR1_HOLDOFF 1
  244. #define SR2_DISABLED 2
  245. struct s_srf {
  246. u_long SRThreshold ; /* threshold value */
  247. u_char RT_Flag ; /* report transmitted flag */
  248. u_char sr_state ; /* state-machine */
  249. u_char any_report ; /* any report required */
  250. u_long TSR ; /* timer */
  251. u_short ring_status ; /* IBM ring status */
  252. } ;
  253. /*
  254. * IBM token ring status
  255. */
  256. #define RS_RES15 (1<<15) /* reserved */
  257. #define RS_HARDERROR (1<<14) /* ring down */
  258. #define RS_SOFTERROR (1<<13) /* sent SRF */
  259. #define RS_BEACON (1<<12) /* transmitted beacon */
  260. #define RS_PATHTEST (1<<11) /* path test failed */
  261. #define RS_SELFTEST (1<<10) /* selftest required */
  262. #define RS_RES9 (1<< 9) /* reserved */
  263. #define RS_DISCONNECT (1<< 8) /* remote disconnect */
  264. #define RS_RES7 (1<< 7) /* reserved */
  265. #define RS_DUPADDR (1<< 6) /* duplicate address */
  266. #define RS_NORINGOP (1<< 5) /* no ring op */
  267. #define RS_VERSION (1<< 4) /* SMT version mismatch */
  268. #define RS_STUCKBYPASSS (1<< 3) /* stuck bypass */
  269. #define RS_EVENT (1<< 2) /* FDDI event occurred */
  270. #define RS_RINGOPCHANGE (1<< 1) /* ring op changed */
  271. #define RS_RES0 (1<< 0) /* reserved */
  272. #define RS_SET(smc,bit) \
  273. ring_status_indication(smc,smc->srf.ring_status |= bit)
  274. #define RS_CLEAR(smc,bit) \
  275. ring_status_indication(smc,smc->srf.ring_status &= ~bit)
  276. #define RS_CLEAR_EVENT (0xffff & ~(RS_NORINGOP))
  277. /* Define the AIX-event-Notification as null function if it isn't defined */
  278. /* in the targetos.h file */
  279. #ifndef AIX_EVENT
  280. #define AIX_EVENT(smc,opt0,opt1,opt2,opt3) /* nothing */
  281. #endif
  282. struct s_srf_evc {
  283. u_char evc_code ; /* event code type */
  284. u_char evc_index ; /* index for mult. instances */
  285. u_char evc_rep_required ; /* report required */
  286. u_short evc_para ; /* SMT Para Number */
  287. u_char *evc_cond_state ; /* condition state */
  288. u_char *evc_multiple ; /* multiple occurrence */
  289. } ;
  290. /*
  291. * Values used by frame based services
  292. * smt.c
  293. */
  294. #define SMT_MAX_TEST 5
  295. #define SMT_TID_NIF 0 /* pending NIF request */
  296. #define SMT_TID_NIF_TEST 1 /* pending NIF test */
  297. #define SMT_TID_ECF_UNA 2 /* pending ECF UNA test */
  298. #define SMT_TID_ECF_DNA 3 /* pending ECF DNA test */
  299. #define SMT_TID_ECF 4 /* pending ECF test */
  300. struct smt_values {
  301. u_long smt_tvu ; /* timer valid una */
  302. u_long smt_tvd ; /* timer valid dna */
  303. u_long smt_tid ; /* transaction id */
  304. u_long pend[SMT_MAX_TEST] ; /* TID of requests */
  305. u_long uniq_time ; /* unique time stamp */
  306. u_short uniq_ticks ; /* unique time stamp */
  307. u_short please_reconnect ; /* flag : reconnect */
  308. u_long smt_last_lem ;
  309. u_long smt_last_notify ;
  310. struct smt_timer smt_timer ; /* SMT NIF timer */
  311. u_long last_tok_time[NUMMACS]; /* token cnt emulation */
  312. } ;
  313. /*
  314. * SMT/CMT configurable parameters
  315. */
  316. #define SMT_DAS 0 /* dual attach */
  317. #define SMT_SAS 1 /* single attach */
  318. #define SMT_NAC 2 /* null attach concentrator */
  319. struct smt_config {
  320. u_char attach_s ; /* CFM attach to secondary path */
  321. u_char sas ; /* SMT_DAS/SAS/NAC */
  322. u_char build_ring_map ; /* build ringmap if TRUE */
  323. u_char numphys ; /* number of active phys */
  324. u_char sc_pad[1] ;
  325. u_long pcm_tb_min ; /* PCM : TB_Min timer value */
  326. u_long pcm_tb_max ; /* PCM : TB_Max timer value */
  327. u_long pcm_c_min ; /* PCM : C_Min timer value */
  328. u_long pcm_t_out ; /* PCM : T_Out timer value */
  329. u_long pcm_tl_min ; /* PCM : TL_min timer value */
  330. u_long pcm_lc_short ; /* PCM : LC_Short timer value */
  331. u_long pcm_lc_medium ; /* PCM : LC_Medium timer value */
  332. u_long pcm_lc_long ; /* PCM : LC_Long timer value */
  333. u_long pcm_lc_extended ; /* PCM : LC_Extended timer value */
  334. u_long pcm_t_next_9 ; /* PCM : T_Next[9] timer value */
  335. u_long pcm_ns_max ; /* PCM : NS_Max timer value */
  336. u_long ecm_i_max ; /* ECM : I_Max timer value */
  337. u_long ecm_in_max ; /* ECM : IN_Max timer value */
  338. u_long ecm_td_min ; /* ECM : TD_Min timer */
  339. u_long ecm_test_done ; /* ECM : path test done timer */
  340. u_long ecm_check_poll ; /* ECM : check bypass poller */
  341. u_long rmt_t_non_op ; /* RMT : T_Non_OP timer value */
  342. u_long rmt_t_stuck ; /* RMT : T_Stuck timer value */
  343. u_long rmt_t_direct ; /* RMT : T_Direct timer value */
  344. u_long rmt_t_jam ; /* RMT : T_Jam timer value */
  345. u_long rmt_t_announce ; /* RMT : T_Announce timer value */
  346. u_long rmt_t_poll ; /* RMT : claim/beacon poller */
  347. u_long rmt_dup_mac_behavior ; /* Flag for the beavior of SMT if
  348. * a Duplicate MAC Address was detected.
  349. * FALSE: SMT will leave finally the ring
  350. * TRUE: SMT will reinstert into the ring
  351. */
  352. u_long mac_d_max ; /* MAC : D_Max timer value */
  353. u_long lct_short ; /* LCT : error threshold */
  354. u_long lct_medium ; /* LCT : error threshold */
  355. u_long lct_long ; /* LCT : error threshold */
  356. u_long lct_extended ; /* LCT : error threshold */
  357. } ;
  358. #ifdef DEBUG
  359. /*
  360. * Debugging struct sometimes used in smc
  361. */
  362. struct smt_debug {
  363. int d_smtf ;
  364. int d_smt ;
  365. int d_ecm ;
  366. int d_rmt ;
  367. int d_cfm ;
  368. int d_pcm ;
  369. int d_plc ;
  370. #ifdef ESS
  371. int d_ess ;
  372. #endif
  373. #ifdef SBA
  374. int d_sba ;
  375. #endif
  376. struct os_debug d_os; /* Include specific OS DEBUG struct */
  377. } ;
  378. #ifndef DEBUG_BRD
  379. /* all boards shall be debugged with one debug struct */
  380. extern struct smt_debug debug; /* Declaration of debug struct */
  381. #endif /* DEBUG_BRD */
  382. #endif /* DEBUG */
  383. /*
  384. * the SMT Context Struct SMC
  385. * this struct contains ALL global variables of SMT
  386. */
  387. struct s_smc {
  388. struct s_smt_os os ; /* os specific */
  389. struct s_smt_hw hw ; /* hardware */
  390. /*
  391. * NOTE: os and hw MUST BE the first two structs
  392. * anything beyond hw WILL BE SET TO ZERO in smt_set_defaults()
  393. */
  394. struct smt_config s ; /* smt constants */
  395. struct smt_values sm ; /* smt variables */
  396. struct s_ecm e ; /* ecm */
  397. struct s_rmt r ; /* rmt */
  398. struct s_cfm cf ; /* cfm/cem */
  399. #ifdef CONCENTRATOR
  400. struct s_cem ce[NUMPHYS] ; /* cem */
  401. struct s_c_ring cr[NUMPHYS+NUMMACS] ;
  402. #endif
  403. struct s_pcm p ; /* pcm */
  404. struct s_phy y[NUMPHYS] ; /* phy */
  405. struct s_queue q ; /* queue */
  406. struct s_timer t ; /* timer */
  407. struct s_srf srf ; /* SRF */
  408. struct s_srf_evc evcs[6+NUMPHYS*4] ;
  409. struct fddi_mib mib ; /* __THE_MIB__ */
  410. #ifdef SBA
  411. struct s_sba sba ; /* SBA variables */
  412. #endif
  413. #ifdef ESS
  414. struct s_ess ess ; /* Ess variables */
  415. #endif
  416. #if defined(DEBUG) && defined(DEBUG_BRD)
  417. /* If you want all single board to be debugged separately */
  418. struct smt_debug debug; /* Declaration of debug struct */
  419. #endif /* DEBUG_BRD && DEBUG */
  420. } ;
  421. extern const struct fddi_addr fddi_broadcast;
  422. void all_selection_criteria(struct s_smc *smc);
  423. void card_stop(struct s_smc *smc);
  424. void init_board(struct s_smc *smc, u_char *mac_addr);
  425. int init_fplus(struct s_smc *smc);
  426. void init_plc(struct s_smc *smc);
  427. int init_smt(struct s_smc *smc, u_char *mac_addr);
  428. void mac1_irq(struct s_smc *smc, u_short stu, u_short stl);
  429. void mac2_irq(struct s_smc *smc, u_short code_s2u, u_short code_s2l);
  430. void mac3_irq(struct s_smc *smc, u_short code_s3u, u_short code_s3l);
  431. int pcm_status_twisted(struct s_smc *smc);
  432. void plc1_irq(struct s_smc *smc);
  433. void plc2_irq(struct s_smc *smc);
  434. void read_address(struct s_smc *smc, u_char *mac_addr);
  435. void timer_irq(struct s_smc *smc);
  436. #endif /* _SCMECM_ */