smtdef.c 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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/CMT defaults
  18. */
  19. #include "h/types.h"
  20. #include "h/fddi.h"
  21. #include "h/smc.h"
  22. #ifndef OEM_USER_DATA
  23. #define OEM_USER_DATA "SK-NET FDDI V2.0 Userdata"
  24. #endif
  25. #ifndef lint
  26. static const char ID_sccs[] = "@(#)smtdef.c 2.53 99/08/11 (C) SK " ;
  27. #endif
  28. /*
  29. * defaults
  30. */
  31. #define TTMS(x) ((u_long)(x)*1000L)
  32. #define TTS(x) ((u_long)(x)*1000000L)
  33. #define TTUS(x) ((u_long)(x))
  34. #define DEFAULT_TB_MIN TTMS(5)
  35. #define DEFAULT_TB_MAX TTMS(50)
  36. #define DEFAULT_C_MIN TTUS(1600)
  37. #define DEFAULT_T_OUT TTMS(100+5)
  38. #define DEFAULT_TL_MIN TTUS(30)
  39. #define DEFAULT_LC_SHORT TTMS(50+5)
  40. #define DEFAULT_LC_MEDIUM TTMS(500+20)
  41. #define DEFAULT_LC_LONG TTS(5)+TTMS(50)
  42. #define DEFAULT_LC_EXTENDED TTS(50)+TTMS(50)
  43. #define DEFAULT_T_NEXT_9 TTMS(200+10)
  44. #define DEFAULT_NS_MAX TTUS(1310)
  45. #define DEFAULT_I_MAX TTMS(25)
  46. #define DEFAULT_IN_MAX TTMS(40)
  47. #define DEFAULT_TD_MIN TTMS(5)
  48. #define DEFAULT_T_NON_OP TTS(1)
  49. #define DEFAULT_T_STUCK TTS(8)
  50. #define DEFAULT_T_DIRECT TTMS(370)
  51. #define DEFAULT_T_JAM TTMS(370)
  52. #define DEFAULT_T_ANNOUNCE TTMS(2500)
  53. #define DEFAULT_D_MAX TTUS(1617)
  54. #define DEFAULT_LEM_ALARM (8)
  55. #define DEFAULT_LEM_CUTOFF (7)
  56. #define DEFAULT_TEST_DONE TTS(1)
  57. #define DEFAULT_CHECK_POLL TTS(1)
  58. #define DEFAULT_POLL TTMS(50)
  59. /*
  60. * LCT errors threshold
  61. */
  62. #define DEFAULT_LCT_SHORT 1
  63. #define DEFAULT_LCT_MEDIUM 3
  64. #define DEFAULT_LCT_LONG 5
  65. #define DEFAULT_LCT_EXTEND 50
  66. /* Forward declarations */
  67. void smt_reset_defaults(struct s_smc *smc, int level);
  68. static void smt_init_mib(struct s_smc *smc, int level);
  69. static int set_min_max(int maxflag, u_long mib, u_long limit, u_long *oper);
  70. #define MS2BCLK(x) ((x)*12500L)
  71. #define US2BCLK(x) ((x)*1250L)
  72. void smt_reset_defaults(struct s_smc *smc, int level)
  73. {
  74. struct smt_config *smt ;
  75. int i ;
  76. u_long smt_boot_time;
  77. smt_init_mib(smc,level) ;
  78. smc->os.smc_version = SMC_VERSION ;
  79. smt_boot_time = smt_get_time();
  80. for( i = 0; i < NUMMACS; i++ )
  81. smc->sm.last_tok_time[i] = smt_boot_time ;
  82. smt = &smc->s ;
  83. smt->attach_s = 0 ;
  84. smt->build_ring_map = 1 ;
  85. smt->sas = SMT_DAS ;
  86. smt->numphys = NUMPHYS ;
  87. smt->pcm_tb_min = DEFAULT_TB_MIN ;
  88. smt->pcm_tb_max = DEFAULT_TB_MAX ;
  89. smt->pcm_c_min = DEFAULT_C_MIN ;
  90. smt->pcm_t_out = DEFAULT_T_OUT ;
  91. smt->pcm_tl_min = DEFAULT_TL_MIN ;
  92. smt->pcm_lc_short = DEFAULT_LC_SHORT ;
  93. smt->pcm_lc_medium = DEFAULT_LC_MEDIUM ;
  94. smt->pcm_lc_long = DEFAULT_LC_LONG ;
  95. smt->pcm_lc_extended = DEFAULT_LC_EXTENDED ;
  96. smt->pcm_t_next_9 = DEFAULT_T_NEXT_9 ;
  97. smt->pcm_ns_max = DEFAULT_NS_MAX ;
  98. smt->ecm_i_max = DEFAULT_I_MAX ;
  99. smt->ecm_in_max = DEFAULT_IN_MAX ;
  100. smt->ecm_td_min = DEFAULT_TD_MIN ;
  101. smt->ecm_test_done = DEFAULT_TEST_DONE ;
  102. smt->ecm_check_poll = DEFAULT_CHECK_POLL ;
  103. smt->rmt_t_non_op = DEFAULT_T_NON_OP ;
  104. smt->rmt_t_stuck = DEFAULT_T_STUCK ;
  105. smt->rmt_t_direct = DEFAULT_T_DIRECT ;
  106. smt->rmt_t_jam = DEFAULT_T_JAM ;
  107. smt->rmt_t_announce = DEFAULT_T_ANNOUNCE ;
  108. smt->rmt_t_poll = DEFAULT_POLL ;
  109. smt->rmt_dup_mac_behavior = FALSE ; /* See Struct smt_config */
  110. smt->mac_d_max = DEFAULT_D_MAX ;
  111. smt->lct_short = DEFAULT_LCT_SHORT ;
  112. smt->lct_medium = DEFAULT_LCT_MEDIUM ;
  113. smt->lct_long = DEFAULT_LCT_LONG ;
  114. smt->lct_extended = DEFAULT_LCT_EXTEND ;
  115. #ifndef SLIM_SMT
  116. #ifdef ESS
  117. if (level == 0) {
  118. smc->ess.sync_bw_available = FALSE ;
  119. smc->mib.fddiESSPayload = 0 ;
  120. smc->mib.fddiESSOverhead = 0 ;
  121. smc->mib.fddiESSMaxTNeg = (u_long)(- MS2BCLK(25)) ;
  122. smc->mib.fddiESSMinSegmentSize = 1 ;
  123. smc->mib.fddiESSCategory = SB_STATIC ;
  124. smc->mib.fddiESSSynchTxMode = FALSE ;
  125. smc->ess.raf_act_timer_poll = FALSE ;
  126. smc->ess.timer_count = 7 ; /* first RAF alc req after 3s */
  127. }
  128. smc->ess.local_sba_active = FALSE ;
  129. smc->ess.sba_reply_pend = NULL ;
  130. #endif
  131. #ifdef SBA
  132. smt_init_sba(smc,level) ;
  133. #endif
  134. #endif /* no SLIM_SMT */
  135. #ifdef TAG_MODE
  136. if (level == 0) {
  137. smc->hw.pci_fix_value = 0 ;
  138. }
  139. #endif
  140. }
  141. /*
  142. * manufacturer data
  143. */
  144. static const char man_data[32] =
  145. /* 01234567890123456789012345678901 */
  146. "xxxSK-NET FDDI SMT 7.3 - V2.8.8" ;
  147. static void smt_init_mib(struct s_smc *smc, int level)
  148. {
  149. struct fddi_mib *mib ;
  150. struct fddi_mib_p *pm ;
  151. int port ;
  152. int path ;
  153. mib = &smc->mib ;
  154. if (level == 0) {
  155. /*
  156. * set EVERYTHING to ZERO
  157. * EXCEPT hw and os
  158. */
  159. memset(((char *)smc)+
  160. sizeof(struct s_smt_os)+sizeof(struct s_smt_hw), 0,
  161. sizeof(struct s_smc) -
  162. sizeof(struct s_smt_os) - sizeof(struct s_smt_hw)) ;
  163. }
  164. else {
  165. mib->fddiSMTRemoteDisconnectFlag = 0 ;
  166. mib->fddiSMTPeerWrapFlag = 0 ;
  167. }
  168. mib->fddiSMTOpVersionId = 2 ;
  169. mib->fddiSMTHiVersionId = 2 ;
  170. mib->fddiSMTLoVersionId = 2 ;
  171. memcpy((char *) mib->fddiSMTManufacturerData,man_data,32) ;
  172. if (level == 0) {
  173. strcpy(mib->fddiSMTUserData,OEM_USER_DATA) ;
  174. }
  175. mib->fddiSMTMIBVersionId = 1 ;
  176. mib->fddiSMTMac_Ct = NUMMACS ;
  177. mib->fddiSMTConnectionPolicy = POLICY_MM | POLICY_AA | POLICY_BB ;
  178. /*
  179. * fddiSMTNonMaster_Ct and fddiSMTMaster_Ct are set in smt_fixup_mib
  180. * s.sas is not set yet (is set in init driver)
  181. */
  182. mib->fddiSMTAvailablePaths = MIB_PATH_P | MIB_PATH_S ;
  183. mib->fddiSMTConfigCapabilities = 0 ; /* no hold,no wrap_ab*/
  184. mib->fddiSMTTT_Notify = 10 ;
  185. mib->fddiSMTStatRptPolicy = TRUE ;
  186. mib->fddiSMTTrace_MaxExpiration = SEC2MIB(7) ;
  187. mib->fddiSMTMACIndexes = INDEX_MAC ;
  188. mib->fddiSMTStationStatus = MIB_SMT_STASTA_SEPA ; /* separated */
  189. mib->m[MAC0].fddiMACIndex = INDEX_MAC ;
  190. mib->m[MAC0].fddiMACFrameStatusFunctions = FSC_TYPE0 ;
  191. mib->m[MAC0].fddiMACRequestedPaths =
  192. MIB_P_PATH_LOCAL |
  193. MIB_P_PATH_SEC_ALTER |
  194. MIB_P_PATH_PRIM_ALTER ;
  195. mib->m[MAC0].fddiMACAvailablePaths = MIB_PATH_P ;
  196. mib->m[MAC0].fddiMACCurrentPath = MIB_PATH_PRIMARY ;
  197. mib->m[MAC0].fddiMACT_MaxCapabilitiy = (u_long)(- MS2BCLK(165)) ;
  198. mib->m[MAC0].fddiMACTVXCapabilitiy = (u_long)(- US2BCLK(52)) ;
  199. if (level == 0) {
  200. mib->m[MAC0].fddiMACTvxValue = (u_long)(- US2BCLK(27)) ;
  201. mib->m[MAC0].fddiMACTvxValueMIB = (u_long)(- US2BCLK(27)) ;
  202. mib->m[MAC0].fddiMACT_Req = (u_long)(- MS2BCLK(165)) ;
  203. mib->m[MAC0].fddiMACT_ReqMIB = (u_long)(- MS2BCLK(165)) ;
  204. mib->m[MAC0].fddiMACT_Max = (u_long)(- MS2BCLK(165)) ;
  205. mib->m[MAC0].fddiMACT_MaxMIB = (u_long)(- MS2BCLK(165)) ;
  206. mib->m[MAC0].fddiMACT_Min = (u_long)(- MS2BCLK(4)) ;
  207. }
  208. mib->m[MAC0].fddiMACHardwarePresent = TRUE ;
  209. mib->m[MAC0].fddiMACMA_UnitdataEnable = TRUE ;
  210. mib->m[MAC0].fddiMACFrameErrorThreshold = 1 ;
  211. mib->m[MAC0].fddiMACNotCopiedThreshold = 1 ;
  212. /*
  213. * Path attributes
  214. */
  215. for (path = 0 ; path < NUMPATHS ; path++) {
  216. mib->a[path].fddiPATHIndex = INDEX_PATH + path ;
  217. if (level == 0) {
  218. mib->a[path].fddiPATHTVXLowerBound =
  219. (u_long)(- US2BCLK(27)) ;
  220. mib->a[path].fddiPATHT_MaxLowerBound =
  221. (u_long)(- MS2BCLK(165)) ;
  222. mib->a[path].fddiPATHMaxT_Req =
  223. (u_long)(- MS2BCLK(165)) ;
  224. }
  225. }
  226. /*
  227. * Port attributes
  228. */
  229. pm = mib->p ;
  230. for (port = 0 ; port < NUMPHYS ; port++) {
  231. /*
  232. * set MIB pointer in phy
  233. */
  234. /* Attention: don't initialize mib pointer here! */
  235. /* It must be initialized during phase 2 */
  236. smc->y[port].mib = NULL;
  237. mib->fddiSMTPORTIndexes[port] = port+INDEX_PORT ;
  238. pm->fddiPORTIndex = port+INDEX_PORT ;
  239. pm->fddiPORTHardwarePresent = TRUE ;
  240. if (level == 0) {
  241. pm->fddiPORTLer_Alarm = DEFAULT_LEM_ALARM ;
  242. pm->fddiPORTLer_Cutoff = DEFAULT_LEM_CUTOFF ;
  243. }
  244. /*
  245. * fddiPORTRequestedPaths are set in pcmplc.c
  246. * we don't know the port type yet !
  247. */
  248. pm->fddiPORTRequestedPaths[1] = 0 ;
  249. pm->fddiPORTRequestedPaths[2] = 0 ;
  250. pm->fddiPORTRequestedPaths[3] = 0 ;
  251. pm->fddiPORTAvailablePaths = MIB_PATH_P ;
  252. pm->fddiPORTPMDClass = MIB_PMDCLASS_MULTI ;
  253. pm++ ;
  254. }
  255. (void) smt_set_mac_opvalues(smc) ;
  256. }
  257. int smt_set_mac_opvalues(struct s_smc *smc)
  258. {
  259. int st ;
  260. int st2 ;
  261. st = set_min_max(1,smc->mib.m[MAC0].fddiMACTvxValueMIB,
  262. smc->mib.a[PATH0].fddiPATHTVXLowerBound,
  263. &smc->mib.m[MAC0].fddiMACTvxValue) ;
  264. st |= set_min_max(0,smc->mib.m[MAC0].fddiMACT_MaxMIB,
  265. smc->mib.a[PATH0].fddiPATHT_MaxLowerBound,
  266. &smc->mib.m[MAC0].fddiMACT_Max) ;
  267. st |= (st2 = set_min_max(0,smc->mib.m[MAC0].fddiMACT_ReqMIB,
  268. smc->mib.a[PATH0].fddiPATHMaxT_Req,
  269. &smc->mib.m[MAC0].fddiMACT_Req)) ;
  270. if (st2) {
  271. /* Treq attribute changed remotely. So send an AIX_EVENT to the
  272. * user
  273. */
  274. AIX_EVENT(smc, (u_long) FDDI_RING_STATUS, (u_long)
  275. FDDI_SMT_EVENT, (u_long) FDDI_REMOTE_T_REQ,
  276. smt_get_event_word(smc));
  277. }
  278. return st;
  279. }
  280. void smt_fixup_mib(struct s_smc *smc)
  281. {
  282. #ifdef CONCENTRATOR
  283. switch (smc->s.sas) {
  284. case SMT_SAS :
  285. smc->mib.fddiSMTNonMaster_Ct = 1 ;
  286. break ;
  287. case SMT_DAS :
  288. smc->mib.fddiSMTNonMaster_Ct = 2 ;
  289. break ;
  290. case SMT_NAC :
  291. smc->mib.fddiSMTNonMaster_Ct = 0 ;
  292. break ;
  293. }
  294. smc->mib.fddiSMTMaster_Ct = NUMPHYS - smc->mib.fddiSMTNonMaster_Ct ;
  295. #else
  296. switch (smc->s.sas) {
  297. case SMT_SAS :
  298. smc->mib.fddiSMTNonMaster_Ct = 1 ;
  299. break ;
  300. case SMT_DAS :
  301. smc->mib.fddiSMTNonMaster_Ct = 2 ;
  302. break ;
  303. }
  304. smc->mib.fddiSMTMaster_Ct = 0 ;
  305. #endif
  306. }
  307. /*
  308. * determine new setting for operational value
  309. * if limit is lower than mib
  310. * use limit
  311. * else
  312. * use mib
  313. * NOTE : numbers are negative, negate comparison !
  314. */
  315. static int set_min_max(int maxflag, u_long mib, u_long limit, u_long *oper)
  316. {
  317. u_long old ;
  318. old = *oper ;
  319. if ((limit > mib) ^ maxflag)
  320. *oper = limit ;
  321. else
  322. *oper = mib ;
  323. return old != *oper;
  324. }