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