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