Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
smtdef.c
Go to the documentation of this file.
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 void smt_reset_defaults(struct s_smc *smc, int level);
76 static void smt_init_mib(struct s_smc *smc, int level);
77 static int set_min_max(int maxflag, u_long mib, u_long limit, u_long *oper);
78 
79 #define MS2BCLK(x) ((x)*12500L)
80 #define US2BCLK(x) ((x)*1250L)
81 
82 void smt_reset_defaults(struct s_smc *smc, int level)
83 {
84  struct smt_config *smt ;
85  int i ;
86  u_long smt_boot_time;
87 
88 
89  smt_init_mib(smc,level) ;
90 
91  smc->os.smc_version = SMC_VERSION ;
92  smt_boot_time = smt_get_time();
93  for( i = 0; i < NUMMACS; i++ )
94  smc->sm.last_tok_time[i] = smt_boot_time ;
95  smt = &smc->s ;
96  smt->attach_s = 0 ;
97  smt->build_ring_map = 1 ;
98  smt->sas = SMT_DAS ;
99  smt->numphys = NUMPHYS ;
100  smt->pcm_tb_min = DEFAULT_TB_MIN ;
101  smt->pcm_tb_max = DEFAULT_TB_MAX ;
102  smt->pcm_c_min = DEFAULT_C_MIN ;
103  smt->pcm_t_out = DEFAULT_T_OUT ;
104  smt->pcm_tl_min = DEFAULT_TL_MIN ;
110  smt->pcm_ns_max = DEFAULT_NS_MAX ;
111  smt->ecm_i_max = DEFAULT_I_MAX ;
112  smt->ecm_in_max = DEFAULT_IN_MAX ;
113  smt->ecm_td_min = DEFAULT_TD_MIN ;
119  smt->rmt_t_jam = DEFAULT_T_JAM ;
121  smt->rmt_t_poll = DEFAULT_POLL ;
122  smt->rmt_dup_mac_behavior = FALSE ; /* See Struct smt_config */
123  smt->mac_d_max = DEFAULT_D_MAX ;
124 
127  smt->lct_long = DEFAULT_LCT_LONG ;
129 
130 #ifndef SLIM_SMT
131 #ifdef ESS
132  if (level == 0) {
133  smc->ess.sync_bw_available = FALSE ;
134  smc->mib.fddiESSPayload = 0 ;
135  smc->mib.fddiESSOverhead = 0 ;
136  smc->mib.fddiESSMaxTNeg = (u_long)(- MS2BCLK(25)) ;
137  smc->mib.fddiESSMinSegmentSize = 1 ;
138  smc->mib.fddiESSCategory = SB_STATIC ;
139  smc->mib.fddiESSSynchTxMode = FALSE ;
140  smc->ess.raf_act_timer_poll = FALSE ;
141  smc->ess.timer_count = 7 ; /* first RAF alc req after 3s */
142  }
143  smc->ess.local_sba_active = FALSE ;
144  smc->ess.sba_reply_pend = NULL ;
145 #endif
146 #ifdef SBA
147  smt_init_sba(smc,level) ;
148 #endif
149 #endif /* no SLIM_SMT */
150 #ifdef TAG_MODE
151  if (level == 0) {
152  smc->hw.pci_fix_value = 0 ;
153  }
154 #endif
155 }
156 
157 /*
158  * manufacturer data
159  */
160 static const char man_data[32] =
161 /* 01234567890123456789012345678901 */
162  "xxxSK-NET FDDI SMT 7.3 - V2.8.8" ;
163 
164 static void smt_init_mib(struct s_smc *smc, int level)
165 {
166  struct fddi_mib *mib ;
167  struct fddi_mib_p *pm ;
168  int port ;
169  int path ;
170 
171  mib = &smc->mib ;
172  if (level == 0) {
173  /*
174  * set EVERYTHING to ZERO
175  * EXCEPT hw and os
176  */
177  memset(((char *)smc)+
178  sizeof(struct s_smt_os)+sizeof(struct s_smt_hw), 0,
179  sizeof(struct s_smc) -
180  sizeof(struct s_smt_os) - sizeof(struct s_smt_hw)) ;
181  }
182  else {
183  mib->fddiSMTRemoteDisconnectFlag = 0 ;
184  mib->fddiSMTPeerWrapFlag = 0 ;
185  }
186 
187  mib->fddiSMTOpVersionId = 2 ;
188  mib->fddiSMTHiVersionId = 2 ;
189  mib->fddiSMTLoVersionId = 2 ;
190  memcpy((char *) mib->fddiSMTManufacturerData,man_data,32) ;
191  if (level == 0) {
193  }
194  mib->fddiSMTMIBVersionId = 1 ;
195  mib->fddiSMTMac_Ct = NUMMACS ;
197 
198  /*
199  * fddiSMTNonMaster_Ct and fddiSMTMaster_Ct are set in smt_fixup_mib
200  * s.sas is not set yet (is set in init driver)
201  */
203 
204  mib->fddiSMTConfigCapabilities = 0 ; /* no hold,no wrap_ab*/
205  mib->fddiSMTTT_Notify = 10 ;
206  mib->fddiSMTStatRptPolicy = TRUE ;
209  mib->fddiSMTStationStatus = MIB_SMT_STASTA_SEPA ; /* separated */
210 
211  mib->m[MAC0].fddiMACIndex = INDEX_MAC ;
212  mib->m[MAC0].fddiMACFrameStatusFunctions = FSC_TYPE0 ;
213  mib->m[MAC0].fddiMACRequestedPaths =
217  mib->m[MAC0].fddiMACAvailablePaths = MIB_PATH_P ;
218  mib->m[MAC0].fddiMACCurrentPath = MIB_PATH_PRIMARY ;
219  mib->m[MAC0].fddiMACT_MaxCapabilitiy = (u_long)(- MS2BCLK(165)) ;
220  mib->m[MAC0].fddiMACTVXCapabilitiy = (u_long)(- US2BCLK(52)) ;
221  if (level == 0) {
222  mib->m[MAC0].fddiMACTvxValue = (u_long)(- US2BCLK(27)) ;
223  mib->m[MAC0].fddiMACTvxValueMIB = (u_long)(- US2BCLK(27)) ;
224  mib->m[MAC0].fddiMACT_Req = (u_long)(- MS2BCLK(165)) ;
225  mib->m[MAC0].fddiMACT_ReqMIB = (u_long)(- MS2BCLK(165)) ;
226  mib->m[MAC0].fddiMACT_Max = (u_long)(- MS2BCLK(165)) ;
227  mib->m[MAC0].fddiMACT_MaxMIB = (u_long)(- MS2BCLK(165)) ;
228  mib->m[MAC0].fddiMACT_Min = (u_long)(- MS2BCLK(4)) ;
229  }
230  mib->m[MAC0].fddiMACHardwarePresent = TRUE ;
231  mib->m[MAC0].fddiMACMA_UnitdataEnable = TRUE ;
232  mib->m[MAC0].fddiMACFrameErrorThreshold = 1 ;
233  mib->m[MAC0].fddiMACNotCopiedThreshold = 1 ;
234  /*
235  * Path attributes
236  */
237  for (path = 0 ; path < NUMPATHS ; path++) {
238  mib->a[path].fddiPATHIndex = INDEX_PATH + path ;
239  if (level == 0) {
240  mib->a[path].fddiPATHTVXLowerBound =
241  (u_long)(- US2BCLK(27)) ;
242  mib->a[path].fddiPATHT_MaxLowerBound =
243  (u_long)(- MS2BCLK(165)) ;
244  mib->a[path].fddiPATHMaxT_Req =
245  (u_long)(- MS2BCLK(165)) ;
246  }
247  }
248 
249 
250  /*
251  * Port attributes
252  */
253  pm = mib->p ;
254  for (port = 0 ; port < NUMPHYS ; port++) {
255  /*
256  * set MIB pointer in phy
257  */
258  /* Attention: don't initialize mib pointer here! */
259  /* It must be initialized during phase 2 */
260  smc->y[port].mib = NULL;
261  mib->fddiSMTPORTIndexes[port] = port+INDEX_PORT ;
262 
263  pm->fddiPORTIndex = port+INDEX_PORT ;
264  pm->fddiPORTHardwarePresent = TRUE ;
265  if (level == 0) {
266  pm->fddiPORTLer_Alarm = DEFAULT_LEM_ALARM ;
267  pm->fddiPORTLer_Cutoff = DEFAULT_LEM_CUTOFF ;
268  }
269  /*
270  * fddiPORTRequestedPaths are set in pcmplc.c
271  * we don't know the port type yet !
272  */
273  pm->fddiPORTRequestedPaths[1] = 0 ;
274  pm->fddiPORTRequestedPaths[2] = 0 ;
275  pm->fddiPORTRequestedPaths[3] = 0 ;
276  pm->fddiPORTAvailablePaths = MIB_PATH_P ;
277  pm->fddiPORTPMDClass = MIB_PMDCLASS_MULTI ;
278  pm++ ;
279  }
280 
281  (void) smt_set_mac_opvalues(smc) ;
282 }
283 
284 int smt_set_mac_opvalues(struct s_smc *smc)
285 {
286  int st ;
287  int st2 ;
288 
289  st = set_min_max(1,smc->mib.m[MAC0].fddiMACTvxValueMIB,
290  smc->mib.a[PATH0].fddiPATHTVXLowerBound,
291  &smc->mib.m[MAC0].fddiMACTvxValue) ;
292  st |= set_min_max(0,smc->mib.m[MAC0].fddiMACT_MaxMIB,
293  smc->mib.a[PATH0].fddiPATHT_MaxLowerBound,
294  &smc->mib.m[MAC0].fddiMACT_Max) ;
295  st |= (st2 = set_min_max(0,smc->mib.m[MAC0].fddiMACT_ReqMIB,
296  smc->mib.a[PATH0].fddiPATHMaxT_Req,
297  &smc->mib.m[MAC0].fddiMACT_Req)) ;
298  if (st2) {
299  /* Treq attribute changed remotely. So send an AIX_EVENT to the
300  * user
301  */
302  AIX_EVENT(smc, (u_long) FDDI_RING_STATUS, (u_long)
303  FDDI_SMT_EVENT, (u_long) FDDI_REMOTE_T_REQ,
304  smt_get_event_word(smc));
305  }
306  return st;
307 }
308 
309 void smt_fixup_mib(struct s_smc *smc)
310 {
311 #ifdef CONCENTRATOR
312  switch (smc->s.sas) {
313  case SMT_SAS :
314  smc->mib.fddiSMTNonMaster_Ct = 1 ;
315  break ;
316  case SMT_DAS :
317  smc->mib.fddiSMTNonMaster_Ct = 2 ;
318  break ;
319  case SMT_NAC :
320  smc->mib.fddiSMTNonMaster_Ct = 0 ;
321  break ;
322  }
323  smc->mib.fddiSMTMaster_Ct = NUMPHYS - smc->mib.fddiSMTNonMaster_Ct ;
324 #else
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  }
333  smc->mib.fddiSMTMaster_Ct = 0 ;
334 #endif
335 }
336 
337 /*
338  * determine new setting for operational value
339  * if limit is lower than mib
340  * use limit
341  * else
342  * use mib
343  * NOTE : numbers are negative, negate comparison !
344  */
345 static int set_min_max(int maxflag, u_long mib, u_long limit, u_long *oper)
346 {
347  u_long old ;
348  old = *oper ;
349  if ((limit > mib) ^ maxflag)
350  *oper = limit ;
351  else
352  *oper = mib ;
353  return old != *oper;
354 }
355