1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /******************************************************************************
4 * (C)Copyright 1998,1999 SysKonnect,
5 * a business unit of Schneider & Koch & Co. Datensysteme GmbH.
7 * See the file "skfddi.c" for further information.
9 * The information in this file is provided "AS IS" without warranty.
11 ******************************************************************************/
14 Parameter Management Frame processing for SMT 7.2
23 #include "h/smtstate.h"
27 static int smt_authorize(struct s_smc
*smc
, struct smt_header
*sm
);
28 static int smt_check_set_count(struct s_smc
*smc
, struct smt_header
*sm
);
29 static const struct s_p_tab
* smt_get_ptab(u_short para
);
30 static int smt_mib_phys(struct s_smc
*smc
);
31 static int smt_set_para(struct s_smc
*smc
, struct smt_para
*pa
, int index
,
33 void smt_add_para(struct s_smc
*smc
, struct s_pcon
*pcon
, u_short para
,
34 int index
, int local
);
35 static SMbuf
*smt_build_pmf_response(struct s_smc
*smc
, struct smt_header
*req
,
37 static int port_to_mib(struct s_smc
*smc
, int p
);
39 #define MOFFSS(e) offsetof(struct fddi_mib, e)
40 #define MOFFMS(e) offsetof(struct fddi_mib_m, e)
41 #define MOFFAS(e) offsetof(struct fddi_mib_a, e)
42 #define MOFFPS(e) offsetof(struct fddi_mib_p, e)
45 #define AC_G 0x01 /* Get */
46 #define AC_GR 0x02 /* Get/Set */
47 #define AC_S 0x04 /* Set */
49 #define AC_GROUP 0x10 /* Group */
50 #define MS2BCLK(x) ((x)*12500L)
59 A LongAddress (6 byte)
63 static const struct s_p_tab
{
64 u_short p_num
; /* parameter code */
65 u_char p_access
; /* access rights */
66 u_short p_offset
; /* offset in mib */
67 char p_swap
[3] ; /* format string */
70 { SMT_P100A
,AC_GROUP
} ,
71 { SMT_P100B
,AC_G
, MOFFSS(fddiSMTStationId
), "8" } ,
72 { SMT_P100D
,AC_G
, MOFFSS(fddiSMTOpVersionId
), "S" } ,
73 { SMT_P100E
,AC_G
, MOFFSS(fddiSMTHiVersionId
), "S" } ,
74 { SMT_P100F
,AC_G
, MOFFSS(fddiSMTLoVersionId
), "S" } ,
75 { SMT_P1010
,AC_G
, MOFFSS(fddiSMTManufacturerData
), "D" } ,
76 { SMT_P1011
,AC_GR
, MOFFSS(fddiSMTUserData
), "D" } ,
77 { SMT_P1012
,AC_G
, MOFFSS(fddiSMTMIBVersionId
), "S" } ,
79 /* StationConfigGrp */
80 { SMT_P1014
,AC_GROUP
} ,
81 { SMT_P1015
,AC_G
, MOFFSS(fddiSMTMac_Ct
), "B" } ,
82 { SMT_P1016
,AC_G
, MOFFSS(fddiSMTNonMaster_Ct
), "B" } ,
83 { SMT_P1017
,AC_G
, MOFFSS(fddiSMTMaster_Ct
), "B" } ,
84 { SMT_P1018
,AC_G
, MOFFSS(fddiSMTAvailablePaths
), "B" } ,
85 { SMT_P1019
,AC_G
, MOFFSS(fddiSMTConfigCapabilities
),"S" } ,
86 { SMT_P101A
,AC_GR
, MOFFSS(fddiSMTConfigPolicy
), "wS" } ,
87 { SMT_P101B
,AC_GR
, MOFFSS(fddiSMTConnectionPolicy
),"wS" } ,
88 { SMT_P101D
,AC_GR
, MOFFSS(fddiSMTTT_Notify
), "wS" } ,
89 { SMT_P101E
,AC_GR
, MOFFSS(fddiSMTStatRptPolicy
), "bB" } ,
90 { SMT_P101F
,AC_GR
, MOFFSS(fddiSMTTrace_MaxExpiration
),"lL" } ,
91 { SMT_P1020
,AC_G
, MOFFSS(fddiSMTPORTIndexes
), "II" } ,
92 { SMT_P1021
,AC_G
, MOFFSS(fddiSMTMACIndexes
), "I" } ,
93 { SMT_P1022
,AC_G
, MOFFSS(fddiSMTBypassPresent
), "F" } ,
96 { SMT_P1028
,AC_GROUP
} ,
97 { SMT_P1029
,AC_G
, MOFFSS(fddiSMTECMState
), "E" } ,
98 { SMT_P102A
,AC_G
, MOFFSS(fddiSMTCF_State
), "E" } ,
99 { SMT_P102C
,AC_G
, MOFFSS(fddiSMTRemoteDisconnectFlag
),"F" } ,
100 { SMT_P102D
,AC_G
, MOFFSS(fddiSMTStationStatus
), "E" } ,
101 { SMT_P102E
,AC_G
, MOFFSS(fddiSMTPeerWrapFlag
), "F" } ,
103 /* MIBOperationGrp */
104 { SMT_P1032
,AC_GROUP
} ,
105 { SMT_P1033
,AC_G
, MOFFSS(fddiSMTTimeStamp
),"P" } ,
106 { SMT_P1034
,AC_G
, MOFFSS(fddiSMTTransitionTimeStamp
),"P" } ,
107 /* NOTE : SMT_P1035 is already swapped ! SMT_P_SETCOUNT */
108 { SMT_P1035
,AC_G
, MOFFSS(fddiSMTSetCount
),"4P" } ,
109 { SMT_P1036
,AC_G
, MOFFSS(fddiSMTLastSetStationId
),"8" } ,
111 { SMT_P103C
,AC_S
, 0, "wS" } ,
115 * only accessible locally to get/set passwd
117 { SMT_P10F0
,AC_GR
, MOFFSS(fddiPRPMFPasswd
), "8" } ,
118 { SMT_P10F1
,AC_GR
, MOFFSS(fddiPRPMFStation
), "8" } ,
120 { SMT_P10F2
,AC_GR
, MOFFSS(fddiESSPayload
), "lL" } ,
121 { SMT_P10F3
,AC_GR
, MOFFSS(fddiESSOverhead
), "lL" } ,
122 { SMT_P10F4
,AC_GR
, MOFFSS(fddiESSMaxTNeg
), "lL" } ,
123 { SMT_P10F5
,AC_GR
, MOFFSS(fddiESSMinSegmentSize
), "lL" } ,
124 { SMT_P10F6
,AC_GR
, MOFFSS(fddiESSCategory
), "lL" } ,
125 { SMT_P10F7
,AC_GR
, MOFFSS(fddiESSSynchTxMode
), "wS" } ,
128 { SMT_P10F8
,AC_GR
, MOFFSS(fddiSBACommand
), "bF" } ,
129 { SMT_P10F9
,AC_GR
, MOFFSS(fddiSBAAvailable
), "bF" } ,
132 { SMT_P200A
,AC_GROUP
} ,
133 { SMT_P200B
,AC_G
, MOFFMS(fddiMACFrameStatusFunctions
),"S" } ,
134 { SMT_P200D
,AC_G
, MOFFMS(fddiMACT_MaxCapabilitiy
),"T" } ,
135 { SMT_P200E
,AC_G
, MOFFMS(fddiMACTVXCapabilitiy
),"T" } ,
138 { SMT_P2014
,AC_GROUP
} ,
139 { SMT_P2016
,AC_G
, MOFFMS(fddiMACAvailablePaths
), "B" } ,
140 { SMT_P2017
,AC_G
, MOFFMS(fddiMACCurrentPath
), "S" } ,
141 { SMT_P2018
,AC_G
, MOFFMS(fddiMACUpstreamNbr
), "A" } ,
142 { SMT_P2019
,AC_G
, MOFFMS(fddiMACDownstreamNbr
), "A" } ,
143 { SMT_P201A
,AC_G
, MOFFMS(fddiMACOldUpstreamNbr
), "A" } ,
144 { SMT_P201B
,AC_G
, MOFFMS(fddiMACOldDownstreamNbr
),"A" } ,
145 { SMT_P201D
,AC_G
, MOFFMS(fddiMACDupAddressTest
), "E" } ,
146 { SMT_P2020
,AC_GR
, MOFFMS(fddiMACRequestedPaths
), "wS" } ,
147 { SMT_P2021
,AC_G
, MOFFMS(fddiMACDownstreamPORTType
),"E" } ,
148 { SMT_P2022
,AC_G
, MOFFMS(fddiMACIndex
), "S" } ,
151 { SMT_P2028
,AC_GROUP
} ,
152 { SMT_P2029
,AC_G
, MOFFMS(fddiMACSMTAddress
), "A" } ,
155 { SMT_P2032
,AC_GROUP
} ,
156 { SMT_P2033
,AC_G
, MOFFMS(fddiMACT_Req
), "T" } ,
157 { SMT_P2034
,AC_G
, MOFFMS(fddiMACT_Neg
), "T" } ,
158 { SMT_P2035
,AC_G
, MOFFMS(fddiMACT_Max
), "T" } ,
159 { SMT_P2036
,AC_G
, MOFFMS(fddiMACTvxValue
), "T" } ,
160 { SMT_P2038
,AC_G
, MOFFMS(fddiMACT_Pri0
), "T" } ,
161 { SMT_P2039
,AC_G
, MOFFMS(fddiMACT_Pri1
), "T" } ,
162 { SMT_P203A
,AC_G
, MOFFMS(fddiMACT_Pri2
), "T" } ,
163 { SMT_P203B
,AC_G
, MOFFMS(fddiMACT_Pri3
), "T" } ,
164 { SMT_P203C
,AC_G
, MOFFMS(fddiMACT_Pri4
), "T" } ,
165 { SMT_P203D
,AC_G
, MOFFMS(fddiMACT_Pri5
), "T" } ,
166 { SMT_P203E
,AC_G
, MOFFMS(fddiMACT_Pri6
), "T" } ,
170 { SMT_P2046
,AC_GROUP
} ,
171 { SMT_P2047
,AC_G
, MOFFMS(fddiMACFrame_Ct
), "C" } ,
172 { SMT_P2048
,AC_G
, MOFFMS(fddiMACCopied_Ct
), "C" } ,
173 { SMT_P2049
,AC_G
, MOFFMS(fddiMACTransmit_Ct
), "C" } ,
174 { SMT_P204A
,AC_G
, MOFFMS(fddiMACToken_Ct
), "C" } ,
175 { SMT_P2051
,AC_G
, MOFFMS(fddiMACError_Ct
), "C" } ,
176 { SMT_P2052
,AC_G
, MOFFMS(fddiMACLost_Ct
), "C" } ,
177 { SMT_P2053
,AC_G
, MOFFMS(fddiMACTvxExpired_Ct
), "C" } ,
178 { SMT_P2054
,AC_G
, MOFFMS(fddiMACNotCopied_Ct
), "C" } ,
179 { SMT_P2056
,AC_G
, MOFFMS(fddiMACRingOp_Ct
), "C" } ,
181 /* FrameErrorConditionGrp */
182 { SMT_P205A
,AC_GROUP
} ,
183 { SMT_P205F
,AC_GR
, MOFFMS(fddiMACFrameErrorThreshold
),"wS" } ,
184 { SMT_P2060
,AC_G
, MOFFMS(fddiMACFrameErrorRatio
), "S" } ,
186 /* NotCopiedConditionGrp */
187 { SMT_P2064
,AC_GROUP
} ,
188 { SMT_P2067
,AC_GR
, MOFFMS(fddiMACNotCopiedThreshold
),"wS" } ,
189 { SMT_P2069
,AC_G
, MOFFMS(fddiMACNotCopiedRatio
), "S" } ,
192 { SMT_P206E
,AC_GROUP
} ,
193 { SMT_P206F
,AC_G
, MOFFMS(fddiMACRMTState
), "S" } ,
194 { SMT_P2070
,AC_G
, MOFFMS(fddiMACDA_Flag
), "F" } ,
195 { SMT_P2071
,AC_G
, MOFFMS(fddiMACUNDA_Flag
), "F" } ,
196 { SMT_P2072
,AC_G
, MOFFMS(fddiMACFrameErrorFlag
), "F" } ,
197 { SMT_P2073
,AC_G
, MOFFMS(fddiMACNotCopiedFlag
), "F" } ,
198 { SMT_P2074
,AC_G
, MOFFMS(fddiMACMA_UnitdataAvailable
),"F" } ,
199 { SMT_P2075
,AC_G
, MOFFMS(fddiMACHardwarePresent
), "F" } ,
200 { SMT_P2076
,AC_GR
, MOFFMS(fddiMACMA_UnitdataEnable
),"bF" } ,
204 * only accessible locally to get/set TMIN
206 { SMT_P20F0
,AC_NA
} ,
207 { SMT_P20F1
,AC_GR
, MOFFMS(fddiMACT_Min
), "lT" } ,
209 /* Path Attributes */
211 * DON't swap 320B,320F,3210: they are already swapped in swap_para()
213 { SMT_P320A
,AC_GROUP
} ,
214 { SMT_P320B
,AC_G
, MOFFAS(fddiPATHIndex
), "r" } ,
215 { SMT_P320F
,AC_GR
, MOFFAS(fddiPATHSbaPayload
), "l4" } ,
216 { SMT_P3210
,AC_GR
, MOFFAS(fddiPATHSbaOverhead
), "l4" } ,
217 /* fddiPATHConfiguration */
218 { SMT_P3212
,AC_G
, 0, "" } ,
219 { SMT_P3213
,AC_GR
, MOFFAS(fddiPATHT_Rmode
), "lT" } ,
220 { SMT_P3214
,AC_GR
, MOFFAS(fddiPATHSbaAvailable
), "lL" } ,
221 { SMT_P3215
,AC_GR
, MOFFAS(fddiPATHTVXLowerBound
), "lT" } ,
222 { SMT_P3216
,AC_GR
, MOFFAS(fddiPATHT_MaxLowerBound
),"lT" } ,
223 { SMT_P3217
,AC_GR
, MOFFAS(fddiPATHMaxT_Req
), "lT" } ,
225 /* Port Attributes */
227 { SMT_P400A
,AC_GROUP
} ,
228 { SMT_P400C
,AC_G
, MOFFPS(fddiPORTMy_Type
), "E" } ,
229 { SMT_P400D
,AC_G
, MOFFPS(fddiPORTNeighborType
), "E" } ,
230 { SMT_P400E
,AC_GR
, MOFFPS(fddiPORTConnectionPolicies
),"bB" } ,
231 { SMT_P400F
,AC_G
, MOFFPS(fddiPORTMacIndicated
), "2" } ,
232 { SMT_P4010
,AC_G
, MOFFPS(fddiPORTCurrentPath
), "E" } ,
233 { SMT_P4011
,AC_GR
, MOFFPS(fddiPORTRequestedPaths
), "l4" } ,
234 { SMT_P4012
,AC_G
, MOFFPS(fddiPORTMACPlacement
), "S" } ,
235 { SMT_P4013
,AC_G
, MOFFPS(fddiPORTAvailablePaths
), "B" } ,
236 { SMT_P4016
,AC_G
, MOFFPS(fddiPORTPMDClass
), "E" } ,
237 { SMT_P4017
,AC_G
, MOFFPS(fddiPORTConnectionCapabilities
), "B"} ,
238 { SMT_P401D
,AC_G
, MOFFPS(fddiPORTIndex
), "R" } ,
241 { SMT_P401E
,AC_GROUP
} ,
242 { SMT_P401F
,AC_GR
, MOFFPS(fddiPORTMaint_LS
), "wE" } ,
243 { SMT_P4021
,AC_G
, MOFFPS(fddiPORTBS_Flag
), "F" } ,
244 { SMT_P4022
,AC_G
, MOFFPS(fddiPORTPC_LS
), "E" } ,
247 { SMT_P4028
,AC_GROUP
} ,
248 { SMT_P4029
,AC_G
, MOFFPS(fddiPORTEBError_Ct
), "C" } ,
249 { SMT_P402A
,AC_G
, MOFFPS(fddiPORTLCTFail_Ct
), "C" } ,
252 { SMT_P4032
,AC_GROUP
} ,
253 { SMT_P4033
,AC_G
, MOFFPS(fddiPORTLer_Estimate
), "F" } ,
254 { SMT_P4034
,AC_G
, MOFFPS(fddiPORTLem_Reject_Ct
), "C" } ,
255 { SMT_P4035
,AC_G
, MOFFPS(fddiPORTLem_Ct
), "C" } ,
256 { SMT_P403A
,AC_GR
, MOFFPS(fddiPORTLer_Cutoff
), "bB" } ,
257 { SMT_P403B
,AC_GR
, MOFFPS(fddiPORTLer_Alarm
), "bB" } ,
260 { SMT_P403C
,AC_GROUP
} ,
261 { SMT_P403D
,AC_G
, MOFFPS(fddiPORTConnectState
), "E" } ,
262 { SMT_P403E
,AC_G
, MOFFPS(fddiPORTPCMStateX
), "E" } ,
263 { SMT_P403F
,AC_G
, MOFFPS(fddiPORTPC_Withhold
), "E" } ,
264 { SMT_P4040
,AC_G
, MOFFPS(fddiPORTLerFlag
), "F" } ,
265 { SMT_P4041
,AC_G
, MOFFPS(fddiPORTHardwarePresent
),"F" } ,
267 { SMT_P4046
,AC_S
, 0, "wS" } ,
273 void smt_pmf_received_pack(struct s_smc
*smc
, SMbuf
*mb
, int local
)
275 struct smt_header
*sm
;
278 sm
= smtod(mb
,struct smt_header
*) ;
279 DB_SMT("SMT: processing PMF frame at %p len %d", sm
, mb
->sm_len
);
281 dump_smt(smc
,sm
,"PMF Received") ;
284 * Start the watchdog: It may be a long, long packet and
285 * maybe the watchdog occurs ...
287 smt_start_watchdog(smc
) ;
289 if (sm
->smt_class
== SMT_PMF_GET
||
290 sm
->smt_class
== SMT_PMF_SET
) {
291 reply
= smt_build_pmf_response(smc
,sm
,
292 sm
->smt_class
== SMT_PMF_SET
,local
) ;
294 sm
= smtod(reply
,struct smt_header
*) ;
296 dump_smt(smc
,sm
,"PMF Reply") ;
298 smt_send_frame(smc
,reply
,FC_SMT_INFO
,local
) ;
303 static SMbuf
*smt_build_pmf_response(struct s_smc
*smc
, struct smt_header
*req
,
307 struct smt_header
*smt
;
308 struct smt_para
*pa
;
309 struct smt_p_reason
*res
;
310 const struct s_p_tab
*pt
;
316 SK_LOC_DECL(struct s_pcon
,pcon
) ;
317 SK_LOC_DECL(struct s_pcon
,set_pcon
) ;
322 if (!(mb
= smt_get_mbuf(smc
)))
325 smt
= smtod(mb
, struct smt_header
*) ;
326 smt
->smt_dest
= req
->smt_source
; /* DA == source of request */
327 smt
->smt_class
= req
->smt_class
; /* same class (GET/SET) */
328 smt
->smt_type
= SMT_REPLY
;
329 smt
->smt_version
= SMT_VID_2
;
330 smt
->smt_tid
= req
->smt_tid
; /* same TID */
335 * setup parameter status
337 pcon
.pc_len
= SMT_MAX_INFO_LEN
; /* max para length */
338 pcon
.pc_err
= 0 ; /* no error */
339 pcon
.pc_badset
= 0 ; /* no bad set count */
340 pcon
.pc_p
= (void *) (smt
+ 1) ; /* paras start here */
343 * check authoriziation and set count
347 if (!local
&& smt_authorize(smc
,req
))
348 error
= SMT_RDF_AUTHOR
;
349 else if (smt_check_set_count(smc
,req
))
350 pcon
.pc_badset
= SMT_RDF_BADSET
;
353 * add reason code and all mandatory parameters
355 res
= (struct smt_p_reason
*) pcon
.pc_p
;
356 smt_add_para(smc
,&pcon
,(u_short
) SMT_P_REASON
,0,0) ;
357 smt_add_para(smc
,&pcon
,(u_short
) SMT_P1033
,0,0) ;
358 /* update 1035 and 1036 later if set */
360 smt_add_para(smc
,&pcon
,(u_short
) SMT_P1035
,0,0) ;
361 smt_add_para(smc
,&pcon
,(u_short
) SMT_P1036
,0,0) ;
363 pcon
.pc_err
= error
;
365 pa
= (struct smt_para
*) (req
+ 1) ;
367 * process list of paras
369 while (!pcon
.pc_err
&& len
> 0 ) {
370 if (((u_short
)len
< pa
->p_len
+ PARA_LEN
) || (pa
->p_len
& 3)) {
371 pcon
.pc_err
= SMT_RDF_LENGTH
;
375 if (((range
= (pa
->p_type
& 0xf000)) == 0x2000) ||
376 range
== 0x3000 || range
== 0x4000) {
378 * get index for PART,MAC ad PATH group
380 index
= *((u_char
*)pa
+ PARA_LEN
+ 3) ;/* index */
382 if (!set
&& (pa
->p_len
!= 4)) {
383 pcon
.pc_err
= SMT_RDF_LENGTH
;
386 if (!index
&& !set
) {
390 idx_end
= index
- 1 + NUMMACS
;
394 idx_end
= index
- 1 + NUMPATHS
;
398 idx_end
= index
- 1 + NUMPHYS
;
400 if (smc
->s
.sas
== SMT_SAS
)
401 idx_end
= INDEX_PORT
;
409 * smt group has no index
411 if (!set
&& (pa
->p_len
!= 0)) {
412 pcon
.pc_err
= SMT_RDF_LENGTH
;
418 while (index
<= idx_end
) {
421 * add all paras of group
423 pt
= smt_get_ptab(pa
->p_type
) ;
424 if (pt
&& pt
->p_access
== AC_GROUP
&& !set
) {
426 while (pt
->p_access
== AC_G
||
427 pt
->p_access
== AC_GR
) {
428 smt_add_para(smc
,&pcon
,pt
->p_num
,
435 * AUTHORIZATION in get/set
438 else if (pa
->p_type
!= SMT_P_AUTHOR
&&
439 (!set
|| (pa
->p_type
!= SMT_P1035
))) {
441 if (pcon
.pc_badset
) {
442 smt_add_para(smc
,&pcon
,pa
->p_type
,
446 st
= smt_set_para(smc
,pa
,index
,local
,1);
448 * return para even if error
450 smt_add_para(smc
,&pcon
,pa
->p_type
,
455 if (pt
&& pt
->p_access
== AC_S
) {
459 smt_add_para(smc
,&pcon
,pa
->p_type
,
467 len
-= pa
->p_len
+ PARA_LEN
;
468 pa
= (struct smt_para
*) ((char *)pa
+ pa
->p_len
+ PARA_LEN
) ;
470 smt
->smt_len
= SMT_MAX_INFO_LEN
- pcon
.pc_len
;
471 mb
->sm_len
= smt
->smt_len
+ sizeof(struct smt_header
) ;
473 /* update reason code */
474 res
->rdf_reason
= pcon
.pc_badset
? pcon
.pc_badset
:
475 pcon
.pc_err
? pcon
.pc_err
: SMT_RDF_SUCCESS
;
476 if (set
&& (res
->rdf_reason
== SMT_RDF_SUCCESS
)) {
478 * increment set count
480 * store station id of last set
482 smc
->mib
.fddiSMTSetCount
.count
++ ;
483 smt_set_timestamp(smc
,smc
->mib
.fddiSMTSetCount
.timestamp
) ;
484 smc
->mib
.fddiSMTLastSetStationId
= req
->smt_sid
;
485 smt_add_para(smc
,&set_pcon
,(u_short
) SMT_P1035
,0,0) ;
486 smt_add_para(smc
,&set_pcon
,(u_short
) SMT_P1036
,0,0) ;
491 static int smt_authorize(struct s_smc
*smc
, struct smt_header
*sm
)
493 struct smt_para
*pa
;
498 * check source station id if not zero
500 p
= (char *) &smc
->mib
.fddiPRPMFStation
;
501 for (i
= 0 ; i
< 8 && !p
[i
] ; i
++)
504 if (memcmp((char *) &sm
->smt_sid
,
505 (char *) &smc
->mib
.fddiPRPMFStation
,8))
509 * check authoriziation parameter if passwd not zero
511 p
= (char *) smc
->mib
.fddiPRPMFPasswd
;
512 for (i
= 0 ; i
< 8 && !p
[i
] ; i
++)
515 pa
= (struct smt_para
*) sm_to_para(smc
,sm
,SMT_P_AUTHOR
) ;
520 if (memcmp((char *)(pa
+1),(char *)smc
->mib
.fddiPRPMFPasswd
,8))
526 static int smt_check_set_count(struct s_smc
*smc
, struct smt_header
*sm
)
528 struct smt_para
*pa
;
529 struct smt_p_setcount
*sc
;
531 pa
= (struct smt_para
*) sm_to_para(smc
,sm
,SMT_P1035
) ;
533 sc
= (struct smt_p_setcount
*) pa
;
534 if ((smc
->mib
.fddiSMTSetCount
.count
!= sc
->count
) ||
535 memcmp((char *) smc
->mib
.fddiSMTSetCount
.timestamp
,
536 (char *)sc
->timestamp
,8))
542 void smt_add_para(struct s_smc
*smc
, struct s_pcon
*pcon
, u_short para
,
543 int index
, int local
)
545 struct smt_para
*pa
;
546 const struct s_p_tab
*pt
;
547 struct fddi_mib_m
*mib_m
= NULL
;
548 struct fddi_mib_p
*mib_p
= NULL
;
569 * actions don't have a value
571 pt
= smt_get_ptab(para
) ;
572 if (pt
&& pt
->p_access
== AC_S
)
575 to
= (char *) (pcon
->pc_p
) ; /* destination pointer */
576 len
= pcon
->pc_len
; /* free space */
577 plen
= len
; /* remember start length */
578 pa
= (struct smt_para
*) to
; /* type/length pointer */
579 to
+= PARA_LEN
; /* skip smt_para */
582 * set index if required
584 if (((range
= (para
& 0xf000)) == 0x2000) ||
585 range
== 0x3000 || range
== 0x4000) {
595 mac
= index
- INDEX_MAC
;
596 path
= index
- INDEX_PATH
;
597 port
= index
- INDEX_PORT
;
604 mib_addr
= (char *) (&smc
->mib
) ;
607 if (mac
< 0 || mac
>= NUMMACS
) {
608 pcon
->pc_err
= SMT_RDF_NOPARAM
;
611 mib_addr
= (char *) (&smc
->mib
.m
[mac
]) ;
612 mib_m
= (struct fddi_mib_m
*) mib_addr
;
615 if (path
< 0 || path
>= NUMPATHS
) {
616 pcon
->pc_err
= SMT_RDF_NOPARAM
;
619 mib_addr
= (char *) (&smc
->mib
.a
[path
]) ;
622 if (port
< 0 || port
>= smt_mib_phys(smc
)) {
623 pcon
->pc_err
= SMT_RDF_NOPARAM
;
626 mib_addr
= (char *) (&smc
->mib
.p
[port_to_mib(smc
,port
)]) ;
627 mib_p
= (struct fddi_mib_p
*) mib_addr
;
631 * check special paras
651 pcon
->pc_err
= SMT_RDF_NOPARAM
;
661 mac_update_counter(smc
) ;
664 mib_p
->fddiPORTPC_LS
= LS2MIB(
665 sm_pm_get_ls(smc
,port_to_mib(smc
,port
))) ;
671 case SMT_P1033
: /* time stamp */
672 smt_set_timestamp(smc
,smc
->mib
.fddiSMTTimeStamp
) ;
675 case SMT_P1020
: /* port indexes */
677 swap
= "IIIIIIIIIIII" ;
680 if (smc
->s
.sas
== SMT_SAS
)
686 swap
= "IIIIIIIIIIIIIIIIIIIIIIII" ;
695 sp_len
= cem_build_path(smc
,to
,path
) ;
698 case SMT_P1048
: /* peer wrap condition */
700 struct smt_p_1048
*sp
;
701 sp
= (struct smt_p_1048
*) to
;
702 sp
->p1048_flag
= smc
->mib
.fddiSMTPeerWrapFlag
;
703 sp
->p1048_cf_state
= smc
->mib
.fddiSMTCF_State
;
704 sp_len
= sizeof(struct smt_p_1048
) ;
709 struct smt_p_208c
*sp
;
710 sp
= (struct smt_p_208c
*) to
;
712 smc
->mib
.m
[MAC0
].fddiMACDuplicateAddressCond
;
713 sp
->p208c_dupcondition
=
714 (mib_m
->fddiMACDA_Flag
? SMT_ST_MY_DUPA
: 0) |
715 (mib_m
->fddiMACUNDA_Flag
? SMT_ST_UNA_DUPA
: 0);
717 mib_m
->fddiMACSMTAddress
;
718 sp
->p208c_fddiunalong
=
719 mib_m
->fddiMACUpstreamNbr
;
721 sp_len
= sizeof(struct smt_p_208c
) ;
724 case SMT_P208D
: /* frame error condition */
726 struct smt_p_208d
*sp
;
727 sp
= (struct smt_p_208d
*) to
;
729 mib_m
->fddiMACFrameErrorFlag
;
731 mib_m
->fddiMACFrame_Ct
;
733 mib_m
->fddiMACError_Ct
;
735 mib_m
->fddiMACLost_Ct
;
737 mib_m
->fddiMACFrameErrorRatio
;
738 sp_len
= sizeof(struct smt_p_208d
) ;
741 case SMT_P208E
: /* not copied condition */
743 struct smt_p_208e
*sp
;
744 sp
= (struct smt_p_208e
*) to
;
746 mib_m
->fddiMACNotCopiedFlag
;
747 sp
->p208e_not_copied
=
748 mib_m
->fddiMACNotCopied_Ct
;
750 mib_m
->fddiMACCopied_Ct
;
751 sp
->p208e_not_copied_ratio
=
752 mib_m
->fddiMACNotCopiedRatio
;
753 sp_len
= sizeof(struct smt_p_208e
) ;
756 case SMT_P208F
: /* neighbor change event */
758 struct smt_p_208f
*sp
;
759 sp
= (struct smt_p_208f
*) to
;
761 mib_m
->fddiMACMultiple_N
;
762 sp
->p208f_nacondition
=
763 mib_m
->fddiMACDuplicateAddressCond
;
765 mib_m
->fddiMACOldUpstreamNbr
;
767 mib_m
->fddiMACUpstreamNbr
;
769 mib_m
->fddiMACOldDownstreamNbr
;
771 mib_m
->fddiMACDownstreamNbr
;
772 sp
->p208f_curren_path
=
773 mib_m
->fddiMACCurrentPath
;
774 sp
->p208f_smt_address
=
775 mib_m
->fddiMACSMTAddress
;
776 sp_len
= sizeof(struct smt_p_208f
) ;
781 struct smt_p_2090
*sp
;
782 sp
= (struct smt_p_2090
*) to
;
784 mib_m
->fddiMACMultiple_P
;
785 sp
->p2090_availablepaths
=
786 mib_m
->fddiMACAvailablePaths
;
787 sp
->p2090_currentpath
=
788 mib_m
->fddiMACCurrentPath
;
789 sp
->p2090_requestedpaths
=
790 mib_m
->fddiMACRequestedPaths
;
791 sp_len
= sizeof(struct smt_p_2090
) ;
796 struct smt_p_4050
*sp
;
797 sp
= (struct smt_p_4050
*) to
;
799 mib_p
->fddiPORTLerFlag
;
802 mib_p
->fddiPORTLer_Cutoff
;
804 mib_p
->fddiPORTLer_Alarm
;
806 mib_p
->fddiPORTLer_Estimate
;
807 sp
->p4050_reject_ct
=
808 mib_p
->fddiPORTLem_Reject_Ct
;
810 mib_p
->fddiPORTLem_Ct
;
811 sp_len
= sizeof(struct smt_p_4050
) ;
817 struct smt_p_4051
*sp
;
818 sp
= (struct smt_p_4051
*) to
;
820 mib_p
->fddiPORTMultiple_U
;
822 mib_p
->fddiPORTMy_Type
;
823 sp
->p4051_connectstate
=
824 mib_p
->fddiPORTConnectState
;
825 sp
->p4051_pc_neighbor
=
826 mib_p
->fddiPORTNeighborType
;
827 sp
->p4051_pc_withhold
=
828 mib_p
->fddiPORTPC_Withhold
;
829 sp_len
= sizeof(struct smt_p_4051
) ;
834 struct smt_p_4052
*sp
;
835 sp
= (struct smt_p_4052
*) to
;
837 mib_p
->fddiPORTEB_Condition
;
838 sp
->p4052_eberrorcount
=
839 mib_p
->fddiPORTEBError_Ct
;
840 sp_len
= sizeof(struct smt_p_4052
) ;
845 struct smt_p_4053
*sp
;
846 sp
= (struct smt_p_4053
*) to
;
848 mib_p
->fddiPORTMultiple_P
;
849 sp
->p4053_availablepaths
=
850 mib_p
->fddiPORTAvailablePaths
;
851 sp
->p4053_currentpath
=
852 mib_p
->fddiPORTCurrentPath
;
853 memcpy( (char *) &sp
->p4053_requestedpaths
,
854 (char *) mib_p
->fddiPORTRequestedPaths
,4) ;
856 mib_p
->fddiPORTMy_Type
;
857 sp
->p4053_neighbortype
=
858 mib_p
->fddiPORTNeighborType
;
859 sp_len
= sizeof(struct smt_p_4053
) ;
869 pcon
->pc_err
= (para
& 0xff00) ? SMT_RDF_NOPARAM
:
874 * check access rights
876 switch (pt
->p_access
) {
881 pcon
->pc_err
= SMT_RDF_ILLEGAL
;
884 from
= mib_addr
+ pt
->p_offset
;
886 swap
= pt
->p_swap
; /* pointer to swap string */
891 while ((c
= *swap
++)) {
921 case 'I' : /* for SET of port indexes */
964 case '2' : /* PortMacIndicated */
989 memcpy((char *) to
+2,(char *) from
,6) ;
997 memcpy((char *) to
,(char *) from
,8) ;
1005 memcpy((char *) to
,(char *) from
,32) ;
1010 case 'P' : /* timestamp is NOT swapped */
1025 SMT_PANIC(smc
,SMT_E0119
, SMT_E0119_MSG
) ;
1032 * make it even (in case of 'I' encoding)
1033 * note: len is DECREMENTED
1038 to
+= 4 - (len
& 3 ) ;
1042 /* set type and length */
1044 pa
->p_len
= plen
- len
- PARA_LEN
;
1046 pcon
->pc_p
= (void *) to
;
1047 pcon
->pc_len
= len
;
1056 /* parameter does not fit in frame */
1057 pcon
->pc_err
= SMT_RDF_TOOLONG
;
1061 pcon
->pc_err
= SMT_RDF_LENGTH
;
1067 static int smt_set_para(struct s_smc
*smc
, struct smt_para
*pa
, int index
,
1070 #define IFSET(x) if (set) (x)
1072 const struct s_p_tab
*pt
;
1079 struct fddi_mib
*mib
;
1080 struct fddi_mib_m
*mib_m
= NULL
;
1081 struct fddi_mib_a
*mib_a
= NULL
;
1082 struct fddi_mib_p
*mib_p
= NULL
;
1086 SK_LOC_DECL(u_char
,byte_val
) ;
1087 SK_LOC_DECL(u_short
,word_val
) ;
1088 SK_LOC_DECL(u_long
,long_val
) ;
1090 mac
= index
- INDEX_MAC
;
1091 path
= index
- INDEX_PATH
;
1092 port
= index
- INDEX_PORT
;
1094 from
= (char *) (pa
+ 1 ) ;
1097 switch (pa
->p_type
& 0xf000) {
1100 mib_addr
= (char *) mib
;
1103 if (mac
< 0 || mac
>= NUMMACS
) {
1104 return SMT_RDF_NOPARAM
;
1106 mib_m
= &smc
->mib
.m
[mac
] ;
1107 mib_addr
= (char *) mib_m
;
1108 from
+= 4 ; /* skip index */
1112 if (path
< 0 || path
>= NUMPATHS
) {
1113 return SMT_RDF_NOPARAM
;
1115 mib_a
= &smc
->mib
.a
[path
] ;
1116 mib_addr
= (char *) mib_a
;
1117 from
+= 4 ; /* skip index */
1121 if (port
< 0 || port
>= smt_mib_phys(smc
)) {
1122 return SMT_RDF_NOPARAM
;
1124 mib_p
= &smc
->mib
.p
[port_to_mib(smc
,port
)] ;
1125 mib_addr
= (char *) mib_p
;
1126 from
+= 4 ; /* skip index */
1130 switch (pa
->p_type
) {
1147 return SMT_RDF_NOPARAM
;
1150 pt
= smt_get_ptab(pa
->p_type
) ;
1152 return (pa
->p_type
& 0xff00) ? SMT_RDF_NOPARAM
:
1154 switch (pt
->p_access
) {
1159 return SMT_RDF_ILLEGAL
;
1161 to
= mib_addr
+ pt
->p_offset
;
1162 swap
= pt
->p_swap
; /* pointer to swap string */
1164 while (swap
&& (c
= *swap
++)) {
1167 to
= (char *) &byte_val
;
1170 to
= (char *) &word_val
;
1173 to
= (char *) &long_val
;
1182 if (from
[0] | from
[1])
1184 #ifdef LITTLE_ENDIAN
1206 if (from
[0] | from
[1] | from
[2])
1219 #ifdef LITTLE_ENDIAN
1237 memcpy(to
,from
+2,6) ;
1264 memcpy(to
,from
,32) ;
1269 case 'P' : /* timestamp is NOT swapped */
1284 SMT_PANIC(smc
,SMT_E0120
, SMT_E0120_MSG
) ;
1285 return SMT_RDF_ILLEGAL
;
1289 * actions and internal updates
1291 switch (pa
->p_type
) {
1292 case SMT_P101A
: /* fddiSMTConfigPolicy */
1295 IFSET(mib
->fddiSMTConfigPolicy
= word_val
) ;
1297 case SMT_P101B
: /* fddiSMTConnectionPolicy */
1298 if (!(word_val
& POLICY_MM
))
1300 IFSET(mib
->fddiSMTConnectionPolicy
= word_val
) ;
1302 case SMT_P101D
: /* fddiSMTTT_Notify */
1303 if (word_val
< 2 || word_val
> 30)
1305 IFSET(mib
->fddiSMTTT_Notify
= word_val
) ;
1307 case SMT_P101E
: /* fddiSMTStatRptPolicy */
1310 IFSET(mib
->fddiSMTStatRptPolicy
= byte_val
) ;
1312 case SMT_P101F
: /* fddiSMTTrace_MaxExpiration */
1314 * note: lower limit trace_max = 6.001773... s
1317 if (long_val
< (long)0x478bf51L
)
1319 IFSET(mib
->fddiSMTTrace_MaxExpiration
= long_val
) ;
1322 case SMT_P10F2
: /* fddiESSPayload */
1323 if (long_val
> 1562)
1325 if (set
&& smc
->mib
.fddiESSPayload
!= long_val
) {
1326 smc
->ess
.raf_act_timer_poll
= TRUE
;
1327 smc
->mib
.fddiESSPayload
= long_val
;
1330 case SMT_P10F3
: /* fddiESSOverhead */
1331 if (long_val
< 50 || long_val
> 5000)
1333 if (set
&& smc
->mib
.fddiESSPayload
&&
1334 smc
->mib
.fddiESSOverhead
!= long_val
) {
1335 smc
->ess
.raf_act_timer_poll
= TRUE
;
1336 smc
->mib
.fddiESSOverhead
= long_val
;
1339 case SMT_P10F4
: /* fddiESSMaxTNeg */
1340 if (long_val
> -MS2BCLK(5) || long_val
< -MS2BCLK(165))
1342 IFSET(mib
->fddiESSMaxTNeg
= long_val
) ;
1344 case SMT_P10F5
: /* fddiESSMinSegmentSize */
1345 if (long_val
< 1 || long_val
> 4478)
1347 IFSET(mib
->fddiESSMinSegmentSize
= long_val
) ;
1349 case SMT_P10F6
: /* fddiESSCategory */
1350 if ((long_val
& 0xffff) != 1)
1352 IFSET(mib
->fddiESSCategory
= long_val
) ;
1354 case SMT_P10F7
: /* fddiESSSyncTxMode */
1357 IFSET(mib
->fddiESSSynchTxMode
= word_val
) ;
1361 case SMT_P10F8
: /* fddiSBACommand */
1362 if (byte_val
!= SB_STOP
&& byte_val
!= SB_START
)
1364 IFSET(mib
->fddiSBACommand
= byte_val
) ;
1366 case SMT_P10F9
: /* fddiSBAAvailable */
1369 IFSET(mib
->fddiSBAAvailable
= byte_val
) ;
1372 case SMT_P2020
: /* fddiMACRequestedPaths */
1373 if ((word_val
& (MIB_P_PATH_PRIM_PREFER
|
1374 MIB_P_PATH_PRIM_ALTER
)) == 0 )
1376 IFSET(mib_m
->fddiMACRequestedPaths
= word_val
) ;
1378 case SMT_P205F
: /* fddiMACFrameErrorThreshold */
1379 /* 0 .. ffff acceptable */
1380 IFSET(mib_m
->fddiMACFrameErrorThreshold
= word_val
) ;
1382 case SMT_P2067
: /* fddiMACNotCopiedThreshold */
1383 /* 0 .. ffff acceptable */
1384 IFSET(mib_m
->fddiMACNotCopiedThreshold
= word_val
) ;
1386 case SMT_P2076
: /* fddiMACMA_UnitdataEnable */
1390 mib_m
->fddiMACMA_UnitdataEnable
= byte_val
;
1391 queue_event(smc
,EVENT_RMT
,RM_ENABLE_FLAG
) ;
1394 case SMT_P20F1
: /* fddiMACT_Min */
1395 IFSET(mib_m
->fddiMACT_Min
= long_val
) ;
1398 if (long_val
> 1562)
1400 IFSET(mib_a
->fddiPATHSbaPayload
= long_val
) ;
1403 ess_para_change(smc
) ;
1407 if (long_val
> 5000)
1410 if (long_val
!= 0 && mib_a
->fddiPATHSbaPayload
== 0)
1413 IFSET(mib_a
->fddiPATHSbaOverhead
= long_val
) ;
1416 ess_para_change(smc
) ;
1419 case SMT_P3213
: /* fddiPATHT_Rmode */
1421 * 0 .. 343.597 => 0 .. 2e32 * 80nS
1424 mib_a
->fddiPATHT_Rmode
= long_val
;
1425 rtm_set_timer(smc
) ;
1428 case SMT_P3214
: /* fddiPATHSbaAvailable */
1429 if (long_val
> 0x00BEBC20L
)
1432 if (set
&& mib
->fddiSBACommand
== SB_STOP
)
1435 IFSET(mib_a
->fddiPATHSbaAvailable
= long_val
) ;
1437 case SMT_P3215
: /* fddiPATHTVXLowerBound */
1438 IFSET(mib_a
->fddiPATHTVXLowerBound
= long_val
) ;
1439 goto change_mac_para
;
1440 case SMT_P3216
: /* fddiPATHT_MaxLowerBound */
1441 IFSET(mib_a
->fddiPATHT_MaxLowerBound
= long_val
) ;
1442 goto change_mac_para
;
1443 case SMT_P3217
: /* fddiPATHMaxT_Req */
1444 IFSET(mib_a
->fddiPATHMaxT_Req
= long_val
) ;
1447 if (set
&& smt_set_mac_opvalues(smc
)) {
1448 RS_SET(smc
,RS_EVENT
) ;
1449 smc
->sm
.please_reconnect
= 1 ;
1450 queue_event(smc
,EVENT_ECM
,EC_DISCONNECT
) ;
1453 case SMT_P400E
: /* fddiPORTConnectionPolicies */
1456 IFSET(mib_p
->fddiPORTConnectionPolicies
= byte_val
) ;
1458 case SMT_P4011
: /* fddiPORTRequestedPaths */
1459 /* all 3*8 bits allowed */
1460 IFSET(memcpy((char *)mib_p
->fddiPORTRequestedPaths
,
1461 (char *)&long_val
,4)) ;
1463 case SMT_P401F
: /* fddiPORTMaint_LS */
1466 IFSET(mib_p
->fddiPORTMaint_LS
= word_val
) ;
1468 case SMT_P403A
: /* fddiPORTLer_Cutoff */
1469 if (byte_val
< 4 || byte_val
> 15)
1471 IFSET(mib_p
->fddiPORTLer_Cutoff
= byte_val
) ;
1473 case SMT_P403B
: /* fddiPORTLer_Alarm */
1474 if (byte_val
< 4 || byte_val
> 15)
1476 IFSET(mib_p
->fddiPORTLer_Alarm
= byte_val
) ;
1482 case SMT_P103C
: /* fddiSMTStationAction */
1483 if (smt_action(smc
,SMT_STATION_ACTION
, (int) word_val
, 0))
1486 case SMT_P4046
: /* fddiPORTAction */
1487 if (smt_action(smc
,SMT_PORT_ACTION
, (int) word_val
,
1488 port_to_mib(smc
,port
)))
1497 /* parameter value in frame is out of range */
1498 return SMT_RDF_RANGE
;
1501 /* parameter value in frame is too short */
1502 return SMT_RDF_LENGTH
;
1506 /* parameter not setable, because the SBA is not active
1507 * Please note: we give the return code 'not authorizeed
1508 * because SBA denied is not a valid return code in the
1511 return SMT_RDF_AUTHOR
;
1515 static const struct s_p_tab
*smt_get_ptab(u_short para
)
1517 const struct s_p_tab
*pt
;
1518 for (pt
= p_tab
; pt
->p_num
&& pt
->p_num
!= para
; pt
++)
1520 return pt
->p_num
? pt
: NULL
;
1523 static int smt_mib_phys(struct s_smc
*smc
)
1530 if (smc
->s
.sas
== SMT_SAS
)
1536 static int port_to_mib(struct s_smc
*smc
, int p
)
1543 if (smc
->s
.sas
== SMT_SAS
)
1552 void dump_smt(struct s_smc
*smc
, struct smt_header
*sm
, char *text
)
1555 struct smt_para
*pa
;
1559 #ifdef LITTLE_ENDIAN
1566 if (smc
->debug
.d_smtf
< 2)
1568 if (debug
.d_smtf
< 2)
1571 #ifdef LITTLE_ENDIAN
1572 smtlen
= sm
->smt_len
+ sizeof(struct smt_header
) ;
1574 printf("SMT Frame [%s]:\nDA ",text
) ;
1575 dump_hex((char *) &sm
->smt_dest
,6) ;
1577 dump_hex((char *) &sm
->smt_source
,6) ;
1578 printf(" Class %x Type %x Version %x\n",
1579 sm
->smt_class
,sm
->smt_type
,sm
->smt_version
) ;
1580 printf("TID %x\t\tSID ", sm
->smt_tid
);
1581 dump_hex((char *) &sm
->smt_sid
,8) ;
1582 printf(" LEN %x\n",sm
->smt_len
) ;
1585 pa
= (struct smt_para
*) (sm
+ 1) ;
1589 printf("TYPE %x LEN %x VALUE\t",pa
->p_type
,pa
->p_len
) ;
1591 printf("TYPE %04x LEN %2x VALUE\t",pa
->p_type
,pa
->p_len
) ;
1594 if ( (n
< 0 ) || (n
> (int)(len
- PARA_LEN
))) {
1595 n
= len
- PARA_LEN
;
1596 printf(" BAD LENGTH\n") ;
1599 #ifdef LITTLE_ENDIAN
1600 smt_swap_para(sm
,smtlen
,0) ;
1603 dump_hex((char *)(pa
+1),(int) n
) ;
1608 c
= (char *)(pa
+1) ;
1614 nn
= (n
> 16) ? 16 : n
;
1617 printf("\t\t\t...\n") ;
1629 #ifdef LITTLE_ENDIAN
1630 smt_swap_para(sm
,smtlen
,1) ;
1632 plen
= (pa
->p_len
+ PARA_LEN
+ 3) & ~3 ;
1634 pa
= (struct smt_para
*)((char *)pa
+ plen
) ;
1636 printf("-------------------------------------------------\n\n") ;
1639 void dump_hex(char *p
, int len
)
1645 printf("%x%s",*p
++ & 0xff,len
? ( (n
& 7) ? " " : "-") : "") ;
1647 printf("%02x%s",*p
++ & 0xff,len
? ( (n
& 7) ? " " : "-") : "") ;
1651 #endif /* no BOOT */
1655 #endif /* no SLIM_SMT */