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