smc.h 14 KB

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