[ARM] pxa: update defconfig for Verdex Pro
[linux-2.6/verdex.git] / drivers / net / skfp / pmf.c
bloba320fdb3727ded529bd95833c32b50182bccfff6
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 Parameter Management Frame processing for SMT 7.2
21 #include "h/types.h"
22 #include "h/fddi.h"
23 #include "h/smc.h"
24 #include "h/smt_p.h"
26 #define KERNEL
27 #include "h/smtstate.h"
29 #ifndef SLIM_SMT
31 #ifndef lint
32 static const char ID_sccs[] = "@(#)pmf.c 1.37 97/08/04 (C) SK " ;
33 #endif
35 static int smt_authorize(struct s_smc *smc, struct smt_header *sm);
36 static int smt_check_set_count(struct s_smc *smc, struct smt_header *sm);
37 static const struct s_p_tab* smt_get_ptab(u_short para);
38 static int smt_mib_phys(struct s_smc *smc);
39 static int smt_set_para(struct s_smc *smc, struct smt_para *pa, int index,
40 int local, int set);
41 void smt_add_para(struct s_smc *smc, struct s_pcon *pcon, u_short para,
42 int index, int local);
43 static SMbuf *smt_build_pmf_response(struct s_smc *smc, struct smt_header *req,
44 int set, int local);
45 static int port_to_mib(struct s_smc *smc, int p);
47 #define MOFFSS(e) offsetof(struct fddi_mib, e)
48 #define MOFFMS(e) offsetof(struct fddi_mib_m, e)
49 #define MOFFAS(e) offsetof(struct fddi_mib_a, e)
50 #define MOFFPS(e) offsetof(struct fddi_mib_p, e)
53 #define AC_G 0x01 /* Get */
54 #define AC_GR 0x02 /* Get/Set */
55 #define AC_S 0x04 /* Set */
56 #define AC_NA 0x08
57 #define AC_GROUP 0x10 /* Group */
58 #define MS2BCLK(x) ((x)*12500L)
60 F LFag (byte)
61 B byte
62 S u_short 16 bit
63 C Counter 32 bit
64 L Long 32 bit
65 T Timer_2 32 bit
66 P TimeStamp ;
67 A LongAddress (6 byte)
68 E Enum 16 bit
69 R ResId 16 Bit
71 static const struct s_p_tab {
72 u_short p_num ; /* parameter code */
73 u_char p_access ; /* access rights */
74 u_short p_offset ; /* offset in mib */
75 char p_swap[3] ; /* format string */
76 } p_tab[] = {
77 /* StationIdGrp */
78 { SMT_P100A,AC_GROUP } ,
79 { SMT_P100B,AC_G, MOFFSS(fddiSMTStationId), "8" } ,
80 { SMT_P100D,AC_G, MOFFSS(fddiSMTOpVersionId), "S" } ,
81 { SMT_P100E,AC_G, MOFFSS(fddiSMTHiVersionId), "S" } ,
82 { SMT_P100F,AC_G, MOFFSS(fddiSMTLoVersionId), "S" } ,
83 { SMT_P1010,AC_G, MOFFSS(fddiSMTManufacturerData), "D" } ,
84 { SMT_P1011,AC_GR, MOFFSS(fddiSMTUserData), "D" } ,
85 { SMT_P1012,AC_G, MOFFSS(fddiSMTMIBVersionId), "S" } ,
87 /* StationConfigGrp */
88 { SMT_P1014,AC_GROUP } ,
89 { SMT_P1015,AC_G, MOFFSS(fddiSMTMac_Ct), "B" } ,
90 { SMT_P1016,AC_G, MOFFSS(fddiSMTNonMaster_Ct), "B" } ,
91 { SMT_P1017,AC_G, MOFFSS(fddiSMTMaster_Ct), "B" } ,
92 { SMT_P1018,AC_G, MOFFSS(fddiSMTAvailablePaths), "B" } ,
93 { SMT_P1019,AC_G, MOFFSS(fddiSMTConfigCapabilities),"S" } ,
94 { SMT_P101A,AC_GR, MOFFSS(fddiSMTConfigPolicy), "wS" } ,
95 { SMT_P101B,AC_GR, MOFFSS(fddiSMTConnectionPolicy),"wS" } ,
96 { SMT_P101D,AC_GR, MOFFSS(fddiSMTTT_Notify), "wS" } ,
97 { SMT_P101E,AC_GR, MOFFSS(fddiSMTStatRptPolicy), "bB" } ,
98 { SMT_P101F,AC_GR, MOFFSS(fddiSMTTrace_MaxExpiration),"lL" } ,
99 { SMT_P1020,AC_G, MOFFSS(fddiSMTPORTIndexes), "II" } ,
100 { SMT_P1021,AC_G, MOFFSS(fddiSMTMACIndexes), "I" } ,
101 { SMT_P1022,AC_G, MOFFSS(fddiSMTBypassPresent), "F" } ,
103 /* StatusGrp */
104 { SMT_P1028,AC_GROUP } ,
105 { SMT_P1029,AC_G, MOFFSS(fddiSMTECMState), "E" } ,
106 { SMT_P102A,AC_G, MOFFSS(fddiSMTCF_State), "E" } ,
107 { SMT_P102C,AC_G, MOFFSS(fddiSMTRemoteDisconnectFlag),"F" } ,
108 { SMT_P102D,AC_G, MOFFSS(fddiSMTStationStatus), "E" } ,
109 { SMT_P102E,AC_G, MOFFSS(fddiSMTPeerWrapFlag), "F" } ,
111 /* MIBOperationGrp */
112 { SMT_P1032,AC_GROUP } ,
113 { SMT_P1033,AC_G, MOFFSS(fddiSMTTimeStamp),"P" } ,
114 { SMT_P1034,AC_G, MOFFSS(fddiSMTTransitionTimeStamp),"P" } ,
115 /* NOTE : SMT_P1035 is already swapped ! SMT_P_SETCOUNT */
116 { SMT_P1035,AC_G, MOFFSS(fddiSMTSetCount),"4P" } ,
117 { SMT_P1036,AC_G, MOFFSS(fddiSMTLastSetStationId),"8" } ,
119 { SMT_P103C,AC_S, 0, "wS" } ,
122 * PRIVATE EXTENSIONS
123 * only accessible locally to get/set passwd
125 { SMT_P10F0,AC_GR, MOFFSS(fddiPRPMFPasswd), "8" } ,
126 { SMT_P10F1,AC_GR, MOFFSS(fddiPRPMFStation), "8" } ,
127 #ifdef ESS
128 { SMT_P10F2,AC_GR, MOFFSS(fddiESSPayload), "lL" } ,
129 { SMT_P10F3,AC_GR, MOFFSS(fddiESSOverhead), "lL" } ,
130 { SMT_P10F4,AC_GR, MOFFSS(fddiESSMaxTNeg), "lL" } ,
131 { SMT_P10F5,AC_GR, MOFFSS(fddiESSMinSegmentSize), "lL" } ,
132 { SMT_P10F6,AC_GR, MOFFSS(fddiESSCategory), "lL" } ,
133 { SMT_P10F7,AC_GR, MOFFSS(fddiESSSynchTxMode), "wS" } ,
134 #endif
135 #ifdef SBA
136 { SMT_P10F8,AC_GR, MOFFSS(fddiSBACommand), "bF" } ,
137 { SMT_P10F9,AC_GR, MOFFSS(fddiSBAAvailable), "bF" } ,
138 #endif
139 /* MAC Attributes */
140 { SMT_P200A,AC_GROUP } ,
141 { SMT_P200B,AC_G, MOFFMS(fddiMACFrameStatusFunctions),"S" } ,
142 { SMT_P200D,AC_G, MOFFMS(fddiMACT_MaxCapabilitiy),"T" } ,
143 { SMT_P200E,AC_G, MOFFMS(fddiMACTVXCapabilitiy),"T" } ,
145 /* ConfigGrp */
146 { SMT_P2014,AC_GROUP } ,
147 { SMT_P2016,AC_G, MOFFMS(fddiMACAvailablePaths), "B" } ,
148 { SMT_P2017,AC_G, MOFFMS(fddiMACCurrentPath), "S" } ,
149 { SMT_P2018,AC_G, MOFFMS(fddiMACUpstreamNbr), "A" } ,
150 { SMT_P2019,AC_G, MOFFMS(fddiMACDownstreamNbr), "A" } ,
151 { SMT_P201A,AC_G, MOFFMS(fddiMACOldUpstreamNbr), "A" } ,
152 { SMT_P201B,AC_G, MOFFMS(fddiMACOldDownstreamNbr),"A" } ,
153 { SMT_P201D,AC_G, MOFFMS(fddiMACDupAddressTest), "E" } ,
154 { SMT_P2020,AC_GR, MOFFMS(fddiMACRequestedPaths), "wS" } ,
155 { SMT_P2021,AC_G, MOFFMS(fddiMACDownstreamPORTType),"E" } ,
156 { SMT_P2022,AC_G, MOFFMS(fddiMACIndex), "S" } ,
158 /* AddressGrp */
159 { SMT_P2028,AC_GROUP } ,
160 { SMT_P2029,AC_G, MOFFMS(fddiMACSMTAddress), "A" } ,
162 /* OperationGrp */
163 { SMT_P2032,AC_GROUP } ,
164 { SMT_P2033,AC_G, MOFFMS(fddiMACT_Req), "T" } ,
165 { SMT_P2034,AC_G, MOFFMS(fddiMACT_Neg), "T" } ,
166 { SMT_P2035,AC_G, MOFFMS(fddiMACT_Max), "T" } ,
167 { SMT_P2036,AC_G, MOFFMS(fddiMACTvxValue), "T" } ,
168 { SMT_P2038,AC_G, MOFFMS(fddiMACT_Pri0), "T" } ,
169 { SMT_P2039,AC_G, MOFFMS(fddiMACT_Pri1), "T" } ,
170 { SMT_P203A,AC_G, MOFFMS(fddiMACT_Pri2), "T" } ,
171 { SMT_P203B,AC_G, MOFFMS(fddiMACT_Pri3), "T" } ,
172 { SMT_P203C,AC_G, MOFFMS(fddiMACT_Pri4), "T" } ,
173 { SMT_P203D,AC_G, MOFFMS(fddiMACT_Pri5), "T" } ,
174 { SMT_P203E,AC_G, MOFFMS(fddiMACT_Pri6), "T" } ,
177 /* CountersGrp */
178 { SMT_P2046,AC_GROUP } ,
179 { SMT_P2047,AC_G, MOFFMS(fddiMACFrame_Ct), "C" } ,
180 { SMT_P2048,AC_G, MOFFMS(fddiMACCopied_Ct), "C" } ,
181 { SMT_P2049,AC_G, MOFFMS(fddiMACTransmit_Ct), "C" } ,
182 { SMT_P204A,AC_G, MOFFMS(fddiMACToken_Ct), "C" } ,
183 { SMT_P2051,AC_G, MOFFMS(fddiMACError_Ct), "C" } ,
184 { SMT_P2052,AC_G, MOFFMS(fddiMACLost_Ct), "C" } ,
185 { SMT_P2053,AC_G, MOFFMS(fddiMACTvxExpired_Ct), "C" } ,
186 { SMT_P2054,AC_G, MOFFMS(fddiMACNotCopied_Ct), "C" } ,
187 { SMT_P2056,AC_G, MOFFMS(fddiMACRingOp_Ct), "C" } ,
189 /* FrameErrorConditionGrp */
190 { SMT_P205A,AC_GROUP } ,
191 { SMT_P205F,AC_GR, MOFFMS(fddiMACFrameErrorThreshold),"wS" } ,
192 { SMT_P2060,AC_G, MOFFMS(fddiMACFrameErrorRatio), "S" } ,
194 /* NotCopiedConditionGrp */
195 { SMT_P2064,AC_GROUP } ,
196 { SMT_P2067,AC_GR, MOFFMS(fddiMACNotCopiedThreshold),"wS" } ,
197 { SMT_P2069,AC_G, MOFFMS(fddiMACNotCopiedRatio), "S" } ,
199 /* StatusGrp */
200 { SMT_P206E,AC_GROUP } ,
201 { SMT_P206F,AC_G, MOFFMS(fddiMACRMTState), "S" } ,
202 { SMT_P2070,AC_G, MOFFMS(fddiMACDA_Flag), "F" } ,
203 { SMT_P2071,AC_G, MOFFMS(fddiMACUNDA_Flag), "F" } ,
204 { SMT_P2072,AC_G, MOFFMS(fddiMACFrameErrorFlag), "F" } ,
205 { SMT_P2073,AC_G, MOFFMS(fddiMACNotCopiedFlag), "F" } ,
206 { SMT_P2074,AC_G, MOFFMS(fddiMACMA_UnitdataAvailable),"F" } ,
207 { SMT_P2075,AC_G, MOFFMS(fddiMACHardwarePresent), "F" } ,
208 { SMT_P2076,AC_GR, MOFFMS(fddiMACMA_UnitdataEnable),"bF" } ,
211 * PRIVATE EXTENSIONS
212 * only accessible locally to get/set TMIN
214 { SMT_P20F0,AC_NA } ,
215 { SMT_P20F1,AC_GR, MOFFMS(fddiMACT_Min), "lT" } ,
217 /* Path Attributes */
219 * DON't swap 320B,320F,3210: they are already swapped in swap_para()
221 { SMT_P320A,AC_GROUP } ,
222 { SMT_P320B,AC_G, MOFFAS(fddiPATHIndex), "r" } ,
223 { SMT_P320F,AC_GR, MOFFAS(fddiPATHSbaPayload), "l4" } ,
224 { SMT_P3210,AC_GR, MOFFAS(fddiPATHSbaOverhead), "l4" } ,
225 /* fddiPATHConfiguration */
226 { SMT_P3212,AC_G, 0, "" } ,
227 { SMT_P3213,AC_GR, MOFFAS(fddiPATHT_Rmode), "lT" } ,
228 { SMT_P3214,AC_GR, MOFFAS(fddiPATHSbaAvailable), "lL" } ,
229 { SMT_P3215,AC_GR, MOFFAS(fddiPATHTVXLowerBound), "lT" } ,
230 { SMT_P3216,AC_GR, MOFFAS(fddiPATHT_MaxLowerBound),"lT" } ,
231 { SMT_P3217,AC_GR, MOFFAS(fddiPATHMaxT_Req), "lT" } ,
233 /* Port Attributes */
234 /* ConfigGrp */
235 { SMT_P400A,AC_GROUP } ,
236 { SMT_P400C,AC_G, MOFFPS(fddiPORTMy_Type), "E" } ,
237 { SMT_P400D,AC_G, MOFFPS(fddiPORTNeighborType), "E" } ,
238 { SMT_P400E,AC_GR, MOFFPS(fddiPORTConnectionPolicies),"bB" } ,
239 { SMT_P400F,AC_G, MOFFPS(fddiPORTMacIndicated), "2" } ,
240 { SMT_P4010,AC_G, MOFFPS(fddiPORTCurrentPath), "E" } ,
241 { SMT_P4011,AC_GR, MOFFPS(fddiPORTRequestedPaths), "l4" } ,
242 { SMT_P4012,AC_G, MOFFPS(fddiPORTMACPlacement), "S" } ,
243 { SMT_P4013,AC_G, MOFFPS(fddiPORTAvailablePaths), "B" } ,
244 { SMT_P4016,AC_G, MOFFPS(fddiPORTPMDClass), "E" } ,
245 { SMT_P4017,AC_G, MOFFPS(fddiPORTConnectionCapabilities), "B"} ,
246 { SMT_P401D,AC_G, MOFFPS(fddiPORTIndex), "R" } ,
248 /* OperationGrp */
249 { SMT_P401E,AC_GROUP } ,
250 { SMT_P401F,AC_GR, MOFFPS(fddiPORTMaint_LS), "wE" } ,
251 { SMT_P4021,AC_G, MOFFPS(fddiPORTBS_Flag), "F" } ,
252 { SMT_P4022,AC_G, MOFFPS(fddiPORTPC_LS), "E" } ,
254 /* ErrorCtrsGrp */
255 { SMT_P4028,AC_GROUP } ,
256 { SMT_P4029,AC_G, MOFFPS(fddiPORTEBError_Ct), "C" } ,
257 { SMT_P402A,AC_G, MOFFPS(fddiPORTLCTFail_Ct), "C" } ,
259 /* LerGrp */
260 { SMT_P4032,AC_GROUP } ,
261 { SMT_P4033,AC_G, MOFFPS(fddiPORTLer_Estimate), "F" } ,
262 { SMT_P4034,AC_G, MOFFPS(fddiPORTLem_Reject_Ct), "C" } ,
263 { SMT_P4035,AC_G, MOFFPS(fddiPORTLem_Ct), "C" } ,
264 { SMT_P403A,AC_GR, MOFFPS(fddiPORTLer_Cutoff), "bB" } ,
265 { SMT_P403B,AC_GR, MOFFPS(fddiPORTLer_Alarm), "bB" } ,
267 /* StatusGrp */
268 { SMT_P403C,AC_GROUP } ,
269 { SMT_P403D,AC_G, MOFFPS(fddiPORTConnectState), "E" } ,
270 { SMT_P403E,AC_G, MOFFPS(fddiPORTPCMStateX), "E" } ,
271 { SMT_P403F,AC_G, MOFFPS(fddiPORTPC_Withhold), "E" } ,
272 { SMT_P4040,AC_G, MOFFPS(fddiPORTLerFlag), "F" } ,
273 { SMT_P4041,AC_G, MOFFPS(fddiPORTHardwarePresent),"F" } ,
275 { SMT_P4046,AC_S, 0, "wS" } ,
277 { 0, AC_GROUP } ,
278 { 0 }
281 void smt_pmf_received_pack(struct s_smc *smc, SMbuf *mb, int local)
283 struct smt_header *sm ;
284 SMbuf *reply ;
286 sm = smtod(mb,struct smt_header *) ;
287 DB_SMT("SMT: processing PMF frame at %x len %d\n",sm,mb->sm_len) ;
288 #ifdef DEBUG
289 dump_smt(smc,sm,"PMF Received") ;
290 #endif
292 * Start the watchdog: It may be a long, long packet and
293 * maybe the watchdog occurs ...
295 smt_start_watchdog(smc) ;
297 if (sm->smt_class == SMT_PMF_GET ||
298 sm->smt_class == SMT_PMF_SET) {
299 reply = smt_build_pmf_response(smc,sm,
300 sm->smt_class == SMT_PMF_SET,local) ;
301 if (reply) {
302 sm = smtod(reply,struct smt_header *) ;
303 #ifdef DEBUG
304 dump_smt(smc,sm,"PMF Reply") ;
305 #endif
306 smt_send_frame(smc,reply,FC_SMT_INFO,local) ;
311 static SMbuf *smt_build_pmf_response(struct s_smc *smc, struct smt_header *req,
312 int set, int local)
314 SMbuf *mb ;
315 struct smt_header *smt ;
316 struct smt_para *pa ;
317 struct smt_p_reason *res ;
318 const struct s_p_tab *pt ;
319 int len ;
320 int index ;
321 int idx_end ;
322 int error ;
323 int range ;
324 SK_LOC_DECL(struct s_pcon,pcon) ;
325 SK_LOC_DECL(struct s_pcon,set_pcon) ;
328 * build SMT header
330 if (!(mb = smt_get_mbuf(smc)))
331 return(mb) ;
333 smt = smtod(mb, struct smt_header *) ;
334 smt->smt_dest = req->smt_source ; /* DA == source of request */
335 smt->smt_class = req->smt_class ; /* same class (GET/SET) */
336 smt->smt_type = SMT_REPLY ;
337 smt->smt_version = SMT_VID_2 ;
338 smt->smt_tid = req->smt_tid ; /* same TID */
339 smt->smt_pad = 0 ;
340 smt->smt_len = 0 ;
343 * setup parameter status
345 pcon.pc_len = SMT_MAX_INFO_LEN ; /* max para length */
346 pcon.pc_err = 0 ; /* no error */
347 pcon.pc_badset = 0 ; /* no bad set count */
348 pcon.pc_p = (void *) (smt + 1) ; /* paras start here */
351 * check authoriziation and set count
353 error = 0 ;
354 if (set) {
355 if (!local && smt_authorize(smc,req))
356 error = SMT_RDF_AUTHOR ;
357 else if (smt_check_set_count(smc,req))
358 pcon.pc_badset = SMT_RDF_BADSET ;
361 * add reason code and all mandatory parameters
363 res = (struct smt_p_reason *) pcon.pc_p ;
364 smt_add_para(smc,&pcon,(u_short) SMT_P_REASON,0,0) ;
365 smt_add_para(smc,&pcon,(u_short) SMT_P1033,0,0) ;
366 /* update 1035 and 1036 later if set */
367 set_pcon = pcon ;
368 smt_add_para(smc,&pcon,(u_short) SMT_P1035,0,0) ;
369 smt_add_para(smc,&pcon,(u_short) SMT_P1036,0,0) ;
371 pcon.pc_err = error ;
372 len = req->smt_len ;
373 pa = (struct smt_para *) (req + 1) ;
375 * process list of paras
377 while (!pcon.pc_err && len > 0 ) {
378 if (((u_short)len < pa->p_len + PARA_LEN) || (pa->p_len & 3)) {
379 pcon.pc_err = SMT_RDF_LENGTH ;
380 break ;
383 if (((range = (pa->p_type & 0xf000)) == 0x2000) ||
384 range == 0x3000 || range == 0x4000) {
386 * get index for PART,MAC ad PATH group
388 index = *((u_char *)pa + PARA_LEN + 3) ;/* index */
389 idx_end = index ;
390 if (!set && (pa->p_len != 4)) {
391 pcon.pc_err = SMT_RDF_LENGTH ;
392 break ;
394 if (!index && !set) {
395 switch (range) {
396 case 0x2000 :
397 index = INDEX_MAC ;
398 idx_end = index - 1 + NUMMACS ;
399 break ;
400 case 0x3000 :
401 index = INDEX_PATH ;
402 idx_end = index - 1 + NUMPATHS ;
403 break ;
404 case 0x4000 :
405 index = INDEX_PORT ;
406 idx_end = index - 1 + NUMPHYS ;
407 #ifndef CONCENTRATOR
408 if (smc->s.sas == SMT_SAS)
409 idx_end = INDEX_PORT ;
410 #endif
411 break ;
415 else {
417 * smt group has no index
419 if (!set && (pa->p_len != 0)) {
420 pcon.pc_err = SMT_RDF_LENGTH ;
421 break ;
423 index = 0 ;
424 idx_end = 0 ;
426 while (index <= idx_end) {
428 * if group
429 * add all paras of group
431 pt = smt_get_ptab(pa->p_type) ;
432 if (pt && pt->p_access == AC_GROUP && !set) {
433 pt++ ;
434 while (pt->p_access == AC_G ||
435 pt->p_access == AC_GR) {
436 smt_add_para(smc,&pcon,pt->p_num,
437 index,local);
438 pt++ ;
442 * ignore
443 * AUTHORIZATION in get/set
444 * SET COUNT in set
446 else if (pa->p_type != SMT_P_AUTHOR &&
447 (!set || (pa->p_type != SMT_P1035))) {
448 int st ;
449 if (pcon.pc_badset) {
450 smt_add_para(smc,&pcon,pa->p_type,
451 index,local) ;
453 else if (set) {
454 st = smt_set_para(smc,pa,index,local,1);
456 * return para even if error
458 smt_add_para(smc,&pcon,pa->p_type,
459 index,local) ;
460 pcon.pc_err = st ;
462 else {
463 if (pt && pt->p_access == AC_S) {
464 pcon.pc_err =
465 SMT_RDF_ILLEGAL ;
467 smt_add_para(smc,&pcon,pa->p_type,
468 index,local) ;
471 if (pcon.pc_err)
472 break ;
473 index++ ;
475 len -= pa->p_len + PARA_LEN ;
476 pa = (struct smt_para *) ((char *)pa + pa->p_len + PARA_LEN) ;
478 smt->smt_len = SMT_MAX_INFO_LEN - pcon.pc_len ;
479 mb->sm_len = smt->smt_len + sizeof(struct smt_header) ;
481 /* update reason code */
482 res->rdf_reason = pcon.pc_badset ? pcon.pc_badset :
483 pcon.pc_err ? pcon.pc_err : SMT_RDF_SUCCESS ;
484 if (set && (res->rdf_reason == SMT_RDF_SUCCESS)) {
486 * increment set count
487 * set time stamp
488 * store station id of last set
490 smc->mib.fddiSMTSetCount.count++ ;
491 smt_set_timestamp(smc,smc->mib.fddiSMTSetCount.timestamp) ;
492 smc->mib.fddiSMTLastSetStationId = req->smt_sid ;
493 smt_add_para(smc,&set_pcon,(u_short) SMT_P1035,0,0) ;
494 smt_add_para(smc,&set_pcon,(u_short) SMT_P1036,0,0) ;
496 return(mb) ;
499 static int smt_authorize(struct s_smc *smc, struct smt_header *sm)
501 struct smt_para *pa ;
502 int i ;
503 char *p ;
506 * check source station id if not zero
508 p = (char *) &smc->mib.fddiPRPMFStation ;
509 for (i = 0 ; i < 8 && !p[i] ; i++)
511 if (i != 8) {
512 if (memcmp((char *) &sm->smt_sid,
513 (char *) &smc->mib.fddiPRPMFStation,8))
514 return(1) ;
517 * check authoriziation parameter if passwd not zero
519 p = (char *) smc->mib.fddiPRPMFPasswd ;
520 for (i = 0 ; i < 8 && !p[i] ; i++)
522 if (i != 8) {
523 pa = (struct smt_para *) sm_to_para(smc,sm,SMT_P_AUTHOR) ;
524 if (!pa)
525 return(1) ;
526 if (pa->p_len != 8)
527 return(1) ;
528 if (memcmp((char *)(pa+1),(char *)smc->mib.fddiPRPMFPasswd,8))
529 return(1) ;
531 return(0) ;
534 static int smt_check_set_count(struct s_smc *smc, struct smt_header *sm)
536 struct smt_para *pa ;
537 struct smt_p_setcount *sc ;
539 pa = (struct smt_para *) sm_to_para(smc,sm,SMT_P1035) ;
540 if (pa) {
541 sc = (struct smt_p_setcount *) pa ;
542 if ((smc->mib.fddiSMTSetCount.count != sc->count) ||
543 memcmp((char *) smc->mib.fddiSMTSetCount.timestamp,
544 (char *)sc->timestamp,8))
545 return(1) ;
547 return(0) ;
550 void smt_add_para(struct s_smc *smc, struct s_pcon *pcon, u_short para,
551 int index, int local)
553 struct smt_para *pa ;
554 const struct s_p_tab *pt ;
555 struct fddi_mib_m *mib_m = NULL;
556 struct fddi_mib_p *mib_p = NULL;
557 int len ;
558 int plen ;
559 char *from ;
560 char *to ;
561 const char *swap ;
562 char c ;
563 int range ;
564 char *mib_addr ;
565 int mac ;
566 int path ;
567 int port ;
568 int sp_len ;
571 * skip if error
573 if (pcon->pc_err)
574 return ;
577 * actions don't have a value
579 pt = smt_get_ptab(para) ;
580 if (pt && pt->p_access == AC_S)
581 return ;
583 to = (char *) (pcon->pc_p) ; /* destination pointer */
584 len = pcon->pc_len ; /* free space */
585 plen = len ; /* remember start length */
586 pa = (struct smt_para *) to ; /* type/length pointer */
587 to += PARA_LEN ; /* skip smt_para */
588 len -= PARA_LEN ;
590 * set index if required
592 if (((range = (para & 0xf000)) == 0x2000) ||
593 range == 0x3000 || range == 0x4000) {
594 if (len < 4)
595 goto wrong_error ;
596 to[0] = 0 ;
597 to[1] = 0 ;
598 to[2] = 0 ;
599 to[3] = index ;
600 len -= 4 ;
601 to += 4 ;
603 mac = index - INDEX_MAC ;
604 path = index - INDEX_PATH ;
605 port = index - INDEX_PORT ;
607 * get pointer to mib
609 switch (range) {
610 case 0x1000 :
611 default :
612 mib_addr = (char *) (&smc->mib) ;
613 break ;
614 case 0x2000 :
615 if (mac < 0 || mac >= NUMMACS) {
616 pcon->pc_err = SMT_RDF_NOPARAM ;
617 return ;
619 mib_addr = (char *) (&smc->mib.m[mac]) ;
620 mib_m = (struct fddi_mib_m *) mib_addr ;
621 break ;
622 case 0x3000 :
623 if (path < 0 || path >= NUMPATHS) {
624 pcon->pc_err = SMT_RDF_NOPARAM ;
625 return ;
627 mib_addr = (char *) (&smc->mib.a[path]) ;
628 break ;
629 case 0x4000 :
630 if (port < 0 || port >= smt_mib_phys(smc)) {
631 pcon->pc_err = SMT_RDF_NOPARAM ;
632 return ;
634 mib_addr = (char *) (&smc->mib.p[port_to_mib(smc,port)]) ;
635 mib_p = (struct fddi_mib_p *) mib_addr ;
636 break ;
639 * check special paras
641 swap = NULL;
642 switch (para) {
643 case SMT_P10F0 :
644 case SMT_P10F1 :
645 #ifdef ESS
646 case SMT_P10F2 :
647 case SMT_P10F3 :
648 case SMT_P10F4 :
649 case SMT_P10F5 :
650 case SMT_P10F6 :
651 case SMT_P10F7 :
652 #endif
653 #ifdef SBA
654 case SMT_P10F8 :
655 case SMT_P10F9 :
656 #endif
657 case SMT_P20F1 :
658 if (!local) {
659 pcon->pc_err = SMT_RDF_NOPARAM ;
660 return ;
662 break ;
663 case SMT_P2034 :
664 case SMT_P2046 :
665 case SMT_P2047 :
666 case SMT_P204A :
667 case SMT_P2051 :
668 case SMT_P2052 :
669 mac_update_counter(smc) ;
670 break ;
671 case SMT_P4022:
672 mib_p->fddiPORTPC_LS = LS2MIB(
673 sm_pm_get_ls(smc,port_to_mib(smc,port))) ;
674 break ;
675 case SMT_P_REASON :
676 * (u_long *) to = 0 ;
677 sp_len = 4 ;
678 goto sp_done ;
679 case SMT_P1033 : /* time stamp */
680 smt_set_timestamp(smc,smc->mib.fddiSMTTimeStamp) ;
681 break ;
683 case SMT_P1020: /* port indexes */
684 #if NUMPHYS == 12
685 swap = "IIIIIIIIIIII" ;
686 #else
687 #if NUMPHYS == 2
688 if (smc->s.sas == SMT_SAS)
689 swap = "I" ;
690 else
691 swap = "II" ;
692 #else
693 #if NUMPHYS == 24
694 swap = "IIIIIIIIIIIIIIIIIIIIIIII" ;
695 #else
696 ????
697 #endif
698 #endif
699 #endif
700 break ;
701 case SMT_P3212 :
703 sp_len = cem_build_path(smc,to,path) ;
704 goto sp_done ;
706 case SMT_P1048 : /* peer wrap condition */
708 struct smt_p_1048 *sp ;
709 sp = (struct smt_p_1048 *) to ;
710 sp->p1048_flag = smc->mib.fddiSMTPeerWrapFlag ;
711 sp->p1048_cf_state = smc->mib.fddiSMTCF_State ;
712 sp_len = sizeof(struct smt_p_1048) ;
713 goto sp_done ;
715 case SMT_P208C :
717 struct smt_p_208c *sp ;
718 sp = (struct smt_p_208c *) to ;
719 sp->p208c_flag =
720 smc->mib.m[MAC0].fddiMACDuplicateAddressCond ;
721 sp->p208c_dupcondition =
722 (mib_m->fddiMACDA_Flag ? SMT_ST_MY_DUPA : 0) |
723 (mib_m->fddiMACUNDA_Flag ? SMT_ST_UNA_DUPA : 0);
724 sp->p208c_fddilong =
725 mib_m->fddiMACSMTAddress ;
726 sp->p208c_fddiunalong =
727 mib_m->fddiMACUpstreamNbr ;
728 sp->p208c_pad = 0 ;
729 sp_len = sizeof(struct smt_p_208c) ;
730 goto sp_done ;
732 case SMT_P208D : /* frame error condition */
734 struct smt_p_208d *sp ;
735 sp = (struct smt_p_208d *) to ;
736 sp->p208d_flag =
737 mib_m->fddiMACFrameErrorFlag ;
738 sp->p208d_frame_ct =
739 mib_m->fddiMACFrame_Ct ;
740 sp->p208d_error_ct =
741 mib_m->fddiMACError_Ct ;
742 sp->p208d_lost_ct =
743 mib_m->fddiMACLost_Ct ;
744 sp->p208d_ratio =
745 mib_m->fddiMACFrameErrorRatio ;
746 sp_len = sizeof(struct smt_p_208d) ;
747 goto sp_done ;
749 case SMT_P208E : /* not copied condition */
751 struct smt_p_208e *sp ;
752 sp = (struct smt_p_208e *) to ;
753 sp->p208e_flag =
754 mib_m->fddiMACNotCopiedFlag ;
755 sp->p208e_not_copied =
756 mib_m->fddiMACNotCopied_Ct ;
757 sp->p208e_copied =
758 mib_m->fddiMACCopied_Ct ;
759 sp->p208e_not_copied_ratio =
760 mib_m->fddiMACNotCopiedRatio ;
761 sp_len = sizeof(struct smt_p_208e) ;
762 goto sp_done ;
764 case SMT_P208F : /* neighbor change event */
766 struct smt_p_208f *sp ;
767 sp = (struct smt_p_208f *) to ;
768 sp->p208f_multiple =
769 mib_m->fddiMACMultiple_N ;
770 sp->p208f_nacondition =
771 mib_m->fddiMACDuplicateAddressCond ;
772 sp->p208f_old_una =
773 mib_m->fddiMACOldUpstreamNbr ;
774 sp->p208f_new_una =
775 mib_m->fddiMACUpstreamNbr ;
776 sp->p208f_old_dna =
777 mib_m->fddiMACOldDownstreamNbr ;
778 sp->p208f_new_dna =
779 mib_m->fddiMACDownstreamNbr ;
780 sp->p208f_curren_path =
781 mib_m->fddiMACCurrentPath ;
782 sp->p208f_smt_address =
783 mib_m->fddiMACSMTAddress ;
784 sp_len = sizeof(struct smt_p_208f) ;
785 goto sp_done ;
787 case SMT_P2090 :
789 struct smt_p_2090 *sp ;
790 sp = (struct smt_p_2090 *) to ;
791 sp->p2090_multiple =
792 mib_m->fddiMACMultiple_P ;
793 sp->p2090_availablepaths =
794 mib_m->fddiMACAvailablePaths ;
795 sp->p2090_currentpath =
796 mib_m->fddiMACCurrentPath ;
797 sp->p2090_requestedpaths =
798 mib_m->fddiMACRequestedPaths ;
799 sp_len = sizeof(struct smt_p_2090) ;
800 goto sp_done ;
802 case SMT_P4050 :
804 struct smt_p_4050 *sp ;
805 sp = (struct smt_p_4050 *) to ;
806 sp->p4050_flag =
807 mib_p->fddiPORTLerFlag ;
808 sp->p4050_pad = 0 ;
809 sp->p4050_cutoff =
810 mib_p->fddiPORTLer_Cutoff ;
811 sp->p4050_alarm =
812 mib_p->fddiPORTLer_Alarm ;
813 sp->p4050_estimate =
814 mib_p->fddiPORTLer_Estimate ;
815 sp->p4050_reject_ct =
816 mib_p->fddiPORTLem_Reject_Ct ;
817 sp->p4050_ct =
818 mib_p->fddiPORTLem_Ct ;
819 sp_len = sizeof(struct smt_p_4050) ;
820 goto sp_done ;
823 case SMT_P4051 :
825 struct smt_p_4051 *sp ;
826 sp = (struct smt_p_4051 *) to ;
827 sp->p4051_multiple =
828 mib_p->fddiPORTMultiple_U ;
829 sp->p4051_porttype =
830 mib_p->fddiPORTMy_Type ;
831 sp->p4051_connectstate =
832 mib_p->fddiPORTConnectState ;
833 sp->p4051_pc_neighbor =
834 mib_p->fddiPORTNeighborType ;
835 sp->p4051_pc_withhold =
836 mib_p->fddiPORTPC_Withhold ;
837 sp_len = sizeof(struct smt_p_4051) ;
838 goto sp_done ;
840 case SMT_P4052 :
842 struct smt_p_4052 *sp ;
843 sp = (struct smt_p_4052 *) to ;
844 sp->p4052_flag =
845 mib_p->fddiPORTEB_Condition ;
846 sp->p4052_eberrorcount =
847 mib_p->fddiPORTEBError_Ct ;
848 sp_len = sizeof(struct smt_p_4052) ;
849 goto sp_done ;
851 case SMT_P4053 :
853 struct smt_p_4053 *sp ;
854 sp = (struct smt_p_4053 *) to ;
855 sp->p4053_multiple =
856 mib_p->fddiPORTMultiple_P ;
857 sp->p4053_availablepaths =
858 mib_p->fddiPORTAvailablePaths ;
859 sp->p4053_currentpath =
860 mib_p->fddiPORTCurrentPath ;
861 memcpy( (char *) &sp->p4053_requestedpaths,
862 (char *) mib_p->fddiPORTRequestedPaths,4) ;
863 sp->p4053_mytype =
864 mib_p->fddiPORTMy_Type ;
865 sp->p4053_neighbortype =
866 mib_p->fddiPORTNeighborType ;
867 sp_len = sizeof(struct smt_p_4053) ;
868 goto sp_done ;
870 default :
871 break ;
874 * in table ?
876 if (!pt) {
877 pcon->pc_err = (para & 0xff00) ? SMT_RDF_NOPARAM :
878 SMT_RDF_ILLEGAL ;
879 return ;
882 * check access rights
884 switch (pt->p_access) {
885 case AC_G :
886 case AC_GR :
887 break ;
888 default :
889 pcon->pc_err = SMT_RDF_ILLEGAL ;
890 return ;
892 from = mib_addr + pt->p_offset ;
893 if (!swap)
894 swap = pt->p_swap ; /* pointer to swap string */
897 * copy values
899 while ((c = *swap++)) {
900 switch(c) {
901 case 'b' :
902 case 'w' :
903 case 'l' :
904 break ;
905 case 'S' :
906 case 'E' :
907 case 'R' :
908 case 'r' :
909 if (len < 4)
910 goto len_error ;
911 to[0] = 0 ;
912 to[1] = 0 ;
913 #ifdef LITTLE_ENDIAN
914 if (c == 'r') {
915 to[2] = *from++ ;
916 to[3] = *from++ ;
918 else {
919 to[3] = *from++ ;
920 to[2] = *from++ ;
922 #else
923 to[2] = *from++ ;
924 to[3] = *from++ ;
925 #endif
926 to += 4 ;
927 len -= 4 ;
928 break ;
929 case 'I' : /* for SET of port indexes */
930 if (len < 2)
931 goto len_error ;
932 #ifdef LITTLE_ENDIAN
933 to[1] = *from++ ;
934 to[0] = *from++ ;
935 #else
936 to[0] = *from++ ;
937 to[1] = *from++ ;
938 #endif
939 to += 2 ;
940 len -= 2 ;
941 break ;
942 case 'F' :
943 case 'B' :
944 if (len < 4)
945 goto len_error ;
946 len -= 4 ;
947 to[0] = 0 ;
948 to[1] = 0 ;
949 to[2] = 0 ;
950 to[3] = *from++ ;
951 to += 4 ;
952 break ;
953 case 'C' :
954 case 'T' :
955 case 'L' :
956 if (len < 4)
957 goto len_error ;
958 #ifdef LITTLE_ENDIAN
959 to[3] = *from++ ;
960 to[2] = *from++ ;
961 to[1] = *from++ ;
962 to[0] = *from++ ;
963 #else
964 to[0] = *from++ ;
965 to[1] = *from++ ;
966 to[2] = *from++ ;
967 to[3] = *from++ ;
968 #endif
969 len -= 4 ;
970 to += 4 ;
971 break ;
972 case '2' : /* PortMacIndicated */
973 if (len < 4)
974 goto len_error ;
975 to[0] = 0 ;
976 to[1] = 0 ;
977 to[2] = *from++ ;
978 to[3] = *from++ ;
979 len -= 4 ;
980 to += 4 ;
981 break ;
982 case '4' :
983 if (len < 4)
984 goto len_error ;
985 to[0] = *from++ ;
986 to[1] = *from++ ;
987 to[2] = *from++ ;
988 to[3] = *from++ ;
989 len -= 4 ;
990 to += 4 ;
991 break ;
992 case 'A' :
993 if (len < 8)
994 goto len_error ;
995 to[0] = 0 ;
996 to[1] = 0 ;
997 memcpy((char *) to+2,(char *) from,6) ;
998 to += 8 ;
999 from += 8 ;
1000 len -= 8 ;
1001 break ;
1002 case '8' :
1003 if (len < 8)
1004 goto len_error ;
1005 memcpy((char *) to,(char *) from,8) ;
1006 to += 8 ;
1007 from += 8 ;
1008 len -= 8 ;
1009 break ;
1010 case 'D' :
1011 if (len < 32)
1012 goto len_error ;
1013 memcpy((char *) to,(char *) from,32) ;
1014 to += 32 ;
1015 from += 32 ;
1016 len -= 32 ;
1017 break ;
1018 case 'P' : /* timestamp is NOT swapped */
1019 if (len < 8)
1020 goto len_error ;
1021 to[0] = *from++ ;
1022 to[1] = *from++ ;
1023 to[2] = *from++ ;
1024 to[3] = *from++ ;
1025 to[4] = *from++ ;
1026 to[5] = *from++ ;
1027 to[6] = *from++ ;
1028 to[7] = *from++ ;
1029 to += 8 ;
1030 len -= 8 ;
1031 break ;
1032 default :
1033 SMT_PANIC(smc,SMT_E0119, SMT_E0119_MSG) ;
1034 break ;
1038 done:
1040 * make it even (in case of 'I' encoding)
1041 * note: len is DECREMENTED
1043 if (len & 3) {
1044 to[0] = 0 ;
1045 to[1] = 0 ;
1046 to += 4 - (len & 3 ) ;
1047 len = len & ~ 3 ;
1050 /* set type and length */
1051 pa->p_type = para ;
1052 pa->p_len = plen - len - PARA_LEN ;
1053 /* return values */
1054 pcon->pc_p = (void *) to ;
1055 pcon->pc_len = len ;
1056 return ;
1058 sp_done:
1059 len -= sp_len ;
1060 to += sp_len ;
1061 goto done ;
1063 len_error:
1064 /* parameter does not fit in frame */
1065 pcon->pc_err = SMT_RDF_TOOLONG ;
1066 return ;
1068 wrong_error:
1069 pcon->pc_err = SMT_RDF_LENGTH ;
1073 * set parameter
1075 static int smt_set_para(struct s_smc *smc, struct smt_para *pa, int index,
1076 int local, int set)
1078 #define IFSET(x) if (set) (x)
1080 const struct s_p_tab *pt ;
1081 int len ;
1082 char *from ;
1083 char *to ;
1084 const char *swap ;
1085 char c ;
1086 char *mib_addr ;
1087 struct fddi_mib *mib ;
1088 struct fddi_mib_m *mib_m = NULL;
1089 struct fddi_mib_a *mib_a = NULL;
1090 struct fddi_mib_p *mib_p = NULL;
1091 int mac ;
1092 int path ;
1093 int port ;
1094 SK_LOC_DECL(u_char,byte_val) ;
1095 SK_LOC_DECL(u_short,word_val) ;
1096 SK_LOC_DECL(u_long,long_val) ;
1098 mac = index - INDEX_MAC ;
1099 path = index - INDEX_PATH ;
1100 port = index - INDEX_PORT ;
1101 len = pa->p_len ;
1102 from = (char *) (pa + 1 ) ;
1104 mib = &smc->mib ;
1105 switch (pa->p_type & 0xf000) {
1106 case 0x1000 :
1107 default :
1108 mib_addr = (char *) mib ;
1109 break ;
1110 case 0x2000 :
1111 if (mac < 0 || mac >= NUMMACS) {
1112 return(SMT_RDF_NOPARAM) ;
1114 mib_m = &smc->mib.m[mac] ;
1115 mib_addr = (char *) mib_m ;
1116 from += 4 ; /* skip index */
1117 len -= 4 ;
1118 break ;
1119 case 0x3000 :
1120 if (path < 0 || path >= NUMPATHS) {
1121 return(SMT_RDF_NOPARAM) ;
1123 mib_a = &smc->mib.a[path] ;
1124 mib_addr = (char *) mib_a ;
1125 from += 4 ; /* skip index */
1126 len -= 4 ;
1127 break ;
1128 case 0x4000 :
1129 if (port < 0 || port >= smt_mib_phys(smc)) {
1130 return(SMT_RDF_NOPARAM) ;
1132 mib_p = &smc->mib.p[port_to_mib(smc,port)] ;
1133 mib_addr = (char *) mib_p ;
1134 from += 4 ; /* skip index */
1135 len -= 4 ;
1136 break ;
1138 switch (pa->p_type) {
1139 case SMT_P10F0 :
1140 case SMT_P10F1 :
1141 #ifdef ESS
1142 case SMT_P10F2 :
1143 case SMT_P10F3 :
1144 case SMT_P10F4 :
1145 case SMT_P10F5 :
1146 case SMT_P10F6 :
1147 case SMT_P10F7 :
1148 #endif
1149 #ifdef SBA
1150 case SMT_P10F8 :
1151 case SMT_P10F9 :
1152 #endif
1153 case SMT_P20F1 :
1154 if (!local) {
1155 return(SMT_RDF_NOPARAM) ;
1157 break ;
1159 pt = smt_get_ptab(pa->p_type) ;
1160 if (!pt) {
1161 return( (pa->p_type & 0xff00) ? SMT_RDF_NOPARAM :
1162 SMT_RDF_ILLEGAL ) ;
1164 switch (pt->p_access) {
1165 case AC_GR :
1166 case AC_S :
1167 break ;
1168 default :
1169 return(SMT_RDF_ILLEGAL) ;
1171 to = mib_addr + pt->p_offset ;
1172 swap = pt->p_swap ; /* pointer to swap string */
1174 while (swap && (c = *swap++)) {
1175 switch(c) {
1176 case 'b' :
1177 to = (char *) &byte_val ;
1178 break ;
1179 case 'w' :
1180 to = (char *) &word_val ;
1181 break ;
1182 case 'l' :
1183 to = (char *) &long_val ;
1184 break ;
1185 case 'S' :
1186 case 'E' :
1187 case 'R' :
1188 case 'r' :
1189 if (len < 4) {
1190 goto len_error ;
1192 if (from[0] | from[1])
1193 goto val_error ;
1194 #ifdef LITTLE_ENDIAN
1195 if (c == 'r') {
1196 to[0] = from[2] ;
1197 to[1] = from[3] ;
1199 else {
1200 to[1] = from[2] ;
1201 to[0] = from[3] ;
1203 #else
1204 to[0] = from[2] ;
1205 to[1] = from[3] ;
1206 #endif
1207 from += 4 ;
1208 to += 2 ;
1209 len -= 4 ;
1210 break ;
1211 case 'F' :
1212 case 'B' :
1213 if (len < 4) {
1214 goto len_error ;
1216 if (from[0] | from[1] | from[2])
1217 goto val_error ;
1218 to[0] = from[3] ;
1219 len -= 4 ;
1220 from += 4 ;
1221 to += 4 ;
1222 break ;
1223 case 'C' :
1224 case 'T' :
1225 case 'L' :
1226 if (len < 4) {
1227 goto len_error ;
1229 #ifdef LITTLE_ENDIAN
1230 to[3] = *from++ ;
1231 to[2] = *from++ ;
1232 to[1] = *from++ ;
1233 to[0] = *from++ ;
1234 #else
1235 to[0] = *from++ ;
1236 to[1] = *from++ ;
1237 to[2] = *from++ ;
1238 to[3] = *from++ ;
1239 #endif
1240 len -= 4 ;
1241 to += 4 ;
1242 break ;
1243 case 'A' :
1244 if (len < 8)
1245 goto len_error ;
1246 if (set)
1247 memcpy((char *) to,(char *) from+2,6) ;
1248 to += 8 ;
1249 from += 8 ;
1250 len -= 8 ;
1251 break ;
1252 case '4' :
1253 if (len < 4)
1254 goto len_error ;
1255 if (set)
1256 memcpy((char *) to,(char *) from,4) ;
1257 to += 4 ;
1258 from += 4 ;
1259 len -= 4 ;
1260 break ;
1261 case '8' :
1262 if (len < 8)
1263 goto len_error ;
1264 if (set)
1265 memcpy((char *) to,(char *) from,8) ;
1266 to += 8 ;
1267 from += 8 ;
1268 len -= 8 ;
1269 break ;
1270 case 'D' :
1271 if (len < 32)
1272 goto len_error ;
1273 if (set)
1274 memcpy((char *) to,(char *) from,32) ;
1275 to += 32 ;
1276 from += 32 ;
1277 len -= 32 ;
1278 break ;
1279 case 'P' : /* timestamp is NOT swapped */
1280 if (set) {
1281 to[0] = *from++ ;
1282 to[1] = *from++ ;
1283 to[2] = *from++ ;
1284 to[3] = *from++ ;
1285 to[4] = *from++ ;
1286 to[5] = *from++ ;
1287 to[6] = *from++ ;
1288 to[7] = *from++ ;
1290 to += 8 ;
1291 len -= 8 ;
1292 break ;
1293 default :
1294 SMT_PANIC(smc,SMT_E0120, SMT_E0120_MSG) ;
1295 return(SMT_RDF_ILLEGAL) ;
1299 * actions and internal updates
1301 switch (pa->p_type) {
1302 case SMT_P101A: /* fddiSMTConfigPolicy */
1303 if (word_val & ~1)
1304 goto val_error ;
1305 IFSET(mib->fddiSMTConfigPolicy = word_val) ;
1306 break ;
1307 case SMT_P101B : /* fddiSMTConnectionPolicy */
1308 if (!(word_val & POLICY_MM))
1309 goto val_error ;
1310 IFSET(mib->fddiSMTConnectionPolicy = word_val) ;
1311 break ;
1312 case SMT_P101D : /* fddiSMTTT_Notify */
1313 if (word_val < 2 || word_val > 30)
1314 goto val_error ;
1315 IFSET(mib->fddiSMTTT_Notify = word_val) ;
1316 break ;
1317 case SMT_P101E : /* fddiSMTStatRptPolicy */
1318 if (byte_val & ~1)
1319 goto val_error ;
1320 IFSET(mib->fddiSMTStatRptPolicy = byte_val) ;
1321 break ;
1322 case SMT_P101F : /* fddiSMTTrace_MaxExpiration */
1324 * note: lower limit trace_max = 6.001773... s
1325 * NO upper limit
1327 if (long_val < (long)0x478bf51L)
1328 goto val_error ;
1329 IFSET(mib->fddiSMTTrace_MaxExpiration = long_val) ;
1330 break ;
1331 #ifdef ESS
1332 case SMT_P10F2 : /* fddiESSPayload */
1333 if (long_val > 1562)
1334 goto val_error ;
1335 if (set && smc->mib.fddiESSPayload != long_val) {
1336 smc->ess.raf_act_timer_poll = TRUE ;
1337 smc->mib.fddiESSPayload = long_val ;
1339 break ;
1340 case SMT_P10F3 : /* fddiESSOverhead */
1341 if (long_val < 50 || long_val > 5000)
1342 goto val_error ;
1343 if (set && smc->mib.fddiESSPayload &&
1344 smc->mib.fddiESSOverhead != long_val) {
1345 smc->ess.raf_act_timer_poll = TRUE ;
1346 smc->mib.fddiESSOverhead = long_val ;
1348 break ;
1349 case SMT_P10F4 : /* fddiESSMaxTNeg */
1350 if (long_val > -MS2BCLK(5) || long_val < -MS2BCLK(165))
1351 goto val_error ;
1352 IFSET(mib->fddiESSMaxTNeg = long_val) ;
1353 break ;
1354 case SMT_P10F5 : /* fddiESSMinSegmentSize */
1355 if (long_val < 1 || long_val > 4478)
1356 goto val_error ;
1357 IFSET(mib->fddiESSMinSegmentSize = long_val) ;
1358 break ;
1359 case SMT_P10F6 : /* fddiESSCategory */
1360 if ((long_val & 0xffff) != 1)
1361 goto val_error ;
1362 IFSET(mib->fddiESSCategory = long_val) ;
1363 break ;
1364 case SMT_P10F7 : /* fddiESSSyncTxMode */
1365 if (word_val > 1)
1366 goto val_error ;
1367 IFSET(mib->fddiESSSynchTxMode = word_val) ;
1368 break ;
1369 #endif
1370 #ifdef SBA
1371 case SMT_P10F8 : /* fddiSBACommand */
1372 if (byte_val != SB_STOP && byte_val != SB_START)
1373 goto val_error ;
1374 IFSET(mib->fddiSBACommand = byte_val) ;
1375 break ;
1376 case SMT_P10F9 : /* fddiSBAAvailable */
1377 if (byte_val > 100)
1378 goto val_error ;
1379 IFSET(mib->fddiSBAAvailable = byte_val) ;
1380 break ;
1381 #endif
1382 case SMT_P2020 : /* fddiMACRequestedPaths */
1383 if ((word_val & (MIB_P_PATH_PRIM_PREFER |
1384 MIB_P_PATH_PRIM_ALTER)) == 0 )
1385 goto val_error ;
1386 IFSET(mib_m->fddiMACRequestedPaths = word_val) ;
1387 break ;
1388 case SMT_P205F : /* fddiMACFrameErrorThreshold */
1389 /* 0 .. ffff acceptable */
1390 IFSET(mib_m->fddiMACFrameErrorThreshold = word_val) ;
1391 break ;
1392 case SMT_P2067 : /* fddiMACNotCopiedThreshold */
1393 /* 0 .. ffff acceptable */
1394 IFSET(mib_m->fddiMACNotCopiedThreshold = word_val) ;
1395 break ;
1396 case SMT_P2076: /* fddiMACMA_UnitdataEnable */
1397 if (byte_val & ~1)
1398 goto val_error ;
1399 if (set) {
1400 mib_m->fddiMACMA_UnitdataEnable = byte_val ;
1401 queue_event(smc,EVENT_RMT,RM_ENABLE_FLAG) ;
1403 break ;
1404 case SMT_P20F1 : /* fddiMACT_Min */
1405 IFSET(mib_m->fddiMACT_Min = long_val) ;
1406 break ;
1407 case SMT_P320F :
1408 if (long_val > 1562)
1409 goto val_error ;
1410 IFSET(mib_a->fddiPATHSbaPayload = long_val) ;
1411 #ifdef ESS
1412 if (set)
1413 ess_para_change(smc) ;
1414 #endif
1415 break ;
1416 case SMT_P3210 :
1417 if (long_val > 5000)
1418 goto val_error ;
1420 if (long_val != 0 && mib_a->fddiPATHSbaPayload == 0)
1421 goto val_error ;
1423 IFSET(mib_a->fddiPATHSbaOverhead = long_val) ;
1424 #ifdef ESS
1425 if (set)
1426 ess_para_change(smc) ;
1427 #endif
1428 break ;
1429 case SMT_P3213: /* fddiPATHT_Rmode */
1430 /* no limit :
1431 * 0 .. 343.597 => 0 .. 2e32 * 80nS
1433 if (set) {
1434 mib_a->fddiPATHT_Rmode = long_val ;
1435 rtm_set_timer(smc) ;
1437 break ;
1438 case SMT_P3214 : /* fddiPATHSbaAvailable */
1439 if (long_val > 0x00BEBC20L)
1440 goto val_error ;
1441 #ifdef SBA
1442 if (set && mib->fddiSBACommand == SB_STOP)
1443 goto val_error ;
1444 #endif
1445 IFSET(mib_a->fddiPATHSbaAvailable = long_val) ;
1446 break ;
1447 case SMT_P3215 : /* fddiPATHTVXLowerBound */
1448 IFSET(mib_a->fddiPATHTVXLowerBound = long_val) ;
1449 goto change_mac_para ;
1450 case SMT_P3216 : /* fddiPATHT_MaxLowerBound */
1451 IFSET(mib_a->fddiPATHT_MaxLowerBound = long_val) ;
1452 goto change_mac_para ;
1453 case SMT_P3217 : /* fddiPATHMaxT_Req */
1454 IFSET(mib_a->fddiPATHMaxT_Req = long_val) ;
1456 change_mac_para:
1457 if (set && smt_set_mac_opvalues(smc)) {
1458 RS_SET(smc,RS_EVENT) ;
1459 smc->sm.please_reconnect = 1 ;
1460 queue_event(smc,EVENT_ECM,EC_DISCONNECT) ;
1462 break ;
1463 case SMT_P400E : /* fddiPORTConnectionPolicies */
1464 if (byte_val > 1)
1465 goto val_error ;
1466 IFSET(mib_p->fddiPORTConnectionPolicies = byte_val) ;
1467 break ;
1468 case SMT_P4011 : /* fddiPORTRequestedPaths */
1469 /* all 3*8 bits allowed */
1470 IFSET(memcpy((char *)mib_p->fddiPORTRequestedPaths,
1471 (char *)&long_val,4)) ;
1472 break ;
1473 case SMT_P401F: /* fddiPORTMaint_LS */
1474 if (word_val > 4)
1475 goto val_error ;
1476 IFSET(mib_p->fddiPORTMaint_LS = word_val) ;
1477 break ;
1478 case SMT_P403A : /* fddiPORTLer_Cutoff */
1479 if (byte_val < 4 || byte_val > 15)
1480 goto val_error ;
1481 IFSET(mib_p->fddiPORTLer_Cutoff = byte_val) ;
1482 break ;
1483 case SMT_P403B : /* fddiPORTLer_Alarm */
1484 if (byte_val < 4 || byte_val > 15)
1485 goto val_error ;
1486 IFSET(mib_p->fddiPORTLer_Alarm = byte_val) ;
1487 break ;
1490 * Actions
1492 case SMT_P103C : /* fddiSMTStationAction */
1493 if (smt_action(smc,SMT_STATION_ACTION, (int) word_val, 0))
1494 goto val_error ;
1495 break ;
1496 case SMT_P4046: /* fddiPORTAction */
1497 if (smt_action(smc,SMT_PORT_ACTION, (int) word_val,
1498 port_to_mib(smc,port)))
1499 goto val_error ;
1500 break ;
1501 default :
1502 break ;
1504 return(0) ;
1506 val_error:
1507 /* parameter value in frame is out of range */
1508 return(SMT_RDF_RANGE) ;
1510 len_error:
1511 /* parameter value in frame is too short */
1512 return(SMT_RDF_LENGTH) ;
1514 #if 0
1515 no_author_error:
1516 /* parameter not setable, because the SBA is not active
1517 * Please note: we give the return code 'not authorizeed
1518 * because SBA denied is not a valid return code in the
1519 * PMF protocol.
1521 return(SMT_RDF_AUTHOR) ;
1522 #endif
1525 static const struct s_p_tab *smt_get_ptab(u_short para)
1527 const struct s_p_tab *pt ;
1528 for (pt = p_tab ; pt->p_num && pt->p_num != para ; pt++)
1530 return(pt->p_num ? pt : NULL) ;
1533 static int smt_mib_phys(struct s_smc *smc)
1535 #ifdef CONCENTRATOR
1536 SK_UNUSED(smc) ;
1538 return(NUMPHYS) ;
1539 #else
1540 if (smc->s.sas == SMT_SAS)
1541 return(1) ;
1542 return(NUMPHYS) ;
1543 #endif
1546 static int port_to_mib(struct s_smc *smc, int p)
1548 #ifdef CONCENTRATOR
1549 SK_UNUSED(smc) ;
1551 return(p) ;
1552 #else
1553 if (smc->s.sas == SMT_SAS)
1554 return(PS) ;
1555 return(p) ;
1556 #endif
1560 #ifdef DEBUG
1561 #ifndef BOOT
1562 void dump_smt(struct s_smc *smc, struct smt_header *sm, char *text)
1564 int len ;
1565 struct smt_para *pa ;
1566 char *c ;
1567 int n ;
1568 int nn ;
1569 #ifdef LITTLE_ENDIAN
1570 int smtlen ;
1571 #endif
1573 SK_UNUSED(smc) ;
1575 #ifdef DEBUG_BRD
1576 if (smc->debug.d_smtf < 2)
1577 #else
1578 if (debug.d_smtf < 2)
1579 #endif
1580 return ;
1581 #ifdef LITTLE_ENDIAN
1582 smtlen = sm->smt_len + sizeof(struct smt_header) ;
1583 #endif
1584 printf("SMT Frame [%s]:\nDA ",text) ;
1585 dump_hex((char *) &sm->smt_dest,6) ;
1586 printf("\tSA ") ;
1587 dump_hex((char *) &sm->smt_source,6) ;
1588 printf(" Class %x Type %x Version %x\n",
1589 sm->smt_class,sm->smt_type,sm->smt_version) ;
1590 printf("TID %lx\t\tSID ",sm->smt_tid) ;
1591 dump_hex((char *) &sm->smt_sid,8) ;
1592 printf(" LEN %x\n",sm->smt_len) ;
1594 len = sm->smt_len ;
1595 pa = (struct smt_para *) (sm + 1) ;
1596 while (len > 0 ) {
1597 int plen ;
1598 #ifdef UNIX
1599 printf("TYPE %x LEN %x VALUE\t",pa->p_type,pa->p_len) ;
1600 #else
1601 printf("TYPE %04x LEN %2x VALUE\t",pa->p_type,pa->p_len) ;
1602 #endif
1603 n = pa->p_len ;
1604 if ( (n < 0 ) || (n > (int)(len - PARA_LEN))) {
1605 n = len - PARA_LEN ;
1606 printf(" BAD LENGTH\n") ;
1607 break ;
1609 #ifdef LITTLE_ENDIAN
1610 smt_swap_para(sm,smtlen,0) ;
1611 #endif
1612 if (n < 24) {
1613 dump_hex((char *)(pa+1),(int) n) ;
1614 printf("\n") ;
1616 else {
1617 int first = 0 ;
1618 c = (char *)(pa+1) ;
1619 dump_hex(c,16) ;
1620 printf("\n") ;
1621 n -= 16 ;
1622 c += 16 ;
1623 while (n > 0) {
1624 nn = (n > 16) ? 16 : n ;
1625 if (n > 64) {
1626 if (first == 0)
1627 printf("\t\t\t...\n") ;
1628 first = 1 ;
1630 else {
1631 printf("\t\t\t") ;
1632 dump_hex(c,nn) ;
1633 printf("\n") ;
1635 n -= nn ;
1636 c += 16 ;
1639 #ifdef LITTLE_ENDIAN
1640 smt_swap_para(sm,smtlen,1) ;
1641 #endif
1642 plen = (pa->p_len + PARA_LEN + 3) & ~3 ;
1643 len -= plen ;
1644 pa = (struct smt_para *)((char *)pa + plen) ;
1646 printf("-------------------------------------------------\n\n") ;
1649 void dump_hex(char *p, int len)
1651 int n = 0 ;
1652 while (len--) {
1653 n++ ;
1654 #ifdef UNIX
1655 printf("%x%s",*p++ & 0xff,len ? ( (n & 7) ? " " : "-") : "") ;
1656 #else
1657 printf("%02x%s",*p++ & 0xff,len ? ( (n & 7) ? " " : "-") : "") ;
1658 #endif
1661 #endif /* no BOOT */
1662 #endif /* DEBUG */
1665 #endif /* no SLIM_SMT */