blob: 2e7924d011a32e1c5269b34f3cd64f33fd2e37ef [file] [log] [blame]
wdenk7152b1d2003-09-05 23:19:14 +00001/******************************************************************************
2 *
3 * Name: skrlmt.c
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
5 * Version: $Revision: 1.68 $
6 * Date: $Date: 2003/01/31 15:26:56 $
7 * Purpose: Manage links on SK-NET Adapters, esp. redundant ones.
8 *
9 ******************************************************************************/
10
11/******************************************************************************
12 *
13 * (C)Copyright 1998-2001 SysKonnect GmbH.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * The information in this file is provided "AS IS" without warranty.
21 *
22 ******************************************************************************/
23
24/******************************************************************************
25 *
26 * History:
27 *
28 * $Log: skrlmt.c,v $
29 * Revision 1.68 2003/01/31 15:26:56 rschmidt
30 * Added init for local variables in RlmtInit().
wdenk42d1f032003-10-15 23:53:47 +000031 *
wdenk7152b1d2003-09-05 23:19:14 +000032 * Revision 1.67 2003/01/31 14:12:41 mkunz
33 * single port adapter runs now with two identical MAC addresses
wdenk42d1f032003-10-15 23:53:47 +000034 *
wdenk7152b1d2003-09-05 23:19:14 +000035 * Revision 1.66 2002/09/23 15:14:19 rwahl
36 * - Reset broadcast timestamp on link down.
37 * - Editorial corrections.
wdenk42d1f032003-10-15 23:53:47 +000038 *
wdenk7152b1d2003-09-05 23:19:14 +000039 * Revision 1.65 2002/07/22 14:29:48 rwahl
40 * - Removed BRK statement from debug check.
wdenk42d1f032003-10-15 23:53:47 +000041 *
wdenk7152b1d2003-09-05 23:19:14 +000042 * Revision 1.64 2001/11/28 19:36:14 rwahl
43 * - RLMT Packets sent to an invalid MAC address in CLP/CLPSS mode
44 * (#10650).
45 * - Reworked fix for port switching in CLS mode (#10639)
46 * (no dependency to RLMT module).
47 * - Enabled dbg output for entry/exit of event functions.
48 * - Editorial changes.
wdenk42d1f032003-10-15 23:53:47 +000049 *
wdenk7152b1d2003-09-05 23:19:14 +000050 * Revision 1.63 2001/10/26 07:53:18 afischer
51 * Port switching bug in `check local link` mode
wdenk42d1f032003-10-15 23:53:47 +000052 *
wdenk7152b1d2003-09-05 23:19:14 +000053 * Revision 1.62 2001/07/03 12:16:30 mkunz
54 * New Flag ChgBcPrio (Change priority of last broadcast received)
wdenk42d1f032003-10-15 23:53:47 +000055 *
wdenk7152b1d2003-09-05 23:19:14 +000056 * Revision 1.61 2001/03/14 12:52:08 rassmann
57 * Fixed reporting of active port up/down to PNMI.
wdenk42d1f032003-10-15 23:53:47 +000058 *
wdenk7152b1d2003-09-05 23:19:14 +000059 * Revision 1.60 2001/02/21 16:02:25 gklug
60 * fix: when RLMT starts set Active Port for PNMI
wdenk42d1f032003-10-15 23:53:47 +000061 *
wdenk7152b1d2003-09-05 23:19:14 +000062 * Revision 1.59 2001/02/16 14:38:19 rassmann
63 * Initializing some pointers earlier in the init phase.
64 * Rx Mbufs are freed if the net which they belong to is stopped.
wdenk42d1f032003-10-15 23:53:47 +000065 *
wdenk7152b1d2003-09-05 23:19:14 +000066 * Revision 1.58 2001/02/14 14:06:31 rassmann
67 * Editorial changes.
wdenk42d1f032003-10-15 23:53:47 +000068 *
wdenk7152b1d2003-09-05 23:19:14 +000069 * Revision 1.57 2001/02/05 14:25:26 rassmann
70 * Prepared RLMT for transparent operation.
wdenk42d1f032003-10-15 23:53:47 +000071 *
wdenk7152b1d2003-09-05 23:19:14 +000072 * Revision 1.56 2001/01/30 10:29:09 rassmann
73 * Not checking switching befor RlmtStart.
74 * Editorial changes.
wdenk42d1f032003-10-15 23:53:47 +000075 *
wdenk7152b1d2003-09-05 23:19:14 +000076 * Revision 1.55 2001/01/22 13:41:38 rassmann
77 * Supporting two nets on dual-port adapters.
wdenk42d1f032003-10-15 23:53:47 +000078 *
wdenk7152b1d2003-09-05 23:19:14 +000079 * Revision 1.54 2000/11/30 13:25:07 rassmann
80 * Setting SK_TICK_INCR to 1 by default.
wdenk42d1f032003-10-15 23:53:47 +000081 *
wdenk7152b1d2003-09-05 23:19:14 +000082 * Revision 1.53 2000/11/30 10:48:07 cgoos
83 * Changed definition of SK_RLMT_BC_DELTA.
wdenk42d1f032003-10-15 23:53:47 +000084 *
wdenk7152b1d2003-09-05 23:19:14 +000085 * Revision 1.52 2000/11/27 12:50:03 rassmann
86 * Checking ports after receiving broadcasts.
wdenk42d1f032003-10-15 23:53:47 +000087 *
wdenk7152b1d2003-09-05 23:19:14 +000088 * Revision 1.51 2000/11/17 08:58:00 rassmann
89 * Moved CheckSwitch from SK_RLMT_PACKET_RECEIVED to SK_RLMT_TIM event.
wdenk42d1f032003-10-15 23:53:47 +000090 *
wdenk7152b1d2003-09-05 23:19:14 +000091 * Revision 1.50 2000/11/09 12:24:34 rassmann
92 * Indicating that segmentation check is not running anymore after
93 * SkRlmtCheckSeg().
94 * Restarting segmentation timer after segmentation log.
95 * Editorial changes.
wdenk42d1f032003-10-15 23:53:47 +000096 *
wdenk7152b1d2003-09-05 23:19:14 +000097 * Revision 1.49 1999/11/22 13:38:02 cgoos
98 * Changed license header to GPL.
99 * Added initialization to some variables to avoid compiler warnings.
wdenk42d1f032003-10-15 23:53:47 +0000100 *
wdenk7152b1d2003-09-05 23:19:14 +0000101 * Revision 1.48 1999/10/04 14:01:17 rassmann
102 * Corrected reaction to reception of BPDU frames (#10441).
wdenk42d1f032003-10-15 23:53:47 +0000103 *
wdenk7152b1d2003-09-05 23:19:14 +0000104 * Revision 1.47 1999/07/20 12:53:36 rassmann
105 * Fixed documentation errors for lookahead macros.
wdenk42d1f032003-10-15 23:53:47 +0000106 *
wdenk7152b1d2003-09-05 23:19:14 +0000107 * Revision 1.46 1999/05/28 13:29:16 rassmann
108 * Replaced C++-style comment.
wdenk42d1f032003-10-15 23:53:47 +0000109 *
wdenk7152b1d2003-09-05 23:19:14 +0000110 * Revision 1.45 1999/05/28 13:28:08 rassmann
111 * Corrected syntax error (xxx).
wdenk42d1f032003-10-15 23:53:47 +0000112 *
wdenk7152b1d2003-09-05 23:19:14 +0000113 * Revision 1.44 1999/05/28 11:15:54 rassmann
114 * Changed behaviour to reflect Design Spec v1.2.
115 * Controlling Link LED(s).
116 * Introduced RLMT Packet Version field in RLMT Packet.
117 * Newstyle lookahead macros (checking meta-information before looking at
118 * the packet).
wdenk42d1f032003-10-15 23:53:47 +0000119 *
wdenk7152b1d2003-09-05 23:19:14 +0000120 * Revision 1.43 1999/01/28 13:12:43 rassmann
121 * Corrected Lookahead (bug introduced in previous Rev.).
wdenk42d1f032003-10-15 23:53:47 +0000122 *
wdenk7152b1d2003-09-05 23:19:14 +0000123 * Revision 1.42 1999/01/28 12:50:41 rassmann
124 * Not using broadcast time stamps in CheckLinkState mode.
wdenk42d1f032003-10-15 23:53:47 +0000125 *
wdenk7152b1d2003-09-05 23:19:14 +0000126 * Revision 1.41 1999/01/27 14:13:02 rassmann
127 * Monitoring broadcast traffic.
128 * Switching more reliably and not too early if switch is
129 * configured for spanning tree.
wdenk42d1f032003-10-15 23:53:47 +0000130 *
wdenk7152b1d2003-09-05 23:19:14 +0000131 * Revision 1.40 1999/01/22 13:17:30 rassmann
132 * Informing PNMI of NET_UP.
133 * Clearing RLMT multicast addresses before setting them for the first time.
134 * Reporting segmentation earlier, setting a "quiet time"
135 * after a report.
wdenk42d1f032003-10-15 23:53:47 +0000136 *
wdenk7152b1d2003-09-05 23:19:14 +0000137 * Revision 1.39 1998/12/10 15:29:53 rassmann
138 * Corrected SuspectStatus in SkRlmtBuildCheckChain().
139 * Corrected CHECK_SEG mode.
wdenk42d1f032003-10-15 23:53:47 +0000140 *
wdenk7152b1d2003-09-05 23:19:14 +0000141 * Revision 1.38 1998/12/08 13:11:23 rassmann
142 * Stopping SegTimer at RlmtStop.
wdenk42d1f032003-10-15 23:53:47 +0000143 *
wdenk7152b1d2003-09-05 23:19:14 +0000144 * Revision 1.37 1998/12/07 16:51:42 rassmann
145 * Corrected comments.
wdenk42d1f032003-10-15 23:53:47 +0000146 *
wdenk7152b1d2003-09-05 23:19:14 +0000147 * Revision 1.36 1998/12/04 10:58:56 rassmann
148 * Setting next pointer to NULL when receiving.
wdenk42d1f032003-10-15 23:53:47 +0000149 *
wdenk7152b1d2003-09-05 23:19:14 +0000150 * Revision 1.35 1998/12/03 16:12:42 rassmann
151 * Ignoring/correcting illegal PrefPort values.
wdenk42d1f032003-10-15 23:53:47 +0000152 *
wdenk7152b1d2003-09-05 23:19:14 +0000153 * Revision 1.34 1998/12/01 11:45:35 rassmann
154 * Code cleanup.
wdenk42d1f032003-10-15 23:53:47 +0000155 *
wdenk7152b1d2003-09-05 23:19:14 +0000156 * Revision 1.33 1998/12/01 10:29:32 rassmann
157 * Starting standby ports before getting the net up.
158 * Checking if a port is started when the link comes up.
wdenk42d1f032003-10-15 23:53:47 +0000159 *
wdenk7152b1d2003-09-05 23:19:14 +0000160 * Revision 1.32 1998/11/30 16:19:50 rassmann
161 * New default for PortNoRx.
wdenk42d1f032003-10-15 23:53:47 +0000162 *
wdenk7152b1d2003-09-05 23:19:14 +0000163 * Revision 1.31 1998/11/27 19:17:13 rassmann
164 * Corrected handling of LINK_DOWN coming shortly after LINK_UP.
wdenk42d1f032003-10-15 23:53:47 +0000165 *
wdenk7152b1d2003-09-05 23:19:14 +0000166 * Revision 1.30 1998/11/24 12:37:31 rassmann
167 * Implemented segmentation check.
wdenk42d1f032003-10-15 23:53:47 +0000168 *
wdenk7152b1d2003-09-05 23:19:14 +0000169 * Revision 1.29 1998/11/18 13:04:32 rassmann
170 * Secured PortUpTimer event.
171 * Waiting longer before starting standby port(s).
wdenk42d1f032003-10-15 23:53:47 +0000172 *
wdenk7152b1d2003-09-05 23:19:14 +0000173 * Revision 1.28 1998/11/17 13:43:04 rassmann
174 * Handling (logical) tx failure.
175 * Sending packet on logical address after PORT_SWITCH.
wdenk42d1f032003-10-15 23:53:47 +0000176 *
wdenk7152b1d2003-09-05 23:19:14 +0000177 * Revision 1.27 1998/11/13 17:09:50 rassmann
178 * Secured some events against being called in wrong state.
wdenk42d1f032003-10-15 23:53:47 +0000179 *
wdenk7152b1d2003-09-05 23:19:14 +0000180 * Revision 1.26 1998/11/13 16:56:54 rassmann
181 * Added macro version of SkRlmtLookaheadPacket.
wdenk42d1f032003-10-15 23:53:47 +0000182 *
wdenk7152b1d2003-09-05 23:19:14 +0000183 * Revision 1.25 1998/11/06 18:06:04 rassmann
184 * Corrected timing when RLMT checks fail.
185 * Clearing tx counter earlier in periodical checks.
wdenk42d1f032003-10-15 23:53:47 +0000186 *
wdenk7152b1d2003-09-05 23:19:14 +0000187 * Revision 1.24 1998/11/05 10:37:27 rassmann
188 * Checking destination address in Lookahead.
wdenk42d1f032003-10-15 23:53:47 +0000189 *
wdenk7152b1d2003-09-05 23:19:14 +0000190 * Revision 1.23 1998/11/03 13:53:49 rassmann
191 * RLMT should switch now (at least in mode 3).
wdenk42d1f032003-10-15 23:53:47 +0000192 *
wdenk7152b1d2003-09-05 23:19:14 +0000193 * Revision 1.22 1998/10/29 14:34:49 rassmann
194 * Clearing SK_RLMT struct at startup.
195 * Initializing PortsUp during SK_RLMT_START.
wdenk42d1f032003-10-15 23:53:47 +0000196 *
wdenk7152b1d2003-09-05 23:19:14 +0000197 * Revision 1.21 1998/10/28 11:30:17 rassmann
198 * Default mode is now SK_RLMT_CHECK_LOC_LINK.
wdenk42d1f032003-10-15 23:53:47 +0000199 *
wdenk7152b1d2003-09-05 23:19:14 +0000200 * Revision 1.20 1998/10/26 16:02:03 rassmann
201 * Ignoring LINK_DOWN for links that are down.
wdenk42d1f032003-10-15 23:53:47 +0000202 *
wdenk7152b1d2003-09-05 23:19:14 +0000203 * Revision 1.19 1998/10/22 15:54:01 rassmann
204 * Corrected EtherLen.
205 * Starting Link Check when second port comes up.
wdenk42d1f032003-10-15 23:53:47 +0000206 *
wdenk7152b1d2003-09-05 23:19:14 +0000207 * Revision 1.18 1998/10/22 11:39:50 rassmann
208 * Corrected signed/unsigned mismatches.
209 * Corrected receive list handling and address recognition.
wdenk42d1f032003-10-15 23:53:47 +0000210 *
wdenk7152b1d2003-09-05 23:19:14 +0000211 * Revision 1.17 1998/10/19 17:01:20 rassmann
212 * More detailed checking of received packets.
wdenk42d1f032003-10-15 23:53:47 +0000213 *
wdenk7152b1d2003-09-05 23:19:14 +0000214 * Revision 1.16 1998/10/15 15:16:34 rassmann
215 * Finished Spanning Tree checking.
216 * Checked with lint.
wdenk42d1f032003-10-15 23:53:47 +0000217 *
wdenk7152b1d2003-09-05 23:19:14 +0000218 * Revision 1.15 1998/09/24 19:16:07 rassmann
219 * Code cleanup.
220 * Introduced Timer for PORT_DOWN due to no RX.
wdenk42d1f032003-10-15 23:53:47 +0000221 *
wdenk7152b1d2003-09-05 23:19:14 +0000222 * Revision 1.14 1998/09/18 20:27:14 rassmann
223 * Added address override.
wdenk42d1f032003-10-15 23:53:47 +0000224 *
wdenk7152b1d2003-09-05 23:19:14 +0000225 * Revision 1.13 1998/09/16 11:31:48 rassmann
226 * Including skdrv1st.h again. :(
wdenk42d1f032003-10-15 23:53:47 +0000227 *
wdenk7152b1d2003-09-05 23:19:14 +0000228 * Revision 1.12 1998/09/16 11:09:50 rassmann
229 * Syntax corrections.
wdenk42d1f032003-10-15 23:53:47 +0000230 *
wdenk7152b1d2003-09-05 23:19:14 +0000231 * Revision 1.11 1998/09/15 12:32:03 rassmann
232 * Syntax correction.
wdenk42d1f032003-10-15 23:53:47 +0000233 *
wdenk7152b1d2003-09-05 23:19:14 +0000234 * Revision 1.10 1998/09/15 11:28:49 rassmann
235 * Syntax corrections.
wdenk42d1f032003-10-15 23:53:47 +0000236 *
wdenk7152b1d2003-09-05 23:19:14 +0000237 * Revision 1.9 1998/09/14 17:07:37 rassmann
238 * Added code for port checking via LAN.
239 * Changed Mbuf definition.
wdenk42d1f032003-10-15 23:53:47 +0000240 *
wdenk7152b1d2003-09-05 23:19:14 +0000241 * Revision 1.8 1998/09/07 11:14:14 rassmann
242 * Syntax corrections.
wdenk42d1f032003-10-15 23:53:47 +0000243 *
wdenk7152b1d2003-09-05 23:19:14 +0000244 * Revision 1.7 1998/09/07 09:06:07 rassmann
245 * Syntax corrections.
wdenk42d1f032003-10-15 23:53:47 +0000246 *
wdenk7152b1d2003-09-05 23:19:14 +0000247 * Revision 1.6 1998/09/04 19:41:33 rassmann
248 * Syntax corrections.
249 * Started entering code for checking local links.
wdenk42d1f032003-10-15 23:53:47 +0000250 *
wdenk7152b1d2003-09-05 23:19:14 +0000251 * Revision 1.5 1998/09/04 12:14:27 rassmann
252 * Interface cleanup.
wdenk42d1f032003-10-15 23:53:47 +0000253 *
wdenk7152b1d2003-09-05 23:19:14 +0000254 * Revision 1.4 1998/09/02 16:55:28 rassmann
255 * Updated to reflect new DRV/HWAC/RLMT interface.
wdenk42d1f032003-10-15 23:53:47 +0000256 *
wdenk7152b1d2003-09-05 23:19:14 +0000257 * Revision 1.3 1998/08/27 14:29:03 rassmann
258 * Code cleanup.
wdenk42d1f032003-10-15 23:53:47 +0000259 *
wdenk7152b1d2003-09-05 23:19:14 +0000260 * Revision 1.2 1998/08/27 14:26:24 rassmann
261 * Updated interface.
wdenk42d1f032003-10-15 23:53:47 +0000262 *
wdenk7152b1d2003-09-05 23:19:14 +0000263 * Revision 1.1 1998/08/21 08:26:49 rassmann
264 * First public version.
265 *
266 ******************************************************************************/
267
268/******************************************************************************
269 *
270 * Description:
271 *
272 * This module contains code for Link ManagemenT (LMT) of SK-NET Adapters.
273 * It is mainly intended for adapters with more than one link.
274 * For such adapters, this module realizes Redundant Link ManagemenT (RLMT).
275 *
276 * Include File Hierarchy:
277 *
278 * "skdrv1st.h"
279 * "skdrv2nd.h"
280 *
281 ******************************************************************************/
282
wdenk149dded2003-09-10 18:20:28 +0000283#include <config.h>
284
wdenk7152b1d2003-09-05 23:19:14 +0000285#ifndef lint
286static const char SysKonnectFileId[] =
287 "@(#) $Id: skrlmt.c,v 1.68 2003/01/31 15:26:56 rschmidt Exp $ (C) SysKonnect.";
288#endif /* !defined(lint) */
289
290#define __SKRLMT_C
291
292#ifdef __cplusplus
293#error C++ is not yet supported.
294extern "C" {
295#endif /* cplusplus */
296
297#include "h/skdrv1st.h"
298#include "h/skdrv2nd.h"
299
300/* defines ********************************************************************/
301
302#ifndef SK_HWAC_LINK_LED
303#define SK_HWAC_LINK_LED(a,b,c,d)
304#endif /* !defined(SK_HWAC_LINK_LED) */
305
306#ifndef DEBUG
307#define RLMT_STATIC static
308#else /* DEBUG */
309#define RLMT_STATIC
310
311#ifndef SK_LITTLE_ENDIAN
312/* First 32 bits */
313#define OFFS_LO32 1
314
315/* Second 32 bits */
316#define OFFS_HI32 0
317#else /* SK_LITTLE_ENDIAN */
318/* First 32 bits */
319#define OFFS_LO32 0
320
321/* Second 32 bits */
322#define OFFS_HI32 1
323#endif /* SK_LITTLE_ENDIAN */
324
325#endif /* DEBUG */
326
327/* ----- Private timeout values ----- */
328
329#define SK_RLMT_MIN_TO_VAL 125000 /* 1/8 sec. */
330#define SK_RLMT_DEF_TO_VAL 1000000 /* 1 sec. */
331#define SK_RLMT_PORTDOWN_TIM_VAL 900000 /* another 0.9 sec. */
332#define SK_RLMT_PORTSTART_TIM_VAL 100000 /* 0.1 sec. */
333#define SK_RLMT_PORTUP_TIM_VAL 2500000 /* 2.5 sec. */
334#define SK_RLMT_SEG_TO_VAL 900000000 /* 15 min. */
335
336/* Assume tick counter increment is 1 - may be set OS-dependent. */
337#ifndef SK_TICK_INCR
338#define SK_TICK_INCR SK_CONSTU64(1)
339#endif /* !defined(SK_TICK_INCR) */
340
341/*
342 * Amount that a time stamp must be later to be recognized as "substantially
343 * later". This is about 1/128 sec, but above 1 tick counter increment.
344 */
345#define SK_RLMT_BC_DELTA (1 + ((SK_TICKS_PER_SEC >> 7) > SK_TICK_INCR ? \
346 (SK_TICKS_PER_SEC >> 7) : SK_TICK_INCR))
347
348/* ----- Private RLMT defaults ----- */
349
350#define SK_RLMT_DEF_PREF_PORT 0 /* "Lower" port. */
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200351#define SK_RLMT_DEF_MODE SK_RLMT_CHECK_LINK /* Default RLMT Mode. */
wdenk7152b1d2003-09-05 23:19:14 +0000352
353/* ----- Private RLMT checking states ----- */
354
355#define SK_RLMT_RCS_SEG 1 /* RLMT Check State: check seg. */
356#define SK_RLMT_RCS_START_SEG 2 /* RLMT Check State: start check seg. */
357#define SK_RLMT_RCS_SEND_SEG 4 /* RLMT Check State: send BPDU packet */
358#define SK_RLMT_RCS_REPORT_SEG 8 /* RLMT Check State: report seg. */
359
360/* ----- Private PORT checking states ----- */
361
362#define SK_RLMT_PCS_TX 1 /* Port Check State: check tx. */
363#define SK_RLMT_PCS_RX 2 /* Port Check State: check rx. */
364
365/* ----- Private PORT events ----- */
366
367/* Note: Update simulation when changing these. */
368#define SK_RLMT_PORTSTART_TIM 1100 /* Port start timeout. */
369#define SK_RLMT_PORTUP_TIM 1101 /* Port can now go up. */
370#define SK_RLMT_PORTDOWN_RX_TIM 1102 /* Port did not receive once ... */
371#define SK_RLMT_PORTDOWN 1103 /* Port went down. */
372#define SK_RLMT_PORTDOWN_TX_TIM 1104 /* Partner did not receive ... */
373
374/* ----- Private RLMT events ----- */
375
376/* Note: Update simulation when changing these. */
377#define SK_RLMT_TIM 2100 /* RLMT timeout. */
378#define SK_RLMT_SEG_TIM 2101 /* RLMT segmentation check timeout. */
379
380#define TO_SHORTEN(tim) ((tim) / 2)
381
382/* Error numbers and messages. */
383#define SKERR_RLMT_E001 (SK_ERRBASE_RLMT + 0)
384#define SKERR_RLMT_E001_MSG "No Packet."
385#define SKERR_RLMT_E002 (SKERR_RLMT_E001 + 1)
386#define SKERR_RLMT_E002_MSG "Short Packet."
387#define SKERR_RLMT_E003 (SKERR_RLMT_E002 + 1)
388#define SKERR_RLMT_E003_MSG "Unknown RLMT event."
389#define SKERR_RLMT_E004 (SKERR_RLMT_E003 + 1)
390#define SKERR_RLMT_E004_MSG "PortsUp incorrect."
391#define SKERR_RLMT_E005 (SKERR_RLMT_E004 + 1)
392#define SKERR_RLMT_E005_MSG \
393 "Net seems to be segmented (different root bridges are reported on the ports)."
394#define SKERR_RLMT_E006 (SKERR_RLMT_E005 + 1)
395#define SKERR_RLMT_E006_MSG "Duplicate MAC Address detected."
396#define SKERR_RLMT_E007 (SKERR_RLMT_E006 + 1)
397#define SKERR_RLMT_E007_MSG "LinksUp incorrect."
398#define SKERR_RLMT_E008 (SKERR_RLMT_E007 + 1)
399#define SKERR_RLMT_E008_MSG "Port not started but link came up."
400#define SKERR_RLMT_E009 (SKERR_RLMT_E008 + 1)
401#define SKERR_RLMT_E009_MSG "Corrected illegal setting of Preferred Port."
402#define SKERR_RLMT_E010 (SKERR_RLMT_E009 + 1)
403#define SKERR_RLMT_E010_MSG "Ignored illegal Preferred Port."
404
405/* LLC field values. */
406#define LLC_COMMAND_RESPONSE_BIT 1
407#define LLC_TEST_COMMAND 0xE3
408#define LLC_UI 0x03
409
410/* RLMT Packet fields. */
411#define SK_RLMT_DSAP 0
412#define SK_RLMT_SSAP 0
413#define SK_RLMT_CTRL (LLC_TEST_COMMAND)
414#define SK_RLMT_INDICATOR0 0x53 /* S */
415#define SK_RLMT_INDICATOR1 0x4B /* K */
416#define SK_RLMT_INDICATOR2 0x2D /* - */
417#define SK_RLMT_INDICATOR3 0x52 /* R */
418#define SK_RLMT_INDICATOR4 0x4C /* L */
419#define SK_RLMT_INDICATOR5 0x4D /* M */
420#define SK_RLMT_INDICATOR6 0x54 /* T */
421#define SK_RLMT_PACKET_VERSION 0
422
423/* RLMT SPT Flag values. */
424#define SK_RLMT_SPT_FLAG_CHANGE 0x01
425#define SK_RLMT_SPT_FLAG_CHANGE_ACK 0x80
426
427/* RLMT SPT Packet fields. */
428#define SK_RLMT_SPT_DSAP 0x42
429#define SK_RLMT_SPT_SSAP 0x42
430#define SK_RLMT_SPT_CTRL (LLC_UI)
431#define SK_RLMT_SPT_PROTOCOL_ID0 0x00
432#define SK_RLMT_SPT_PROTOCOL_ID1 0x00
433#define SK_RLMT_SPT_PROTOCOL_VERSION_ID 0x00
434#define SK_RLMT_SPT_BPDU_TYPE 0x00
435#define SK_RLMT_SPT_FLAGS 0x00 /* ?? */
436#define SK_RLMT_SPT_ROOT_ID0 0xFF /* Lowest possible priority. */
437#define SK_RLMT_SPT_ROOT_ID1 0xFF /* Lowest possible priority. */
438
439/* Remaining 6 bytes will be the current port address. */
440#define SK_RLMT_SPT_ROOT_PATH_COST0 0x00
441#define SK_RLMT_SPT_ROOT_PATH_COST1 0x00
442#define SK_RLMT_SPT_ROOT_PATH_COST2 0x00
443#define SK_RLMT_SPT_ROOT_PATH_COST3 0x00
444#define SK_RLMT_SPT_BRIDGE_ID0 0xFF /* Lowest possible priority. */
445#define SK_RLMT_SPT_BRIDGE_ID1 0xFF /* Lowest possible priority. */
446
447/* Remaining 6 bytes will be the current port address. */
448#define SK_RLMT_SPT_PORT_ID0 0xFF /* Lowest possible priority. */
449#define SK_RLMT_SPT_PORT_ID1 0xFF /* Lowest possible priority. */
450#define SK_RLMT_SPT_MSG_AGE0 0x00
451#define SK_RLMT_SPT_MSG_AGE1 0x00
452#define SK_RLMT_SPT_MAX_AGE0 0x00
453#define SK_RLMT_SPT_MAX_AGE1 0xFF
454#define SK_RLMT_SPT_HELLO_TIME0 0x00
455#define SK_RLMT_SPT_HELLO_TIME1 0xFF
456#define SK_RLMT_SPT_FWD_DELAY0 0x00
457#define SK_RLMT_SPT_FWD_DELAY1 0x40
458
459/* Size defines. */
460#define SK_RLMT_MIN_PACKET_SIZE 34
461#define SK_RLMT_MAX_PACKET_SIZE (SK_RLMT_MAX_TX_BUF_SIZE)
462#define SK_PACKET_DATA_LEN (SK_RLMT_MAX_PACKET_SIZE - \
463 SK_RLMT_MIN_PACKET_SIZE)
464
465/* ----- RLMT packet types ----- */
466#define SK_PACKET_ANNOUNCE 1 /* Port announcement. */
467#define SK_PACKET_ALIVE 2 /* Alive packet to port. */
468#define SK_PACKET_ADDR_CHANGED 3 /* Port address changed. */
469#define SK_PACKET_CHECK_TX 4 /* Check your tx line. */
470
471#ifdef SK_LITTLE_ENDIAN
472#define SK_U16_TO_NETWORK_ORDER(Val,Addr) { \
473 SK_U8 *_Addr = (SK_U8*)(Addr); \
474 SK_U16 _Val = (SK_U16)(Val); \
475 *_Addr++ = (SK_U8)(_Val >> 8); \
476 *_Addr = (SK_U8)(_Val & 0xFF); \
477}
478#endif /* SK_LITTLE_ENDIAN */
479
480#ifdef SK_BIG_ENDIAN
481#define SK_U16_TO_NETWORK_ORDER(Val,Addr) (*(SK_U16*)(Addr) = (SK_U16)(Val))
482#endif /* SK_BIG_ENDIAN */
483
484#define AUTONEG_FAILED SK_FALSE
485#define AUTONEG_SUCCESS SK_TRUE
486
487
488/* typedefs *******************************************************************/
489
490/* RLMT packet. Length: SK_RLMT_MAX_PACKET_SIZE (60) bytes. */
491typedef struct s_RlmtPacket {
492 SK_U8 DstAddr[SK_MAC_ADDR_LEN];
493 SK_U8 SrcAddr[SK_MAC_ADDR_LEN];
494 SK_U8 TypeLen[2];
495 SK_U8 DSap;
496 SK_U8 SSap;
497 SK_U8 Ctrl;
498 SK_U8 Indicator[7];
499 SK_U8 RlmtPacketType[2];
500 SK_U8 Align1[2];
501 SK_U8 Random[4]; /* Random value of requesting(!) station. */
502 SK_U8 RlmtPacketVersion[2]; /* RLMT Packet version. */
503 SK_U8 Data[SK_PACKET_DATA_LEN];
504} SK_RLMT_PACKET;
505
506typedef struct s_SpTreeRlmtPacket {
507 SK_U8 DstAddr[SK_MAC_ADDR_LEN];
508 SK_U8 SrcAddr[SK_MAC_ADDR_LEN];
509 SK_U8 TypeLen[2];
510 SK_U8 DSap;
511 SK_U8 SSap;
512 SK_U8 Ctrl;
513 SK_U8 ProtocolId[2];
514 SK_U8 ProtocolVersionId;
515 SK_U8 BpduType;
516 SK_U8 Flags;
517 SK_U8 RootId[8];
518 SK_U8 RootPathCost[4];
519 SK_U8 BridgeId[8];
520 SK_U8 PortId[2];
521 SK_U8 MessageAge[2];
522 SK_U8 MaxAge[2];
523 SK_U8 HelloTime[2];
524 SK_U8 ForwardDelay[2];
525} SK_SPTREE_PACKET;
526
527/* global variables ***********************************************************/
528
529SK_MAC_ADDR SkRlmtMcAddr = {{0x01, 0x00, 0x5A, 0x52, 0x4C, 0x4D}};
530SK_MAC_ADDR BridgeMcAddr = {{0x01, 0x80, 0xC2, 0x00, 0x00, 0x00}};
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200531SK_MAC_ADDR BcAddr = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
wdenk7152b1d2003-09-05 23:19:14 +0000532
533/* local variables ************************************************************/
534
535/* None. */
536
537/* functions ******************************************************************/
538
539RLMT_STATIC void SkRlmtCheckSwitch(
540 SK_AC *pAC,
541 SK_IOC IoC,
542 SK_U32 NetIdx);
543RLMT_STATIC void SkRlmtCheckSeg(
544 SK_AC *pAC,
545 SK_IOC IoC,
546 SK_U32 NetIdx);
547RLMT_STATIC void SkRlmtEvtSetNets(
548 SK_AC *pAC,
549 SK_IOC IoC,
550 SK_EVPARA Para);
551
552/******************************************************************************
553 *
554 * SkRlmtInit - initialize data, set state to init
555 *
556 * Description:
557 *
558 * SK_INIT_DATA
559 * ============
560 *
561 * This routine initializes all RLMT-related variables to a known state.
562 * The initial state is SK_RLMT_RS_INIT.
563 * All ports are initialized to SK_RLMT_PS_INIT.
564 *
565 *
566 * SK_INIT_IO
567 * ==========
568 *
569 * Nothing.
570 *
571 *
572 * SK_INIT_RUN
573 * ===========
574 *
575 * Determine the adapter's random value.
576 * Set the hw registers, the "logical MAC address", the
577 * RLMT multicast address, and eventually the BPDU multicast address.
578 *
579 * Context:
580 * init, pageable
581 *
582 * Returns:
583 * Nothing.
584 */
585void SkRlmtInit(
586SK_AC *pAC, /* Adapter Context */
587SK_IOC IoC, /* I/O Context */
588int Level) /* Initialization Level */
589{
590 SK_U32 i, j;
591 SK_U64 Random;
592 SK_EVPARA Para;
593 SK_MAC_ADDR VirtualMacAddress;
594 SK_MAC_ADDR PhysicalAMacAddress;
595 SK_BOOL VirtualMacAddressSet;
596 SK_BOOL PhysicalAMacAddressSet;
597
598 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_INIT,
599 ("RLMT Init level %d.\n", Level))
600
601 switch (Level) {
602 case SK_INIT_DATA: /* Initialize data structures. */
603 SK_MEMSET((char *)&pAC->Rlmt, 0, sizeof(SK_RLMT));
604
605 for (i = 0; i < SK_MAX_MACS; i++) {
606 pAC->Rlmt.Port[i].PortState = SK_RLMT_PS_INIT;
607 pAC->Rlmt.Port[i].LinkDown = SK_TRUE;
608 pAC->Rlmt.Port[i].PortDown = SK_TRUE;
609 pAC->Rlmt.Port[i].PortStarted = SK_FALSE;
610 pAC->Rlmt.Port[i].PortNoRx = SK_FALSE;
611 pAC->Rlmt.Port[i].RootIdSet = SK_FALSE;
612 pAC->Rlmt.Port[i].PortNumber = i;
613 pAC->Rlmt.Port[i].Net = &pAC->Rlmt.Net[0];
614 pAC->Rlmt.Port[i].AddrPort = &pAC->Addr.Port[i];
615 }
616
617 pAC->Rlmt.NumNets = 1;
618 for (i = 0; i < SK_MAX_NETS; i++) {
619 pAC->Rlmt.Net[i].RlmtState = SK_RLMT_RS_INIT;
620 pAC->Rlmt.Net[i].RootIdSet = SK_FALSE;
621 pAC->Rlmt.Net[i].PrefPort = SK_RLMT_DEF_PREF_PORT;
622 pAC->Rlmt.Net[i].Preference = 0xFFFFFFFF; /* Automatic. */
623 /* Just assuming. */
624 pAC->Rlmt.Net[i].ActivePort = pAC->Rlmt.Net[i].PrefPort;
625 pAC->Rlmt.Net[i].RlmtMode = SK_RLMT_DEF_MODE;
626 pAC->Rlmt.Net[i].TimeoutValue = SK_RLMT_DEF_TO_VAL;
627 pAC->Rlmt.Net[i].NetNumber = i;
628 }
629
630 pAC->Rlmt.Net[0].Port[0] = &pAC->Rlmt.Port[0];
631 pAC->Rlmt.Net[0].Port[1] = &pAC->Rlmt.Port[1];
632#if SK_MAX_NETS > 1
633 pAC->Rlmt.Net[1].Port[0] = &pAC->Rlmt.Port[1];
634#endif /* SK_MAX_NETS > 1 */
635 break;
636
637 case SK_INIT_IO: /* GIMacsFound first available here. */
638 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_INIT,
639 ("RLMT: %d MACs were detected.\n", pAC->GIni.GIMacsFound))
640
641 pAC->Rlmt.Net[0].NumPorts = pAC->GIni.GIMacsFound;
642
643 /* Initialize HW registers? */
644 if (pAC->GIni.GIMacsFound == 1) {
645 Para.Para32[0] = SK_RLMT_MODE_CLS;
646 Para.Para32[1] = 0;
647 (void)SkRlmtEvent(pAC, IoC, SK_RLMT_MODE_CHANGE, Para);
648 }
649 break;
650
651 case SK_INIT_RUN:
652 /* Ensure RLMT is set to one net. */
653 if (pAC->Rlmt.NumNets > 1) {
654 Para.Para32[0] = 1;
655 Para.Para32[1] = -1;
656 SkRlmtEvtSetNets(pAC, IoC, Para);
657 }
658
659 for (i = 0; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
660 Random = SkOsGetTime(pAC);
661 *(SK_U32*)&pAC->Rlmt.Port[i].Random = *(SK_U32*)&Random;
662
663 for (j = 0; j < 4; j++) {
664 pAC->Rlmt.Port[i].Random[j] ^= pAC->Rlmt.Port[i].AddrPort->
665 CurrentMacAddress.a[SK_MAC_ADDR_LEN - 1 - j];
666 }
667
668 (void)SkAddrMcClear(pAC, IoC, i, SK_ADDR_PERMANENT | SK_MC_SW_ONLY);
wdenk42d1f032003-10-15 23:53:47 +0000669
wdenk7152b1d2003-09-05 23:19:14 +0000670 /* Add RLMT MC address. */
671 (void)SkAddrMcAdd(pAC, IoC, i, &SkRlmtMcAddr, SK_ADDR_PERMANENT);
672
673 if (pAC->Rlmt.Net[0].RlmtMode & SK_RLMT_CHECK_SEG) {
674 /* Add BPDU MC address. */
675 (void)SkAddrMcAdd(pAC, IoC, i, &BridgeMcAddr, SK_ADDR_PERMANENT);
676 }
677
678 (void)SkAddrMcUpdate(pAC, IoC, i);
679 }
680
wdenk42d1f032003-10-15 23:53:47 +0000681 VirtualMacAddressSet = SK_FALSE;
wdenk7152b1d2003-09-05 23:19:14 +0000682 /* Read virtual MAC address from Control Register File. */
683 for (j = 0; j < SK_MAC_ADDR_LEN; j++) {
wdenk42d1f032003-10-15 23:53:47 +0000684
685 SK_IN8(IoC, B2_MAC_1 + j, &VirtualMacAddress.a[j]);
686 VirtualMacAddressSet |= VirtualMacAddress.a[j];
wdenk7152b1d2003-09-05 23:19:14 +0000687 }
wdenk42d1f032003-10-15 23:53:47 +0000688
689 PhysicalAMacAddressSet = SK_FALSE;
wdenk7152b1d2003-09-05 23:19:14 +0000690 /* Read physical MAC address for MAC A from Control Register File. */
691 for (j = 0; j < SK_MAC_ADDR_LEN; j++) {
wdenk42d1f032003-10-15 23:53:47 +0000692
693 SK_IN8(IoC, B2_MAC_2 + j, &PhysicalAMacAddress.a[j]);
694 PhysicalAMacAddressSet |= PhysicalAMacAddress.a[j];
wdenk7152b1d2003-09-05 23:19:14 +0000695 }
696
wdenk42d1f032003-10-15 23:53:47 +0000697 /* check if the two mac addresses contain reasonable values */
698 if (!VirtualMacAddressSet || !PhysicalAMacAddressSet) {
wdenk7152b1d2003-09-05 23:19:14 +0000699
wdenk42d1f032003-10-15 23:53:47 +0000700 pAC->Rlmt.RlmtOff = SK_TRUE;
701 }
wdenk7152b1d2003-09-05 23:19:14 +0000702
wdenk42d1f032003-10-15 23:53:47 +0000703 /* if the two mac addresses are equal switch off the RLMT_PRE_LOOKAHEAD
704 and the RLMT_LOOKAHEAD macros */
705 else if (SK_ADDR_EQUAL(PhysicalAMacAddress.a, VirtualMacAddress.a)) {
wdenk7152b1d2003-09-05 23:19:14 +0000706
wdenk42d1f032003-10-15 23:53:47 +0000707 pAC->Rlmt.RlmtOff = SK_TRUE;
708 }
wdenk7152b1d2003-09-05 23:19:14 +0000709 else {
710 pAC->Rlmt.RlmtOff = SK_FALSE;
711 }
712 break;
713
714 default: /* error */
715 break;
716 }
717 return;
718} /* SkRlmtInit */
719
720
721/******************************************************************************
722 *
723 * SkRlmtBuildCheckChain - build the check chain
724 *
725 * Description:
726 * This routine builds the local check chain:
727 * - Each port that is up checks the next port.
728 * - The last port that is up checks the first port that is up.
729 *
730 * Notes:
731 * - Currently only local ports are considered when building the chain.
732 * - Currently the SuspectState is just reset;
733 * it would be better to save it ...
734 *
735 * Context:
736 * runtime, pageable?
737 *
738 * Returns:
739 * Nothing
740 */
741RLMT_STATIC void SkRlmtBuildCheckChain(
742SK_AC *pAC, /* Adapter Context */
743SK_U32 NetIdx) /* Net Number */
744{
745 SK_U32 i;
746 SK_U32 NumMacsUp;
747 SK_RLMT_PORT * FirstMacUp;
748 SK_RLMT_PORT * PrevMacUp;
749
750 FirstMacUp = NULL;
751 PrevMacUp = NULL;
wdenk42d1f032003-10-15 23:53:47 +0000752
wdenk7152b1d2003-09-05 23:19:14 +0000753 if (!(pAC->Rlmt.Net[NetIdx].RlmtMode & SK_RLMT_CHECK_LOC_LINK)) {
754 for (i = 0; i < pAC->Rlmt.Net[i].NumPorts; i++) {
755 pAC->Rlmt.Net[NetIdx].Port[i]->PortsChecked = 0;
756 }
757 return; /* Done. */
758 }
wdenk42d1f032003-10-15 23:53:47 +0000759
wdenk7152b1d2003-09-05 23:19:14 +0000760 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
761 ("SkRlmtBuildCheckChain.\n"))
762
763 NumMacsUp = 0;
764
765 for (i = 0; i < pAC->Rlmt.Net[NetIdx].NumPorts; i++) {
766 pAC->Rlmt.Net[NetIdx].Port[i]->PortsChecked = 0;
767 pAC->Rlmt.Net[NetIdx].Port[i]->PortsSuspect = 0;
768 pAC->Rlmt.Net[NetIdx].Port[i]->CheckingState &=
769 ~(SK_RLMT_PCS_RX | SK_RLMT_PCS_TX);
770
771 /*
772 * If more than two links are detected we should consider
773 * checking at least two other ports:
774 * 1. the next port that is not LinkDown and
775 * 2. the next port that is not PortDown.
776 */
777 if (!pAC->Rlmt.Net[NetIdx].Port[i]->LinkDown) {
778 if (NumMacsUp == 0) {
779 FirstMacUp = pAC->Rlmt.Net[NetIdx].Port[i];
780 }
781 else {
782 PrevMacUp->PortCheck[
783 pAC->Rlmt.Net[NetIdx].Port[i]->PortsChecked].CheckAddr =
784 pAC->Rlmt.Net[NetIdx].Port[i]->AddrPort->CurrentMacAddress;
785 PrevMacUp->PortCheck[
786 PrevMacUp->PortsChecked].SuspectTx = SK_FALSE;
787 PrevMacUp->PortsChecked++;
788 }
789 PrevMacUp = pAC->Rlmt.Net[NetIdx].Port[i];
790 NumMacsUp++;
791 }
792 }
793
794 if (NumMacsUp > 1) {
795 PrevMacUp->PortCheck[PrevMacUp->PortsChecked].CheckAddr =
796 FirstMacUp->AddrPort->CurrentMacAddress;
797 PrevMacUp->PortCheck[PrevMacUp->PortsChecked].SuspectTx =
798 SK_FALSE;
799 PrevMacUp->PortsChecked++;
800 }
801
802#ifdef DEBUG
803 for (i = 0; i < pAC->Rlmt.Net[NetIdx].NumPorts; i++) {
804 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
805 ("Port %d checks %d other ports: %2X.\n", i,
806 pAC->Rlmt.Net[NetIdx].Port[i]->PortsChecked,
807 pAC->Rlmt.Net[NetIdx].Port[i]->PortCheck[0].CheckAddr.a[5]))
808 }
809#endif /* DEBUG */
810
811 return;
812} /* SkRlmtBuildCheckChain */
813
814
815/******************************************************************************
816 *
817 * SkRlmtBuildPacket - build an RLMT packet
818 *
819 * Description:
820 * This routine sets up an RLMT packet.
821 *
822 * Context:
823 * runtime, pageable?
824 *
825 * Returns:
826 * NULL or pointer to RLMT mbuf
827 */
828RLMT_STATIC SK_MBUF *SkRlmtBuildPacket(
829SK_AC *pAC, /* Adapter Context */
830SK_IOC IoC, /* I/O Context */
831SK_U32 PortNumber, /* Sending port */
832SK_U16 PacketType, /* RLMT packet type */
833SK_MAC_ADDR *SrcAddr, /* Source address */
834SK_MAC_ADDR *DestAddr) /* Destination address */
835{
836 int i;
837 SK_U16 Length;
838 SK_MBUF *pMb;
839 SK_RLMT_PACKET *pPacket;
840
841#ifdef DEBUG
842 SK_U8 CheckSrc = 0;
843 SK_U8 CheckDest = 0;
wdenk42d1f032003-10-15 23:53:47 +0000844
wdenk7152b1d2003-09-05 23:19:14 +0000845 for (i = 0; i < SK_MAC_ADDR_LEN; ++i) {
846 CheckSrc |= SrcAddr->a[i];
847 CheckDest |= DestAddr->a[i];
848 }
849
850 if ((CheckSrc == 0) || (CheckDest == 0)) {
851 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_ERR,
852 ("SkRlmtBuildPacket: Invalid %s%saddr.\n",
853 (CheckSrc == 0 ? "Src" : ""), (CheckDest == 0 ? "Dest" : "")))
854 }
855#endif
856
857 if ((pMb = SkDrvAllocRlmtMbuf(pAC, IoC, SK_RLMT_MAX_PACKET_SIZE)) != NULL) {
858 pPacket = (SK_RLMT_PACKET*)pMb->pData;
859 for (i = 0; i < SK_MAC_ADDR_LEN; i++) {
860 pPacket->DstAddr[i] = DestAddr->a[i];
861 pPacket->SrcAddr[i] = SrcAddr->a[i];
862 }
863 pPacket->DSap = SK_RLMT_DSAP;
864 pPacket->SSap = SK_RLMT_SSAP;
865 pPacket->Ctrl = SK_RLMT_CTRL;
866 pPacket->Indicator[0] = SK_RLMT_INDICATOR0;
867 pPacket->Indicator[1] = SK_RLMT_INDICATOR1;
868 pPacket->Indicator[2] = SK_RLMT_INDICATOR2;
869 pPacket->Indicator[3] = SK_RLMT_INDICATOR3;
870 pPacket->Indicator[4] = SK_RLMT_INDICATOR4;
871 pPacket->Indicator[5] = SK_RLMT_INDICATOR5;
872 pPacket->Indicator[6] = SK_RLMT_INDICATOR6;
873
874 SK_U16_TO_NETWORK_ORDER(PacketType, &pPacket->RlmtPacketType[0]);
875
876 for (i = 0; i < 4; i++) {
877 pPacket->Random[i] = pAC->Rlmt.Port[PortNumber].Random[i];
878 }
wdenk42d1f032003-10-15 23:53:47 +0000879
wdenk7152b1d2003-09-05 23:19:14 +0000880 SK_U16_TO_NETWORK_ORDER(
881 SK_RLMT_PACKET_VERSION, &pPacket->RlmtPacketVersion[0]);
882
883 for (i = 0; i < SK_PACKET_DATA_LEN; i++) {
884 pPacket->Data[i] = 0x00;
885 }
886
887 Length = SK_RLMT_MAX_PACKET_SIZE; /* Or smaller. */
888 pMb->Length = Length;
889 pMb->PortIdx = PortNumber;
890 Length -= 14;
891 SK_U16_TO_NETWORK_ORDER(Length, &pPacket->TypeLen[0]);
892
893 if (PacketType == SK_PACKET_ALIVE) {
894 pAC->Rlmt.Port[PortNumber].TxHelloCts++;
895 }
896 }
897
898 return (pMb);
899} /* SkRlmtBuildPacket */
900
901
902/******************************************************************************
903 *
904 * SkRlmtBuildSpanningTreePacket - build spanning tree check packet
905 *
906 * Description:
907 * This routine sets up a BPDU packet for spanning tree check.
908 *
909 * Context:
910 * runtime, pageable?
911 *
912 * Returns:
913 * NULL or pointer to RLMT mbuf
914 */
915RLMT_STATIC SK_MBUF *SkRlmtBuildSpanningTreePacket(
916SK_AC *pAC, /* Adapter Context */
917SK_IOC IoC, /* I/O Context */
918SK_U32 PortNumber) /* Sending port */
919{
920 unsigned i;
921 SK_U16 Length;
922 SK_MBUF *pMb;
923 SK_SPTREE_PACKET *pSPacket;
924
925 if ((pMb = SkDrvAllocRlmtMbuf(pAC, IoC, SK_RLMT_MAX_PACKET_SIZE)) !=
926 NULL) {
927 pSPacket = (SK_SPTREE_PACKET*)pMb->pData;
928 for (i = 0; i < SK_MAC_ADDR_LEN; i++) {
929 pSPacket->DstAddr[i] = BridgeMcAddr.a[i];
930 pSPacket->SrcAddr[i] =
931 pAC->Addr.Port[PortNumber].CurrentMacAddress.a[i];
932 }
933 pSPacket->DSap = SK_RLMT_SPT_DSAP;
934 pSPacket->SSap = SK_RLMT_SPT_SSAP;
935 pSPacket->Ctrl = SK_RLMT_SPT_CTRL;
936
937 pSPacket->ProtocolId[0] = SK_RLMT_SPT_PROTOCOL_ID0;
938 pSPacket->ProtocolId[1] = SK_RLMT_SPT_PROTOCOL_ID1;
939 pSPacket->ProtocolVersionId = SK_RLMT_SPT_PROTOCOL_VERSION_ID;
940 pSPacket->BpduType = SK_RLMT_SPT_BPDU_TYPE;
941 pSPacket->Flags = SK_RLMT_SPT_FLAGS;
942 pSPacket->RootId[0] = SK_RLMT_SPT_ROOT_ID0;
943 pSPacket->RootId[1] = SK_RLMT_SPT_ROOT_ID1;
944 pSPacket->RootPathCost[0] = SK_RLMT_SPT_ROOT_PATH_COST0;
945 pSPacket->RootPathCost[1] = SK_RLMT_SPT_ROOT_PATH_COST1;
946 pSPacket->RootPathCost[2] = SK_RLMT_SPT_ROOT_PATH_COST2;
947 pSPacket->RootPathCost[3] = SK_RLMT_SPT_ROOT_PATH_COST3;
948 pSPacket->BridgeId[0] = SK_RLMT_SPT_BRIDGE_ID0;
949 pSPacket->BridgeId[1] = SK_RLMT_SPT_BRIDGE_ID1;
950
951 /*
952 * Use logical MAC address as bridge ID and filter these packets
953 * on receive.
954 */
955 for (i = 0; i < SK_MAC_ADDR_LEN; i++) {
956 pSPacket->BridgeId[i + 2] = pSPacket->RootId[i + 2] =
957 pAC->Addr.Net[pAC->Rlmt.Port[PortNumber].Net->NetNumber].
958 CurrentMacAddress.a[i];
959 }
960 pSPacket->PortId[0] = SK_RLMT_SPT_PORT_ID0;
961 pSPacket->PortId[1] = SK_RLMT_SPT_PORT_ID1;
962 pSPacket->MessageAge[0] = SK_RLMT_SPT_MSG_AGE0;
963 pSPacket->MessageAge[1] = SK_RLMT_SPT_MSG_AGE1;
964 pSPacket->MaxAge[0] = SK_RLMT_SPT_MAX_AGE0;
965 pSPacket->MaxAge[1] = SK_RLMT_SPT_MAX_AGE1;
966 pSPacket->HelloTime[0] = SK_RLMT_SPT_HELLO_TIME0;
967 pSPacket->HelloTime[1] = SK_RLMT_SPT_HELLO_TIME1;
968 pSPacket->ForwardDelay[0] = SK_RLMT_SPT_FWD_DELAY0;
969 pSPacket->ForwardDelay[1] = SK_RLMT_SPT_FWD_DELAY1;
970
971 Length = SK_RLMT_MAX_PACKET_SIZE; /* Or smaller. */
972 pMb->Length = Length;
973 pMb->PortIdx = PortNumber;
974 Length -= 14;
975 SK_U16_TO_NETWORK_ORDER(Length, &pSPacket->TypeLen[0]);
976
977 pAC->Rlmt.Port[PortNumber].TxSpHelloReqCts++;
978 }
979
980 return (pMb);
981} /* SkRlmtBuildSpanningTreePacket */
982
983
984/******************************************************************************
985 *
986 * SkRlmtSend - build and send check packets
987 *
988 * Description:
989 * Depending on the RLMT state and the checking state, several packets
990 * are sent through the indicated port.
991 *
992 * Context:
993 * runtime, pageable?
994 *
995 * Returns:
996 * Nothing.
997 */
998RLMT_STATIC void SkRlmtSend(
999SK_AC *pAC, /* Adapter Context */
1000SK_IOC IoC, /* I/O Context */
1001SK_U32 PortNumber) /* Sending port */
1002{
1003 unsigned j;
1004 SK_EVPARA Para;
1005 SK_RLMT_PORT *pRPort;
1006
1007 pRPort = &pAC->Rlmt.Port[PortNumber];
1008 if (pAC->Rlmt.Port[PortNumber].Net->RlmtMode & SK_RLMT_CHECK_LOC_LINK) {
1009 if (pRPort->CheckingState & (SK_RLMT_PCS_TX | SK_RLMT_PCS_RX)) {
1010 /* Port is suspicious. Send the RLMT packet to the RLMT mc addr. */
1011 if ((Para.pParaPtr = SkRlmtBuildPacket(pAC, IoC, PortNumber,
1012 SK_PACKET_ALIVE, &pAC->Addr.Port[PortNumber].CurrentMacAddress,
1013 &SkRlmtMcAddr)) != NULL) {
1014 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para);
1015 }
1016 }
1017 else {
1018 /*
1019 * Send a directed RLMT packet to all ports that are
1020 * checked by the indicated port.
1021 */
1022 for (j = 0; j < pRPort->PortsChecked; j++) {
1023 if ((Para.pParaPtr = SkRlmtBuildPacket(pAC, IoC, PortNumber,
1024 SK_PACKET_ALIVE, &pAC->Addr.Port[PortNumber].CurrentMacAddress,
1025 &pRPort->PortCheck[j].CheckAddr)) != NULL) {
1026 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para);
1027 }
1028 }
1029 }
1030 }
1031
1032 if ((pAC->Rlmt.Port[PortNumber].Net->RlmtMode & SK_RLMT_CHECK_SEG) &&
1033 (pAC->Rlmt.Port[PortNumber].Net->CheckingState & SK_RLMT_RCS_SEND_SEG)) {
1034 /*
1035 * Send a BPDU packet to make a connected switch tell us
1036 * the correct root bridge.
1037 */
1038 if ((Para.pParaPtr =
1039 SkRlmtBuildSpanningTreePacket(pAC, IoC, PortNumber)) != NULL) {
1040 pAC->Rlmt.Port[PortNumber].Net->CheckingState &= ~SK_RLMT_RCS_SEND_SEG;
1041 pRPort->RootIdSet = SK_FALSE;
1042
1043 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para);
1044 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_TX,
1045 ("SkRlmtSend: BPDU Packet on Port %u.\n", PortNumber))
1046 }
1047 }
1048 return;
1049} /* SkRlmtSend */
1050
1051
1052/******************************************************************************
1053 *
1054 * SkRlmtPortReceives - check if port is (going) down and bring it up
1055 *
1056 * Description:
1057 * This routine checks if a port who received a non-BPDU packet
1058 * needs to go up or needs to be stopped going down.
1059 *
1060 * Context:
1061 * runtime, pageable?
1062 *
1063 * Returns:
1064 * Nothing.
1065 */
1066RLMT_STATIC void SkRlmtPortReceives(
1067SK_AC *pAC, /* Adapter Context */
1068SK_IOC IoC, /* I/O Context */
1069SK_U32 PortNumber) /* Port to check */
1070{
1071 SK_RLMT_PORT *pRPort;
1072 SK_EVPARA Para;
1073
1074 pRPort = &pAC->Rlmt.Port[PortNumber];
1075 pRPort->PortNoRx = SK_FALSE;
1076
1077 if ((pRPort->PortState == SK_RLMT_PS_DOWN) &&
1078 !(pRPort->CheckingState & SK_RLMT_PCS_TX)) {
1079 /*
1080 * Port is marked down (rx), but received a non-BPDU packet.
1081 * Bring it up.
1082 */
1083 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1084 ("SkRlmtPacketReceive: Received on PortDown.\n"))
1085
1086 pRPort->PortState = SK_RLMT_PS_GOING_UP;
1087 pRPort->GuTimeStamp = SkOsGetTime(pAC);
1088 Para.Para32[0] = PortNumber;
1089 Para.Para32[1] = (SK_U32)-1;
1090 SkTimerStart(pAC, IoC, &pRPort->UpTimer, SK_RLMT_PORTUP_TIM_VAL,
1091 SKGE_RLMT, SK_RLMT_PORTUP_TIM, Para);
1092 pRPort->CheckingState &= ~SK_RLMT_PCS_RX;
1093 /* pAC->Rlmt.CheckSwitch = SK_TRUE; */
1094 SkRlmtCheckSwitch(pAC, IoC, pRPort->Net->NetNumber);
1095 } /* PortDown && !SuspectTx */
1096 else if (pRPort->CheckingState & SK_RLMT_PCS_RX) {
1097 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1098 ("SkRlmtPacketReceive: Stop bringing port down.\n"))
1099 SkTimerStop(pAC, IoC, &pRPort->DownRxTimer);
1100 pRPort->CheckingState &= ~SK_RLMT_PCS_RX;
1101 /* pAC->Rlmt.CheckSwitch = SK_TRUE; */
1102 SkRlmtCheckSwitch(pAC, IoC, pRPort->Net->NetNumber);
1103 } /* PortGoingDown */
1104
1105 return;
1106} /* SkRlmtPortReceives */
1107
1108
1109/******************************************************************************
1110 *
1111 * SkRlmtPacketReceive - receive a packet for closer examination
1112 *
1113 * Description:
1114 * This routine examines a packet more closely than SK_RLMT_LOOKAHEAD.
1115 *
1116 * Context:
1117 * runtime, pageable?
1118 *
1119 * Returns:
1120 * Nothing.
1121 */
1122RLMT_STATIC void SkRlmtPacketReceive(
1123SK_AC *pAC, /* Adapter Context */
1124SK_IOC IoC, /* I/O Context */
1125SK_MBUF *pMb) /* Received packet */
1126{
1127#ifdef xDEBUG
1128 extern void DumpData(char *p, int size);
1129#endif /* DEBUG */
1130 int i;
1131 unsigned j;
1132 SK_U16 PacketType;
1133 SK_U32 PortNumber;
1134 SK_ADDR_PORT *pAPort;
1135 SK_RLMT_PORT *pRPort;
1136 SK_RLMT_PACKET *pRPacket;
1137 SK_SPTREE_PACKET *pSPacket;
1138 SK_EVPARA Para;
1139
1140 PortNumber = pMb->PortIdx;
1141 pAPort = &pAC->Addr.Port[PortNumber];
1142 pRPort = &pAC->Rlmt.Port[PortNumber];
1143
1144 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1145 ("SkRlmtPacketReceive: PortNumber == %d.\n", PortNumber))
1146
1147 pRPacket = (SK_RLMT_PACKET*)pMb->pData;
1148 pSPacket = (SK_SPTREE_PACKET*)pRPacket;
1149
1150#ifdef xDEBUG
1151 DumpData((char *)pRPacket, 32);
1152#endif /* DEBUG */
1153
1154 if ((pRPort->PacketsPerTimeSlot - pRPort->BpduPacketsPerTimeSlot) != 0) {
1155 SkRlmtPortReceives(pAC, IoC, PortNumber);
1156 }
wdenk42d1f032003-10-15 23:53:47 +00001157
wdenk7152b1d2003-09-05 23:19:14 +00001158 /* Check destination address. */
1159
1160 if (!SK_ADDR_EQUAL(pAPort->CurrentMacAddress.a, pRPacket->DstAddr) &&
1161 !SK_ADDR_EQUAL(SkRlmtMcAddr.a, pRPacket->DstAddr) &&
1162 !SK_ADDR_EQUAL(BridgeMcAddr.a, pRPacket->DstAddr)) {
1163
1164 /* Not sent to current MAC or registered MC address => Trash it. */
1165 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1166 ("SkRlmtPacketReceive: Not for me.\n"))
1167
1168 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1169 return;
1170 }
1171 else if (SK_ADDR_EQUAL(pAPort->CurrentMacAddress.a, pRPacket->SrcAddr)) {
1172
1173 /*
1174 * Was sent by same port (may happen during port switching
1175 * or in case of duplicate MAC addresses).
1176 */
1177
1178 /*
1179 * Check for duplicate address here:
1180 * If Packet.Random != My.Random => DupAddr.
1181 */
1182 for (i = 3; i >= 0; i--) {
1183 if (pRPort->Random[i] != pRPacket->Random[i]) {
1184 break;
1185 }
1186 }
1187
1188 /*
1189 * CAUTION: Do not check for duplicate MAC address in RLMT Alive Reply
1190 * packets (they have the LLC_COMMAND_RESPONSE_BIT set in
1191 * pRPacket->SSap).
1192 */
1193 if (i >= 0 && pRPacket->DSap == SK_RLMT_DSAP &&
1194 pRPacket->Ctrl == SK_RLMT_CTRL &&
1195 pRPacket->SSap == SK_RLMT_SSAP &&
1196 pRPacket->Indicator[0] == SK_RLMT_INDICATOR0 &&
1197 pRPacket->Indicator[1] == SK_RLMT_INDICATOR1 &&
1198 pRPacket->Indicator[2] == SK_RLMT_INDICATOR2 &&
1199 pRPacket->Indicator[3] == SK_RLMT_INDICATOR3 &&
1200 pRPacket->Indicator[4] == SK_RLMT_INDICATOR4 &&
1201 pRPacket->Indicator[5] == SK_RLMT_INDICATOR5 &&
1202 pRPacket->Indicator[6] == SK_RLMT_INDICATOR6) {
1203 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1204 ("SkRlmtPacketReceive: Duplicate MAC Address.\n"))
1205
1206 /* Error Log entry. */
1207 SK_ERR_LOG(pAC, SK_ERRCL_COMM, SKERR_RLMT_E006, SKERR_RLMT_E006_MSG);
1208 }
1209 else {
1210 /* Simply trash it. */
1211 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1212 ("SkRlmtPacketReceive: Sent by me.\n"))
1213 }
1214
1215 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1216 return;
1217 }
1218
1219 /* Check SuspectTx entries. */
1220 if (pRPort->PortsSuspect > 0) {
1221 for (j = 0; j < pRPort->PortsChecked; j++) {
1222 if (pRPort->PortCheck[j].SuspectTx &&
1223 SK_ADDR_EQUAL(
1224 pRPacket->SrcAddr, pRPort->PortCheck[j].CheckAddr.a)) {
1225 pRPort->PortCheck[j].SuspectTx = SK_FALSE;
1226 pRPort->PortsSuspect--;
1227 break;
1228 }
1229 }
1230 }
1231
1232 /* Determine type of packet. */
1233 if (pRPacket->DSap == SK_RLMT_DSAP &&
1234 pRPacket->Ctrl == SK_RLMT_CTRL &&
1235 (pRPacket->SSap & ~LLC_COMMAND_RESPONSE_BIT) == SK_RLMT_SSAP &&
1236 pRPacket->Indicator[0] == SK_RLMT_INDICATOR0 &&
1237 pRPacket->Indicator[1] == SK_RLMT_INDICATOR1 &&
1238 pRPacket->Indicator[2] == SK_RLMT_INDICATOR2 &&
1239 pRPacket->Indicator[3] == SK_RLMT_INDICATOR3 &&
1240 pRPacket->Indicator[4] == SK_RLMT_INDICATOR4 &&
1241 pRPacket->Indicator[5] == SK_RLMT_INDICATOR5 &&
1242 pRPacket->Indicator[6] == SK_RLMT_INDICATOR6) {
1243
1244 /* It's an RLMT packet. */
1245 PacketType = (SK_U16)((pRPacket->RlmtPacketType[0] << 8) |
1246 pRPacket->RlmtPacketType[1]);
1247
1248 switch (PacketType) {
1249 case SK_PACKET_ANNOUNCE: /* Not yet used. */
1250#if 0
1251 /* Build the check chain. */
1252 SkRlmtBuildCheckChain(pAC);
1253#endif /* 0 */
1254
1255 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1256 ("SkRlmtPacketReceive: Announce.\n"))
1257
1258 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1259 break;
1260
1261 case SK_PACKET_ALIVE:
1262 if (pRPacket->SSap & LLC_COMMAND_RESPONSE_BIT) {
1263 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1264 ("SkRlmtPacketReceive: Alive Reply.\n"))
1265
1266 if (!(pAC->Addr.Port[PortNumber].PromMode & SK_PROM_MODE_LLC) ||
1267 SK_ADDR_EQUAL(
1268 pRPacket->DstAddr, pAPort->CurrentMacAddress.a)) {
1269 /* Obviously we could send something. */
1270 if (pRPort->CheckingState & SK_RLMT_PCS_TX) {
1271 pRPort->CheckingState &= ~SK_RLMT_PCS_TX;
1272 SkTimerStop(pAC, IoC, &pRPort->DownTxTimer);
1273 }
1274
1275 if ((pRPort->PortState == SK_RLMT_PS_DOWN) &&
1276 !(pRPort->CheckingState & SK_RLMT_PCS_RX)) {
1277 pRPort->PortState = SK_RLMT_PS_GOING_UP;
1278 pRPort->GuTimeStamp = SkOsGetTime(pAC);
1279
1280 SkTimerStop(pAC, IoC, &pRPort->DownTxTimer);
1281
1282 Para.Para32[0] = PortNumber;
1283 Para.Para32[1] = (SK_U32)-1;
1284 SkTimerStart(pAC, IoC, &pRPort->UpTimer,
1285 SK_RLMT_PORTUP_TIM_VAL, SKGE_RLMT,
1286 SK_RLMT_PORTUP_TIM, Para);
1287 }
1288 }
1289
1290 /* Mark sending port as alive? */
1291 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1292 }
1293 else { /* Alive Request Packet. */
1294 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1295 ("SkRlmtPacketReceive: Alive Request.\n"))
1296
1297 pRPort->RxHelloCts++;
1298
1299 /* Answer. */
1300 for (i = 0; i < SK_MAC_ADDR_LEN; i++) {
1301 pRPacket->DstAddr[i] = pRPacket->SrcAddr[i];
1302 pRPacket->SrcAddr[i] =
1303 pAC->Addr.Port[PortNumber].CurrentMacAddress.a[i];
1304 }
1305 pRPacket->SSap |= LLC_COMMAND_RESPONSE_BIT;
1306
1307 Para.pParaPtr = pMb;
1308 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para);
1309 }
1310 break;
1311
1312 case SK_PACKET_CHECK_TX:
1313 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1314 ("SkRlmtPacketReceive: Check your tx line.\n"))
1315
1316 /* A port checking us requests us to check our tx line. */
1317 pRPort->CheckingState |= SK_RLMT_PCS_TX;
1318
1319 /* Start PortDownTx timer. */
1320 Para.Para32[0] = PortNumber;
1321 Para.Para32[1] = (SK_U32)-1;
1322 SkTimerStart(pAC, IoC, &pRPort->DownTxTimer,
1323 SK_RLMT_PORTDOWN_TIM_VAL, SKGE_RLMT,
1324 SK_RLMT_PORTDOWN_TX_TIM, Para);
1325
1326 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1327
1328 if ((Para.pParaPtr = SkRlmtBuildPacket(pAC, IoC, PortNumber,
1329 SK_PACKET_ALIVE, &pAC->Addr.Port[PortNumber].CurrentMacAddress,
1330 &SkRlmtMcAddr)) != NULL) {
1331 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para);
1332 }
1333 break;
1334
1335 case SK_PACKET_ADDR_CHANGED:
1336 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1337 ("SkRlmtPacketReceive: Address Change.\n"))
1338
1339 /* Build the check chain. */
1340 SkRlmtBuildCheckChain(pAC, pRPort->Net->NetNumber);
1341 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1342 break;
1343
1344 default:
1345 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1346 ("SkRlmtPacketReceive: Unknown RLMT packet.\n"))
1347
1348 /* RA;:;: ??? */
1349 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1350 }
1351 }
1352 else if (pSPacket->DSap == SK_RLMT_SPT_DSAP &&
1353 pSPacket->Ctrl == SK_RLMT_SPT_CTRL &&
1354 (pSPacket->SSap & ~LLC_COMMAND_RESPONSE_BIT) == SK_RLMT_SPT_SSAP) {
1355 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1356 ("SkRlmtPacketReceive: BPDU Packet.\n"))
1357
1358 /* Spanning Tree packet. */
1359 pRPort->RxSpHelloCts++;
1360
1361 if (!SK_ADDR_EQUAL(&pSPacket->RootId[2], &pAC->Addr.Net[pAC->Rlmt.
1362 Port[PortNumber].Net->NetNumber].CurrentMacAddress.a[0])) {
1363 /*
1364 * Check segmentation if a new root bridge is set and
1365 * the segmentation check is not currently running.
1366 */
1367 if (!SK_ADDR_EQUAL(&pSPacket->RootId[2], &pRPort->Root.Id[2]) &&
1368 (pAC->Rlmt.Port[PortNumber].Net->LinksUp > 1) &&
1369 (pAC->Rlmt.Port[PortNumber].Net->RlmtMode & SK_RLMT_CHECK_SEG)
1370 != 0 && (pAC->Rlmt.Port[PortNumber].Net->CheckingState &
1371 SK_RLMT_RCS_SEG) == 0) {
1372 pAC->Rlmt.Port[PortNumber].Net->CheckingState |=
1373 SK_RLMT_RCS_START_SEG | SK_RLMT_RCS_SEND_SEG;
1374 }
1375
1376 /* Store tree view of this port. */
1377 for (i = 0; i < 8; i++) {
1378 pRPort->Root.Id[i] = pSPacket->RootId[i];
1379 }
1380 pRPort->RootIdSet = SK_TRUE;
1381
1382 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_DUMP,
1383 ("Root ID %d: %02x %02x %02x %02x %02x %02x %02x %02x.\n",
1384 PortNumber,
1385 pRPort->Root.Id[0], pRPort->Root.Id[1],
1386 pRPort->Root.Id[2], pRPort->Root.Id[3],
1387 pRPort->Root.Id[4], pRPort->Root.Id[5],
1388 pRPort->Root.Id[6], pRPort->Root.Id[7]))
1389 }
1390
1391 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1392 if ((pAC->Rlmt.Port[PortNumber].Net->CheckingState &
1393 SK_RLMT_RCS_REPORT_SEG) != 0) {
1394 SkRlmtCheckSeg(pAC, IoC, pAC->Rlmt.Port[PortNumber].Net->NetNumber);
1395 }
1396 }
1397 else {
1398 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1399 ("SkRlmtPacketReceive: Unknown Packet Type.\n"))
1400
1401 /* Unknown packet. */
1402 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1403 }
1404 return;
1405} /* SkRlmtPacketReceive */
1406
1407
1408/******************************************************************************
1409 *
1410 * SkRlmtCheckPort - check if a port works
1411 *
1412 * Description:
1413 * This routine checks if a port whose link is up received something
1414 * and if it seems to transmit successfully.
1415 *
1416 * # PortState: PsInit, PsLinkDown, PsDown, PsGoingUp, PsUp
1417 * # PortCheckingState (Bitfield): ChkTx, ChkRx, ChkSeg
1418 * # RlmtCheckingState (Bitfield): ChkSeg, StartChkSeg, ReportSeg
1419 *
1420 * if (Rx - RxBpdu == 0) { # No rx.
1421 * if (state == PsUp) {
1422 * PortCheckingState |= ChkRx
1423 * }
1424 * if (ModeCheckSeg && (Timeout ==
1425 * TO_SHORTEN(RLMT_DEFAULT_TIMEOUT))) {
1426 * RlmtCheckingState |= ChkSeg)
1427 * PortCheckingState |= ChkSeg
1428 * }
1429 * NewTimeout = TO_SHORTEN(Timeout)
1430 * if (NewTimeout < RLMT_MIN_TIMEOUT) {
1431 * NewTimeout = RLMT_MIN_TIMEOUT
1432 * PortState = PsDown
1433 * ...
1434 * }
1435 * }
1436 * else { # something was received
1437 * # Set counter to 0 at LinkDown?
1438 * # No - rx may be reported after LinkDown ???
1439 * PortCheckingState &= ~ChkRx
1440 * NewTimeout = RLMT_DEFAULT_TIMEOUT
1441 * if (RxAck == 0) {
1442 * possible reasons:
1443 * is my tx line bad? --
1444 * send RLMT multicast and report
1445 * back internally? (only possible
1446 * between ports on same adapter)
1447 * }
1448 * if (RxChk == 0) {
1449 * possible reasons:
1450 * - tx line of port set to check me
1451 * maybe bad
1452 * - no other port/adapter available or set
1453 * to check me
1454 * - adapter checking me has a longer
1455 * timeout
1456 * ??? anything that can be done here?
1457 * }
1458 * }
1459 *
1460 * Context:
1461 * runtime, pageable?
1462 *
1463 * Returns:
1464 * New timeout value.
1465 */
1466RLMT_STATIC SK_U32 SkRlmtCheckPort(
1467SK_AC *pAC, /* Adapter Context */
1468SK_IOC IoC, /* I/O Context */
1469SK_U32 PortNumber) /* Port to check */
1470{
1471 unsigned i;
1472 SK_U32 NewTimeout;
1473 SK_RLMT_PORT *pRPort;
1474 SK_EVPARA Para;
1475
1476 pRPort = &pAC->Rlmt.Port[PortNumber];
1477
1478 if ((pRPort->PacketsPerTimeSlot - pRPort->BpduPacketsPerTimeSlot) == 0) {
1479 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1480 ("SkRlmtCheckPort %d: No (%d) receives in last time slot.\n",
1481 PortNumber, pRPort->PacketsPerTimeSlot))
1482
1483 /*
1484 * Check segmentation if there was no receive at least twice
1485 * in a row (PortNoRx is already set) and the segmentation
1486 * check is not currently running.
1487 */
1488
1489 if (pRPort->PortNoRx && (pAC->Rlmt.Port[PortNumber].Net->LinksUp > 1) &&
1490 (pAC->Rlmt.Port[PortNumber].Net->RlmtMode & SK_RLMT_CHECK_SEG) &&
1491 !(pAC->Rlmt.Port[PortNumber].Net->CheckingState & SK_RLMT_RCS_SEG)) {
1492 pAC->Rlmt.Port[PortNumber].Net->CheckingState |=
1493 SK_RLMT_RCS_START_SEG | SK_RLMT_RCS_SEND_SEG;
1494 }
1495
1496 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1497 ("SkRlmtCheckPort: PortsSuspect %d, PcsRx %d.\n",
1498 pRPort->PortsSuspect, pRPort->CheckingState & SK_RLMT_PCS_RX))
1499
1500 if (pRPort->PortState != SK_RLMT_PS_DOWN) {
1501 NewTimeout = TO_SHORTEN(pAC->Rlmt.Port[PortNumber].Net->TimeoutValue);
1502 if (NewTimeout < SK_RLMT_MIN_TO_VAL) {
1503 NewTimeout = SK_RLMT_MIN_TO_VAL;
1504 }
1505
1506 if (!(pRPort->CheckingState & SK_RLMT_PCS_RX)) {
1507 Para.Para32[0] = PortNumber;
1508 pRPort->CheckingState |= SK_RLMT_PCS_RX;
1509
1510 /*
1511 * What shall we do if the port checked by this one receives
1512 * our request frames? What's bad - our rx line or his tx line?
1513 */
1514 Para.Para32[1] = (SK_U32)-1;
1515 SkTimerStart(pAC, IoC, &pRPort->DownRxTimer,
1516 SK_RLMT_PORTDOWN_TIM_VAL, SKGE_RLMT,
1517 SK_RLMT_PORTDOWN_RX_TIM, Para);
1518
1519 for (i = 0; i < pRPort->PortsChecked; i++) {
1520 if (pRPort->PortCheck[i].SuspectTx) {
1521 continue;
1522 }
1523 pRPort->PortCheck[i].SuspectTx = SK_TRUE;
1524 pRPort->PortsSuspect++;
1525 if ((Para.pParaPtr =
1526 SkRlmtBuildPacket(pAC, IoC, PortNumber, SK_PACKET_CHECK_TX,
1527 &pAC->Addr.Port[PortNumber].CurrentMacAddress,
1528 &pRPort->PortCheck[i].CheckAddr)) != NULL) {
1529 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para);
1530 }
1531 }
1532 }
1533 }
1534 else { /* PortDown -- or all partners suspect. */
1535 NewTimeout = SK_RLMT_DEF_TO_VAL;
1536 }
1537 pRPort->PortNoRx = SK_TRUE;
1538 }
1539 else { /* A non-BPDU packet was received. */
1540 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1541 ("SkRlmtCheckPort %d: %d (%d) receives in last time slot.\n",
1542 PortNumber,
1543 pRPort->PacketsPerTimeSlot - pRPort->BpduPacketsPerTimeSlot,
1544 pRPort->PacketsPerTimeSlot))
wdenk42d1f032003-10-15 23:53:47 +00001545
wdenk7152b1d2003-09-05 23:19:14 +00001546 SkRlmtPortReceives(pAC, IoC, PortNumber);
1547 if (pAC->Rlmt.CheckSwitch) {
1548 SkRlmtCheckSwitch(pAC, IoC, pRPort->Net->NetNumber);
1549 }
1550
1551 NewTimeout = SK_RLMT_DEF_TO_VAL;
1552 }
1553
1554 return (NewTimeout);
1555} /* SkRlmtCheckPort */
1556
1557
1558/******************************************************************************
1559 *
1560 * SkRlmtSelectBcRx - select new active port, criteria 1 (CLP)
1561 *
1562 * Description:
1563 * This routine selects the port that received a broadcast frame
1564 * substantially later than all other ports.
1565 *
1566 * Context:
1567 * runtime, pageable?
1568 *
1569 * Returns:
1570 * SK_BOOL
1571 */
1572RLMT_STATIC SK_BOOL SkRlmtSelectBcRx(
1573SK_AC *pAC, /* Adapter Context */
1574SK_IOC IoC, /* I/O Context */
1575SK_U32 Active, /* Active port */
1576SK_U32 PrefPort, /* Preferred port */
1577SK_U32 *pSelect) /* New active port */
1578{
1579 SK_U64 BcTimeStamp;
1580 SK_U32 i;
1581 SK_BOOL PortFound;
1582
1583 BcTimeStamp = 0; /* Not totally necessary, but feeling better. */
1584 PortFound = SK_FALSE;
wdenk42d1f032003-10-15 23:53:47 +00001585
wdenk7152b1d2003-09-05 23:19:14 +00001586 /* Select port with the latest TimeStamp. */
1587 for (i = 0; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
1588
1589 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1590 ("TimeStamp Port %d (Down: %d, NoRx: %d): %08x %08x.\n",
1591 i,
wdenk42d1f032003-10-15 23:53:47 +00001592 pAC->Rlmt.Port[i].PortDown, pAC->Rlmt.Port[i].PortNoRx,
wdenk7152b1d2003-09-05 23:19:14 +00001593 *((SK_U32*)(&pAC->Rlmt.Port[i].BcTimeStamp) + OFFS_HI32),
1594 *((SK_U32*)(&pAC->Rlmt.Port[i].BcTimeStamp) + OFFS_LO32)))
1595
1596 if (!pAC->Rlmt.Port[i].PortDown && !pAC->Rlmt.Port[i].PortNoRx) {
1597 if (!PortFound || pAC->Rlmt.Port[i].BcTimeStamp > BcTimeStamp) {
1598 BcTimeStamp = pAC->Rlmt.Port[i].BcTimeStamp;
1599 *pSelect = i;
1600 PortFound = SK_TRUE;
1601 }
1602 }
1603 }
1604
1605 if (PortFound) {
1606 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1607 ("Port %d received the last broadcast.\n", *pSelect))
1608
1609 /* Look if another port's time stamp is similar. */
1610 for (i = 0; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
1611 if (i == *pSelect) {
1612 continue;
1613 }
1614 if (!pAC->Rlmt.Port[i].PortDown && !pAC->Rlmt.Port[i].PortNoRx &&
1615 (pAC->Rlmt.Port[i].BcTimeStamp >
1616 BcTimeStamp - SK_RLMT_BC_DELTA ||
1617 pAC->Rlmt.Port[i].BcTimeStamp +
1618 SK_RLMT_BC_DELTA > BcTimeStamp)) {
1619 PortFound = SK_FALSE;
wdenk42d1f032003-10-15 23:53:47 +00001620
wdenk7152b1d2003-09-05 23:19:14 +00001621 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1622 ("Port %d received a broadcast at a similar time.\n", i))
1623 break;
1624 }
1625 }
1626 }
1627
1628#ifdef DEBUG
1629 if (PortFound) {
1630 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1631 ("SK_RLMT_SELECT_BCRX found Port %d receiving the substantially "
1632 "latest broadcast (%u).\n",
1633 *pSelect,
1634 BcTimeStamp - pAC->Rlmt.Port[1 - *pSelect].BcTimeStamp))
1635 }
1636#endif /* DEBUG */
1637
1638 return (PortFound);
1639} /* SkRlmtSelectBcRx */
1640
1641
1642/******************************************************************************
1643 *
1644 * SkRlmtSelectNotSuspect - select new active port, criteria 2 (CLP)
1645 *
1646 * Description:
1647 * This routine selects a good port (it is PortUp && !SuspectRx).
1648 *
1649 * Context:
1650 * runtime, pageable?
1651 *
1652 * Returns:
1653 * SK_BOOL
1654 */
1655RLMT_STATIC SK_BOOL SkRlmtSelectNotSuspect(
1656SK_AC *pAC, /* Adapter Context */
1657SK_IOC IoC, /* I/O Context */
1658SK_U32 Active, /* Active port */
1659SK_U32 PrefPort, /* Preferred port */
1660SK_U32 *pSelect) /* New active port */
1661{
1662 SK_U32 i;
1663 SK_BOOL PortFound;
1664
1665 PortFound = SK_FALSE;
1666
1667 /* Select first port that is PortUp && !SuspectRx. */
1668 for (i = 0; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
1669 if (!pAC->Rlmt.Port[i].PortDown &&
1670 !(pAC->Rlmt.Port[i].CheckingState & SK_RLMT_PCS_RX)) {
1671 *pSelect = i;
1672 if (!pAC->Rlmt.Port[Active].PortDown &&
1673 !(pAC->Rlmt.Port[Active].CheckingState & SK_RLMT_PCS_RX)) {
1674 *pSelect = Active;
1675 }
1676 if (!pAC->Rlmt.Port[PrefPort].PortDown &&
1677 !(pAC->Rlmt.Port[PrefPort].CheckingState & SK_RLMT_PCS_RX)) {
1678 *pSelect = PrefPort;
1679 }
1680 PortFound = SK_TRUE;
1681 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1682 ("SK_RLMT_SELECT_NOTSUSPECT found Port %d up and not check RX.\n",
1683 *pSelect))
1684 break;
1685 }
1686 }
1687 return (PortFound);
1688} /* SkRlmtSelectNotSuspect */
1689
1690
1691/******************************************************************************
1692 *
1693 * SkRlmtSelectUp - select new active port, criteria 3, 4 (CLP)
1694 *
1695 * Description:
1696 * This routine selects a port that is up.
1697 *
1698 * Context:
1699 * runtime, pageable?
1700 *
1701 * Returns:
1702 * SK_BOOL
1703 */
1704RLMT_STATIC SK_BOOL SkRlmtSelectUp(
1705SK_AC *pAC, /* Adapter Context */
1706SK_IOC IoC, /* I/O Context */
1707SK_U32 Active, /* Active port */
1708SK_U32 PrefPort, /* Preferred port */
1709SK_U32 *pSelect, /* New active port */
1710SK_BOOL AutoNegDone) /* Successfully auto-negotiated? */
1711{
1712 SK_U32 i;
1713 SK_BOOL PortFound;
1714
1715 PortFound = SK_FALSE;
1716
1717 /* Select first port that is PortUp. */
1718 for (i = 0; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
1719 if (pAC->Rlmt.Port[i].PortState == SK_RLMT_PS_UP &&
1720 pAC->GIni.GP[i].PAutoNegFail != AutoNegDone) {
1721 *pSelect = i;
1722 if (pAC->Rlmt.Port[Active].PortState == SK_RLMT_PS_UP &&
1723 pAC->GIni.GP[Active].PAutoNegFail != AutoNegDone) {
1724 *pSelect = Active;
1725 }
1726 if (pAC->Rlmt.Port[PrefPort].PortState == SK_RLMT_PS_UP &&
1727 pAC->GIni.GP[PrefPort].PAutoNegFail != AutoNegDone) {
1728 *pSelect = PrefPort;
1729 }
1730 PortFound = SK_TRUE;
1731 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1732 ("SK_RLMT_SELECT_UP found Port %d up.\n", *pSelect))
1733 break;
1734 }
1735 }
1736 return (PortFound);
1737} /* SkRlmtSelectUp */
1738
1739
1740/******************************************************************************
1741 *
1742 * SkRlmtSelectGoingUp - select new active port, criteria 5, 6 (CLP)
1743 *
1744 * Description:
1745 * This routine selects the port that is going up for the longest time.
1746 *
1747 * Context:
1748 * runtime, pageable?
1749 *
1750 * Returns:
1751 * SK_BOOL
1752 */
1753RLMT_STATIC SK_BOOL SkRlmtSelectGoingUp(
1754SK_AC *pAC, /* Adapter Context */
1755SK_IOC IoC, /* I/O Context */
1756SK_U32 Active, /* Active port */
1757SK_U32 PrefPort, /* Preferred port */
1758SK_U32 *pSelect, /* New active port */
1759SK_BOOL AutoNegDone) /* Successfully auto-negotiated? */
1760{
1761 SK_U64 GuTimeStamp;
1762 SK_U32 i;
1763 SK_BOOL PortFound;
1764
1765 GuTimeStamp = 0;
1766 PortFound = SK_FALSE;
1767
1768 /* Select port that is PortGoingUp for the longest time. */
1769 for (i = 0; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
1770 if (pAC->Rlmt.Port[i].PortState == SK_RLMT_PS_GOING_UP &&
1771 pAC->GIni.GP[i].PAutoNegFail != AutoNegDone) {
1772 GuTimeStamp = pAC->Rlmt.Port[i].GuTimeStamp;
1773 *pSelect = i;
1774 PortFound = SK_TRUE;
1775 break;
1776 }
1777 }
1778
1779 if (!PortFound) {
1780 return (SK_FALSE);
1781 }
1782
1783 for (i = *pSelect + 1; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
1784 if (pAC->Rlmt.Port[i].PortState == SK_RLMT_PS_GOING_UP &&
1785 pAC->Rlmt.Port[i].GuTimeStamp < GuTimeStamp &&
1786 pAC->GIni.GP[i].PAutoNegFail != AutoNegDone) {
1787 GuTimeStamp = pAC->Rlmt.Port[i].GuTimeStamp;
1788 *pSelect = i;
1789 }
1790 }
1791
1792 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1793 ("SK_RLMT_SELECT_GOINGUP found Port %d going up.\n", *pSelect))
1794 return (SK_TRUE);
1795} /* SkRlmtSelectGoingUp */
1796
1797
1798/******************************************************************************
1799 *
1800 * SkRlmtSelectDown - select new active port, criteria 7, 8 (CLP)
1801 *
1802 * Description:
1803 * This routine selects a port that is down.
1804 *
1805 * Context:
1806 * runtime, pageable?
1807 *
1808 * Returns:
1809 * SK_BOOL
1810 */
1811RLMT_STATIC SK_BOOL SkRlmtSelectDown(
1812SK_AC *pAC, /* Adapter Context */
1813SK_IOC IoC, /* I/O Context */
1814SK_U32 Active, /* Active port */
1815SK_U32 PrefPort, /* Preferred port */
1816SK_U32 *pSelect, /* New active port */
1817SK_BOOL AutoNegDone) /* Successfully auto-negotiated? */
1818{
1819 SK_U32 i;
1820 SK_BOOL PortFound;
1821
1822 PortFound = SK_FALSE;
1823
1824 /* Select first port that is PortDown. */
1825 for (i = 0; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
1826 if (pAC->Rlmt.Port[i].PortState == SK_RLMT_PS_DOWN &&
1827 pAC->GIni.GP[i].PAutoNegFail != AutoNegDone) {
1828 *pSelect = i;
1829 if (pAC->Rlmt.Port[Active].PortState == SK_RLMT_PS_DOWN &&
1830 pAC->GIni.GP[Active].PAutoNegFail != AutoNegDone) {
1831 *pSelect = Active;
1832 }
1833 if (pAC->Rlmt.Port[PrefPort].PortState == SK_RLMT_PS_DOWN &&
1834 pAC->GIni.GP[PrefPort].PAutoNegFail != AutoNegDone) {
1835 *pSelect = PrefPort;
1836 }
1837 PortFound = SK_TRUE;
1838 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1839 ("SK_RLMT_SELECT_DOWN found Port %d down.\n", *pSelect))
1840 break;
1841 }
1842 }
1843 return (PortFound);
1844} /* SkRlmtSelectDown */
1845
1846
1847/******************************************************************************
1848 *
1849 * SkRlmtCheckSwitch - select new active port and switch to it
1850 *
1851 * Description:
1852 * This routine decides which port should be the active one and queues
1853 * port switching if necessary.
1854 *
1855 * Context:
1856 * runtime, pageable?
1857 *
1858 * Returns:
1859 * Nothing.
1860 */
1861RLMT_STATIC void SkRlmtCheckSwitch(
1862SK_AC *pAC, /* Adapter Context */
1863SK_IOC IoC, /* I/O Context */
1864SK_U32 NetIdx) /* Net index */
1865{
1866 SK_EVPARA Para;
1867 SK_U32 Active;
1868 SK_U32 PrefPort;
1869 SK_U32 i;
1870 SK_BOOL PortFound;
1871
1872 Active = pAC->Rlmt.Net[NetIdx].ActivePort; /* Index of active port. */
1873 PrefPort = pAC->Rlmt.Net[NetIdx].PrefPort; /* Index of preferred port. */
1874 PortFound = SK_FALSE;
1875 pAC->Rlmt.CheckSwitch = SK_FALSE;
1876
1877#if 0 /* RW 2001/10/18 - active port becomes always prefered one */
1878 if (pAC->Rlmt.Net[NetIdx].Preference == 0xFFFFFFFF) { /* Automatic */
1879 /* disable auto-fail back */
1880 PrefPort = Active;
1881 }
1882#endif
1883
1884 if (pAC->Rlmt.Net[NetIdx].LinksUp == 0) {
1885 /* Last link went down - shut down the net. */
1886 pAC->Rlmt.Net[NetIdx].RlmtState = SK_RLMT_RS_NET_DOWN;
1887 Para.Para32[0] = SK_RLMT_NET_DOWN_TEMP;
1888 Para.Para32[1] = NetIdx;
1889 SkEventQueue(pAC, SKGE_DRV, SK_DRV_NET_DOWN, Para);
1890
1891 Para.Para32[0] = pAC->Rlmt.Net[NetIdx].
1892 Port[pAC->Rlmt.Net[NetIdx].ActivePort]->PortNumber;
1893 Para.Para32[1] = NetIdx;
1894 SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_ACTIVE_DOWN, Para);
1895 return;
1896 } /* pAC->Rlmt.LinksUp == 0 */
1897 else if (pAC->Rlmt.Net[NetIdx].LinksUp == 1 &&
1898 pAC->Rlmt.Net[NetIdx].RlmtState == SK_RLMT_RS_NET_DOWN) {
1899 /* First link came up - get the net up. */
1900 pAC->Rlmt.Net[NetIdx].RlmtState = SK_RLMT_RS_NET_UP;
1901
1902 /*
1903 * If pAC->Rlmt.ActivePort != Para.Para32[0],
1904 * the DRV switches to the port that came up.
1905 */
1906 for (i = 0; i < pAC->Rlmt.Net[NetIdx].NumPorts; i++) {
1907 if (!pAC->Rlmt.Net[NetIdx].Port[i]->LinkDown) {
1908 if (!pAC->Rlmt.Net[NetIdx].Port[Active]->LinkDown) {
1909 i = Active;
1910 }
1911 if (!pAC->Rlmt.Net[NetIdx].Port[PrefPort]->LinkDown) {
1912 i = PrefPort;
1913 }
1914 PortFound = SK_TRUE;
1915 break;
1916 }
1917 }
1918
1919 if (PortFound) {
1920 Para.Para32[0] = pAC->Rlmt.Net[NetIdx].Port[i]->PortNumber;
1921 Para.Para32[1] = NetIdx;
1922 SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_ACTIVE_UP, Para);
1923
1924 pAC->Rlmt.Net[NetIdx].ActivePort = i;
1925 Para.Para32[0] = pAC->Rlmt.Net[NetIdx].Port[i]->PortNumber;
1926 Para.Para32[1] = NetIdx;
1927 SkEventQueue(pAC, SKGE_DRV, SK_DRV_NET_UP, Para);
1928
1929 if ((pAC->Rlmt.Net[NetIdx].RlmtMode & SK_RLMT_TRANSPARENT) == 0 &&
1930 (Para.pParaPtr = SkRlmtBuildPacket(pAC, IoC,
1931 pAC->Rlmt.Net[NetIdx].Port[i]->PortNumber,
1932 SK_PACKET_ANNOUNCE, &pAC->Addr.Net[NetIdx].
1933 CurrentMacAddress, &SkRlmtMcAddr)) != NULL) {
1934 /*
1935 * Send announce packet to RLMT multicast address to force
1936 * switches to learn the new location of the logical MAC address.
1937 */
1938 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para);
1939 }
1940 }
1941 else {
1942 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_RLMT_E007, SKERR_RLMT_E007_MSG);
1943 }
1944
1945 return;
1946 } /* LinksUp == 1 && RlmtState == SK_RLMT_RS_NET_DOWN */
1947 else { /* Cannot be reached in dual-net mode. */
1948 Para.Para32[0] = Active;
1949
1950 /*
1951 * Preselection:
1952 * If RLMT Mode != CheckLinkState
1953 * select port that received a broadcast frame substantially later
1954 * than all other ports
1955 * else select first port that is not SuspectRx
1956 * else select first port that is PortUp
1957 * else select port that is PortGoingUp for the longest time
1958 * else select first port that is PortDown
1959 * else stop.
1960 *
1961 * For the preselected port:
1962 * If ActivePort is equal in quality, select ActivePort.
1963 *
1964 * If PrefPort is equal in quality, select PrefPort.
1965 *
1966 * If ActivePort != SelectedPort,
1967 * If old ActivePort is LinkDown,
1968 * SwitchHard
1969 * else
1970 * SwitchSoft
1971 */
1972 /* check of ChgBcPrio flag added */
1973 if ((pAC->Rlmt.Net[0].RlmtMode != SK_RLMT_MODE_CLS) &&
1974 (!pAC->Rlmt.Net[0].ChgBcPrio)) {
wdenk42d1f032003-10-15 23:53:47 +00001975
wdenk7152b1d2003-09-05 23:19:14 +00001976 if (!PortFound) {
1977 PortFound = SkRlmtSelectBcRx(
1978 pAC, IoC, Active, PrefPort, &Para.Para32[1]);
1979 }
1980
1981 if (!PortFound) {
1982 PortFound = SkRlmtSelectNotSuspect(
1983 pAC, IoC, Active, PrefPort, &Para.Para32[1]);
1984 }
1985 } /* pAC->Rlmt.RlmtMode != SK_RLMT_MODE_CLS */
1986
1987 /* with changed priority for last broadcast received */
1988 if ((pAC->Rlmt.Net[0].RlmtMode != SK_RLMT_MODE_CLS) &&
1989 (pAC->Rlmt.Net[0].ChgBcPrio)) {
1990 if (!PortFound) {
1991 PortFound = SkRlmtSelectNotSuspect(
1992 pAC, IoC, Active, PrefPort, &Para.Para32[1]);
1993 }
1994
1995 if (!PortFound) {
1996 PortFound = SkRlmtSelectBcRx(
1997 pAC, IoC, Active, PrefPort, &Para.Para32[1]);
1998 }
1999 } /* pAC->Rlmt.RlmtMode != SK_RLMT_MODE_CLS */
2000
2001 if (!PortFound) {
2002 PortFound = SkRlmtSelectUp(
2003 pAC, IoC, Active, PrefPort, &Para.Para32[1], AUTONEG_SUCCESS);
2004 }
2005
2006 if (!PortFound) {
2007 PortFound = SkRlmtSelectUp(
2008 pAC, IoC, Active, PrefPort, &Para.Para32[1], AUTONEG_FAILED);
2009 }
2010
2011 if (!PortFound) {
2012 PortFound = SkRlmtSelectGoingUp(
2013 pAC, IoC, Active, PrefPort, &Para.Para32[1], AUTONEG_SUCCESS);
2014 }
2015
2016 if (!PortFound) {
2017 PortFound = SkRlmtSelectGoingUp(
2018 pAC, IoC, Active, PrefPort, &Para.Para32[1], AUTONEG_FAILED);
2019 }
2020
2021 if (pAC->Rlmt.Net[0].RlmtMode != SK_RLMT_MODE_CLS) {
2022 if (!PortFound) {
2023 PortFound = SkRlmtSelectDown(pAC, IoC,
2024 Active, PrefPort, &Para.Para32[1], AUTONEG_SUCCESS);
2025 }
2026
2027 if (!PortFound) {
2028 PortFound = SkRlmtSelectDown(pAC, IoC,
2029 Active, PrefPort, &Para.Para32[1], AUTONEG_FAILED);
2030 }
2031 } /* pAC->Rlmt.RlmtMode != SK_RLMT_MODE_CLS */
2032
2033 if (PortFound) {
2034
2035 if (Para.Para32[1] != Active) {
2036 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2037 ("Active: %d, Para1: %d.\n", Active, Para.Para32[1]))
2038 pAC->Rlmt.Net[NetIdx].ActivePort = Para.Para32[1];
2039 Para.Para32[0] = pAC->Rlmt.Net[NetIdx].
2040 Port[Para.Para32[0]]->PortNumber;
2041 Para.Para32[1] = pAC->Rlmt.Net[NetIdx].
2042 Port[Para.Para32[1]]->PortNumber;
2043 SK_HWAC_LINK_LED(pAC, IoC, Para.Para32[1], SK_LED_ACTIVE);
2044 if (pAC->Rlmt.Port[Active].LinkDown) {
2045 SkEventQueue(pAC, SKGE_DRV, SK_DRV_SWITCH_HARD, Para);
2046 }
2047 else {
2048 SK_HWAC_LINK_LED(pAC, IoC, Para.Para32[0], SK_LED_STANDBY);
2049 SkEventQueue(pAC, SKGE_DRV, SK_DRV_SWITCH_SOFT, Para);
2050 }
2051 Para.Para32[1] = NetIdx;
2052 Para.Para32[0] =
2053 pAC->Rlmt.Net[NetIdx].Port[Para.Para32[0]]->PortNumber;
2054 SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_ACTIVE_DOWN, Para);
2055 Para.Para32[0] = pAC->Rlmt.Net[NetIdx].
2056 Port[pAC->Rlmt.Net[NetIdx].ActivePort]->PortNumber;
2057 SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_ACTIVE_UP, Para);
2058 if ((pAC->Rlmt.Net[NetIdx].RlmtMode & SK_RLMT_TRANSPARENT) == 0 &&
2059 (Para.pParaPtr = SkRlmtBuildPacket(pAC, IoC, Para.Para32[0],
2060 SK_PACKET_ANNOUNCE, &pAC->Addr.Net[NetIdx].CurrentMacAddress,
2061 &SkRlmtMcAddr)) != NULL) {
2062 /*
2063 * Send announce packet to RLMT multicast address to force
2064 * switches to learn the new location of the logical
2065 * MAC address.
2066 */
2067 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para);
2068 } /* (Para.pParaPtr = SkRlmtBuildPacket(...)) != NULL */
2069 } /* Para.Para32[1] != Active */
2070 } /* PortFound */
2071 else {
2072 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_RLMT_E004, SKERR_RLMT_E004_MSG);
2073 }
2074 } /* LinksUp > 1 || LinksUp == 1 && RlmtState != SK_RLMT_RS_NET_DOWN */
2075 return;
2076} /* SkRlmtCheckSwitch */
2077
2078
2079/******************************************************************************
2080 *
2081 * SkRlmtCheckSeg - Report if segmentation is detected
2082 *
2083 * Description:
2084 * This routine checks if the ports see different root bridges and reports
2085 * segmentation in such a case.
2086 *
2087 * Context:
2088 * runtime, pageable?
2089 *
2090 * Returns:
2091 * Nothing.
2092 */
2093RLMT_STATIC void SkRlmtCheckSeg(
2094SK_AC *pAC, /* Adapter Context */
2095SK_IOC IoC, /* I/O Context */
2096SK_U32 NetIdx) /* Net number */
2097{
2098 SK_EVPARA Para;
2099 SK_RLMT_NET *pNet;
2100 SK_U32 i, j;
2101 SK_BOOL Equal;
2102
2103 pNet = &pAC->Rlmt.Net[NetIdx];
2104 pNet->RootIdSet = SK_FALSE;
2105 Equal = SK_TRUE;
2106
2107 for (i = 0; i < pNet->NumPorts; i++) {
2108 if (pNet->Port[i]->LinkDown || !pNet->Port[i]->RootIdSet) {
2109 continue;
2110 }
2111
2112 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_DUMP,
2113 ("Root ID %d: %02x %02x %02x %02x %02x %02x %02x %02x.\n", i,
2114 pNet->Port[i]->Root.Id[0], pNet->Port[i]->Root.Id[1],
2115 pNet->Port[i]->Root.Id[2], pNet->Port[i]->Root.Id[3],
2116 pNet->Port[i]->Root.Id[4], pNet->Port[i]->Root.Id[5],
2117 pNet->Port[i]->Root.Id[6], pNet->Port[i]->Root.Id[7]))
2118
2119 if (!pNet->RootIdSet) {
2120 pNet->Root = pNet->Port[i]->Root;
2121 pNet->RootIdSet = SK_TRUE;
2122 continue;
2123 }
2124
2125 for (j = 0; j < 8; j ++) {
2126 Equal &= pNet->Port[i]->Root.Id[j] == pNet->Root.Id[j];
2127 if (!Equal) {
2128 break;
2129 }
2130 }
wdenk42d1f032003-10-15 23:53:47 +00002131
wdenk7152b1d2003-09-05 23:19:14 +00002132 if (!Equal) {
2133 SK_ERR_LOG(pAC, SK_ERRCL_COMM, SKERR_RLMT_E005, SKERR_RLMT_E005_MSG);
2134 Para.Para32[0] = NetIdx;
2135 Para.Para32[1] = (SK_U32)-1;
2136 SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_SEGMENTATION, Para);
2137
2138 pNet->CheckingState &= ~SK_RLMT_RCS_REPORT_SEG;
2139
2140 /* 2000-03-06 RA: New. */
2141 Para.Para32[0] = NetIdx;
2142 Para.Para32[1] = (SK_U32)-1;
2143 SkTimerStart(pAC, IoC, &pNet->SegTimer, SK_RLMT_SEG_TO_VAL,
2144 SKGE_RLMT, SK_RLMT_SEG_TIM, Para);
2145 break;
2146 }
2147 } /* for (i = 0; i < pNet->NumPorts; i++) */
2148
2149 /* 2000-03-06 RA: Moved here. */
2150 /* Segmentation check not running anymore. */
2151 pNet->CheckingState &= ~SK_RLMT_RCS_SEG;
2152
2153} /* SkRlmtCheckSeg */
2154
2155
2156/******************************************************************************
2157 *
2158 * SkRlmtPortStart - initialize port variables and start port
2159 *
2160 * Description:
2161 * This routine initializes a port's variables and issues a PORT_START
2162 * to the HWAC module. This handles retries if the start fails or the
2163 * link eventually goes down.
2164 *
2165 * Context:
2166 * runtime, pageable?
2167 *
2168 * Returns:
2169 * Nothing
2170 */
2171RLMT_STATIC void SkRlmtPortStart(
2172SK_AC *pAC, /* Adapter Context */
2173SK_IOC IoC, /* I/O Context */
2174SK_U32 PortNumber) /* Port number */
2175{
2176 SK_EVPARA Para;
2177
2178 pAC->Rlmt.Port[PortNumber].PortState = SK_RLMT_PS_LINK_DOWN;
2179 pAC->Rlmt.Port[PortNumber].PortStarted = SK_TRUE;
2180 pAC->Rlmt.Port[PortNumber].LinkDown = SK_TRUE;
2181 pAC->Rlmt.Port[PortNumber].PortDown = SK_TRUE;
2182 pAC->Rlmt.Port[PortNumber].CheckingState = 0;
2183 pAC->Rlmt.Port[PortNumber].RootIdSet = SK_FALSE;
2184 Para.Para32[0] = PortNumber;
2185 Para.Para32[1] = (SK_U32)-1;
2186 SkEventQueue(pAC, SKGE_HWAC, SK_HWEV_PORT_START, Para);
2187} /* SkRlmtPortStart */
2188
2189
2190/******************************************************************************
2191 *
2192 * SkRlmtEvtPortStartTim - PORT_START_TIM
2193 *
2194 * Description:
2195 * This routine handles PORT_START_TIM events.
2196 *
2197 * Context:
2198 * runtime, pageable?
2199 * may be called after SK_INIT_IO
2200 *
2201 * Returns:
2202 * Nothing
2203 */
2204RLMT_STATIC void SkRlmtEvtPortStartTim(
2205SK_AC *pAC, /* Adapter Context */
2206SK_IOC IoC, /* I/O Context */
2207SK_EVPARA Para) /* SK_U32 PortNumber; SK_U32 -1 */
2208{
2209 SK_U32 i;
2210
2211 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2212 ("SK_RLMT_PORTSTART_TIMEOUT Port %d Event BEGIN.\n", Para.Para32[0]))
2213
2214 if (Para.Para32[1] != (SK_U32)-1) {
2215 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2216 ("Bad Parameter.\n"))
2217 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2218 ("SK_RLMT_PORTSTART_TIMEOUT Event EMPTY.\n"))
2219 return;
2220 }
2221
2222 /*
2223 * Used to start non-preferred ports if the preferred one
2224 * does not come up.
2225 * This timeout needs only be set when starting the first
2226 * (preferred) port.
2227 */
2228 if (pAC->Rlmt.Port[Para.Para32[0]].LinkDown) {
2229 /* PORT_START failed. */
2230 for (i = 0; i < pAC->Rlmt.Port[Para.Para32[0]].Net->NumPorts; i++) {
2231 if (!pAC->Rlmt.Port[Para.Para32[0]].Net->Port[i]->PortStarted) {
2232 SkRlmtPortStart(pAC, IoC,
2233 pAC->Rlmt.Port[Para.Para32[0]].Net->Port[i]->PortNumber);
2234 }
2235 }
2236 }
2237
2238 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2239 ("SK_RLMT_PORTSTART_TIMEOUT Event END.\n"))
2240} /* SkRlmtEvtPortStartTim */
2241
2242
2243/******************************************************************************
2244 *
2245 * SkRlmtEvtLinkUp - LINK_UP
2246 *
2247 * Description:
2248 * This routine handles LLINK_UP events.
2249 *
2250 * Context:
2251 * runtime, pageable?
2252 * may be called after SK_INIT_IO
2253 *
2254 * Returns:
2255 * Nothing
2256 */
2257RLMT_STATIC void SkRlmtEvtLinkUp(
2258SK_AC *pAC, /* Adapter Context */
2259SK_IOC IoC, /* I/O Context */
2260SK_EVPARA Para) /* SK_U32 PortNumber; SK_U32 Undefined */
2261{
2262 SK_U32 i;
2263 SK_RLMT_PORT *pRPort;
2264 SK_EVPARA Para2;
2265
2266 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2267 ("SK_RLMT_LINK_UP Port %d Event BEGIN.\n", Para.Para32[0]))
2268
2269 pRPort = &pAC->Rlmt.Port[Para.Para32[0]];
2270 if (!pRPort->PortStarted) {
2271 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_RLMT_E008, SKERR_RLMT_E008_MSG);
2272
2273 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2274 ("SK_RLMT_LINK_UP Event EMPTY.\n"))
2275 return;
2276 }
2277
2278 if (!pRPort->LinkDown) {
2279 /* RA;:;: Any better solution? */
2280 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2281 ("SK_RLMT_LINK_UP Event EMPTY.\n"))
2282 return;
2283 }
2284
2285 SkTimerStop(pAC, IoC, &pRPort->UpTimer);
2286 SkTimerStop(pAC, IoC, &pRPort->DownRxTimer);
2287 SkTimerStop(pAC, IoC, &pRPort->DownTxTimer);
2288
2289 /* Do something if timer already fired? */
2290
2291 pRPort->LinkDown = SK_FALSE;
2292 pRPort->PortState = SK_RLMT_PS_GOING_UP;
2293 pRPort->GuTimeStamp = SkOsGetTime(pAC);
2294 pRPort->BcTimeStamp = 0;
2295 pRPort->Net->LinksUp++;
2296 if (pRPort->Net->LinksUp == 1) {
2297 SK_HWAC_LINK_LED(pAC, IoC, Para.Para32[0], SK_LED_ACTIVE);
2298 }
2299 else {
2300 SK_HWAC_LINK_LED(pAC, IoC, Para.Para32[0], SK_LED_STANDBY);
2301 }
2302
2303 for (i = 0; i < pRPort->Net->NumPorts; i++) {
2304 if (!pRPort->Net->Port[i]->PortStarted) {
2305 SkRlmtPortStart(pAC, IoC, pRPort->Net->Port[i]->PortNumber);
2306 }
2307 }
2308
2309 SkRlmtCheckSwitch(pAC, IoC, pRPort->Net->NetNumber);
2310
2311 if (pRPort->Net->LinksUp >= 2) {
2312 if (pRPort->Net->RlmtMode & SK_RLMT_CHECK_LOC_LINK) {
2313 /* Build the check chain. */
2314 SkRlmtBuildCheckChain(pAC, pRPort->Net->NetNumber);
2315 }
2316 }
2317
2318 /* If the first link comes up, start the periodical RLMT timeout. */
2319 if (pRPort->Net->NumPorts > 1 && pRPort->Net->LinksUp == 1 &&
2320 (pRPort->Net->RlmtMode & SK_RLMT_CHECK_OTHERS) != 0) {
2321 Para2.Para32[0] = pRPort->Net->NetNumber;
2322 Para2.Para32[1] = (SK_U32)-1;
2323 SkTimerStart(pAC, IoC, &pRPort->Net->LocTimer,
2324 pRPort->Net->TimeoutValue, SKGE_RLMT, SK_RLMT_TIM, Para2);
2325 }
2326
2327 Para2 = Para;
2328 Para2.Para32[1] = (SK_U32)-1;
2329 SkTimerStart(pAC, IoC, &pRPort->UpTimer, SK_RLMT_PORTUP_TIM_VAL,
2330 SKGE_RLMT, SK_RLMT_PORTUP_TIM, Para2);
wdenk42d1f032003-10-15 23:53:47 +00002331
wdenk7152b1d2003-09-05 23:19:14 +00002332 /* Later: if (pAC->Rlmt.RlmtMode & SK_RLMT_CHECK_LOC_LINK) && */
2333 if ((pRPort->Net->RlmtMode & SK_RLMT_TRANSPARENT) == 0 &&
2334 (pRPort->Net->RlmtMode & SK_RLMT_CHECK_LINK) != 0 &&
2335 (Para2.pParaPtr =
2336 SkRlmtBuildPacket(pAC, IoC, Para.Para32[0], SK_PACKET_ANNOUNCE,
2337 &pAC->Addr.Port[Para.Para32[0]].CurrentMacAddress, &SkRlmtMcAddr)
2338 ) != NULL) {
2339 /* Send "new" packet to RLMT multicast address. */
2340 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para2);
2341 }
2342
2343 if (pRPort->Net->RlmtMode & SK_RLMT_CHECK_SEG) {
2344 if ((Para2.pParaPtr =
2345 SkRlmtBuildSpanningTreePacket(pAC, IoC, Para.Para32[0])) != NULL) {
2346 pAC->Rlmt.Port[Para.Para32[0]].RootIdSet = SK_FALSE;
2347 pRPort->Net->CheckingState |=
2348 SK_RLMT_RCS_SEG | SK_RLMT_RCS_REPORT_SEG;
2349
2350 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para2);
2351
2352 Para.Para32[1] = (SK_U32)-1;
2353 SkTimerStart(pAC, IoC, &pRPort->Net->SegTimer,
2354 SK_RLMT_SEG_TO_VAL, SKGE_RLMT, SK_RLMT_SEG_TIM, Para);
2355 }
2356 }
2357
2358 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2359 ("SK_RLMT_LINK_UP Event END.\n"))
2360} /* SkRlmtEvtLinkUp */
2361
2362
2363/******************************************************************************
2364 *
2365 * SkRlmtEvtPortUpTim - PORT_UP_TIM
2366 *
2367 * Description:
2368 * This routine handles PORT_UP_TIM events.
2369 *
2370 * Context:
2371 * runtime, pageable?
2372 * may be called after SK_INIT_IO
2373 *
2374 * Returns:
2375 * Nothing
2376 */
2377RLMT_STATIC void SkRlmtEvtPortUpTim(
2378SK_AC *pAC, /* Adapter Context */
2379SK_IOC IoC, /* I/O Context */
2380SK_EVPARA Para) /* SK_U32 PortNumber; SK_U32 -1 */
2381{
2382 SK_RLMT_PORT *pRPort;
2383
2384 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2385 ("SK_RLMT_PORTUP_TIM Port %d Event BEGIN.\n", Para.Para32[0]))
2386
2387 if (Para.Para32[1] != (SK_U32)-1) {
2388 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2389 ("Bad Parameter.\n"))
2390 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2391 ("SK_RLMT_PORTUP_TIM Event EMPTY.\n"))
2392 return;
2393 }
2394
2395 pRPort = &pAC->Rlmt.Port[Para.Para32[0]];
2396 if (pRPort->LinkDown || (pRPort->PortState == SK_RLMT_PS_UP)) {
2397 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2398 ("SK_RLMT_PORTUP_TIM Port %d Event EMPTY.\n", Para.Para32[0]))
2399 return;
2400 }
2401
2402 pRPort->PortDown = SK_FALSE;
2403 pRPort->PortState = SK_RLMT_PS_UP;
2404 pRPort->Net->PortsUp++;
2405 if (pRPort->Net->RlmtState != SK_RLMT_RS_INIT) {
2406 if (pAC->Rlmt.NumNets <= 1) {
2407 SkRlmtCheckSwitch(pAC, IoC, pRPort->Net->NetNumber);
2408 }
2409 SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_PORT_UP, Para);
2410 }
2411
2412 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2413 ("SK_RLMT_PORTUP_TIM Event END.\n"))
2414} /* SkRlmtEvtPortUpTim */
2415
2416
2417/******************************************************************************
2418 *
2419 * SkRlmtEvtPortDownTim - PORT_DOWN_*
2420 *
2421 * Description:
2422 * This routine handles PORT_DOWN_* events.
2423 *
2424 * Context:
2425 * runtime, pageable?
2426 * may be called after SK_INIT_IO
2427 *
2428 * Returns:
2429 * Nothing
2430 */
2431RLMT_STATIC void SkRlmtEvtPortDownX(
2432SK_AC *pAC, /* Adapter Context */
2433SK_IOC IoC, /* I/O Context */
2434SK_U32 Event, /* Event code */
2435SK_EVPARA Para) /* SK_U32 PortNumber; SK_U32 -1 */
2436{
2437 SK_RLMT_PORT *pRPort;
2438
2439 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2440 ("SK_RLMT_PORTDOWN* Port %d Event (%d) BEGIN.\n",
2441 Para.Para32[0], Event))
2442
2443 if (Para.Para32[1] != (SK_U32)-1) {
2444 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2445 ("Bad Parameter.\n"))
2446 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2447 ("SK_RLMT_PORTDOWN* Event EMPTY.\n"))
2448 return;
2449 }
2450
2451 pRPort = &pAC->Rlmt.Port[Para.Para32[0]];
2452 if (!pRPort->PortStarted || (Event == SK_RLMT_PORTDOWN_TX_TIM &&
2453 !(pRPort->CheckingState & SK_RLMT_PCS_TX))) {
2454 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2455 ("SK_RLMT_PORTDOWN* Event (%d) EMPTY.\n", Event))
2456 return;
2457 }
wdenk42d1f032003-10-15 23:53:47 +00002458
wdenk7152b1d2003-09-05 23:19:14 +00002459 /* Stop port's timers. */
2460 SkTimerStop(pAC, IoC, &pRPort->UpTimer);
2461 SkTimerStop(pAC, IoC, &pRPort->DownRxTimer);
2462 SkTimerStop(pAC, IoC, &pRPort->DownTxTimer);
2463
2464 if (pRPort->PortState != SK_RLMT_PS_LINK_DOWN) {
2465 pRPort->PortState = SK_RLMT_PS_DOWN;
2466 }
2467
2468 if (!pRPort->PortDown) {
2469 pRPort->Net->PortsUp--;
2470 pRPort->PortDown = SK_TRUE;
2471 SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_PORT_DOWN, Para);
2472 }
2473
2474 pRPort->PacketsPerTimeSlot = 0;
2475 /* pRPort->DataPacketsPerTimeSlot = 0; */
2476 pRPort->BpduPacketsPerTimeSlot = 0;
2477 pRPort->BcTimeStamp = 0;
2478
2479 /*
2480 * RA;:;: To be checked:
2481 * - actions at RLMT_STOP: We should not switch anymore.
2482 */
2483 if (pRPort->Net->RlmtState != SK_RLMT_RS_INIT) {
2484 if (Para.Para32[0] ==
2485 pRPort->Net->Port[pRPort->Net->ActivePort]->PortNumber) {
2486 /* Active Port went down. */
2487 SkRlmtCheckSwitch(pAC, IoC, pRPort->Net->NetNumber);
2488 }
2489 }
2490
2491 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2492 ("SK_RLMT_PORTDOWN* Event (%d) END.\n", Event))
2493} /* SkRlmtEvtPortDownX */
2494
2495
2496/******************************************************************************
2497 *
2498 * SkRlmtEvtLinkDown - LINK_DOWN
2499 *
2500 * Description:
2501 * This routine handles LINK_DOWN events.
2502 *
2503 * Context:
2504 * runtime, pageable?
2505 * may be called after SK_INIT_IO
2506 *
2507 * Returns:
2508 * Nothing
2509 */
2510RLMT_STATIC void SkRlmtEvtLinkDown(
2511SK_AC *pAC, /* Adapter Context */
2512SK_IOC IoC, /* I/O Context */
2513SK_EVPARA Para) /* SK_U32 PortNumber; SK_U32 Undefined */
2514{
2515 SK_RLMT_PORT *pRPort;
2516
2517 pRPort = &pAC->Rlmt.Port[Para.Para32[0]];
2518 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2519 ("SK_RLMT_LINK_DOWN Port %d Event BEGIN.\n", Para.Para32[0]))
2520
2521 if (!pAC->Rlmt.Port[Para.Para32[0]].LinkDown) {
2522 pRPort->Net->LinksUp--;
2523 pRPort->LinkDown = SK_TRUE;
2524 pRPort->PortState = SK_RLMT_PS_LINK_DOWN;
2525 SK_HWAC_LINK_LED(pAC, IoC, Para.Para32[0], SK_LED_OFF);
2526
2527 if ((pRPort->Net->RlmtMode & SK_RLMT_CHECK_LOC_LINK) != 0) {
2528 /* Build the check chain. */
2529 SkRlmtBuildCheckChain(pAC, pRPort->Net->NetNumber);
2530 }
2531
2532 /* Ensure that port is marked down. */
2533 Para.Para32[1] = -1;
2534 (void)SkRlmtEvent(pAC, IoC, SK_RLMT_PORTDOWN, Para);
2535 }
2536
2537 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2538 ("SK_RLMT_LINK_DOWN Event END.\n"))
2539} /* SkRlmtEvtLinkDown */
2540
2541
2542/******************************************************************************
2543 *
2544 * SkRlmtEvtPortAddr - PORT_ADDR
2545 *
2546 * Description:
2547 * This routine handles PORT_ADDR events.
2548 *
2549 * Context:
2550 * runtime, pageable?
2551 * may be called after SK_INIT_IO
2552 *
2553 * Returns:
2554 * Nothing
2555 */
2556RLMT_STATIC void SkRlmtEvtPortAddr(
2557SK_AC *pAC, /* Adapter Context */
2558SK_IOC IoC, /* I/O Context */
2559SK_EVPARA Para) /* SK_U32 PortNumber; SK_U32 -1 */
2560{
2561 SK_U32 i, j;
2562 SK_RLMT_PORT *pRPort;
2563 SK_MAC_ADDR *pOldMacAddr;
2564 SK_MAC_ADDR *pNewMacAddr;
2565
2566 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2567 ("SK_RLMT_PORT_ADDR Port %d Event BEGIN.\n", Para.Para32[0]))
2568
2569 if (Para.Para32[1] != (SK_U32)-1) {
2570 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2571 ("Bad Parameter.\n"))
2572 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2573 ("SK_RLMT_PORT_ADDR Event EMPTY.\n"))
2574 return;
2575 }
2576
2577 /* Port's physical MAC address changed. */
2578 pOldMacAddr = &pAC->Addr.Port[Para.Para32[0]].PreviousMacAddress;
2579 pNewMacAddr = &pAC->Addr.Port[Para.Para32[0]].CurrentMacAddress;
2580
2581 /*
2582 * NOTE: This is not scalable for solutions where ports are
2583 * checked remotely. There, we need to send an RLMT
2584 * address change packet - and how do we ensure delivery?
2585 */
2586 for (i = 0; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
2587 pRPort = &pAC->Rlmt.Port[i];
2588 for (j = 0; j < pRPort->PortsChecked; j++) {
2589 if (SK_ADDR_EQUAL(
2590 pRPort->PortCheck[j].CheckAddr.a, pOldMacAddr->a)) {
2591 pRPort->PortCheck[j].CheckAddr = *pNewMacAddr;
2592 }
2593 }
2594 }
2595
2596 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2597 ("SK_RLMT_PORT_ADDR Event END.\n"))
2598} /* SkRlmtEvtPortAddr */
2599
2600
2601/******************************************************************************
2602 *
2603 * SkRlmtEvtStart - START
2604 *
2605 * Description:
2606 * This routine handles START events.
2607 *
2608 * Context:
2609 * runtime, pageable?
2610 * may be called after SK_INIT_IO
2611 *
2612 * Returns:
2613 * Nothing
2614 */
2615RLMT_STATIC void SkRlmtEvtStart(
2616SK_AC *pAC, /* Adapter Context */
2617SK_IOC IoC, /* I/O Context */
2618SK_EVPARA Para) /* SK_U32 NetNumber; SK_U32 -1 */
2619{
2620 SK_EVPARA Para2;
2621 SK_U32 PortIdx;
2622 SK_U32 PortNumber;
2623
2624 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2625 ("SK_RLMT_START Net %d Event BEGIN.\n", Para.Para32[0]))
2626
2627 if (Para.Para32[1] != (SK_U32)-1) {
2628 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2629 ("Bad Parameter.\n"))
2630 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2631 ("SK_RLMT_START Event EMPTY.\n"))
2632 return;
2633 }
2634
2635 if (Para.Para32[0] >= pAC->Rlmt.NumNets) {
2636 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2637 ("Bad NetNumber %d.\n", Para.Para32[0]))
2638 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2639 ("SK_RLMT_START Event EMPTY.\n"))
2640 return;
2641 }
2642
2643 if (pAC->Rlmt.Net[Para.Para32[0]].RlmtState != SK_RLMT_RS_INIT) {
2644 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2645 ("SK_RLMT_START Event EMPTY.\n"))
2646 return;
2647 }
2648
2649 if (pAC->Rlmt.NetsStarted >= pAC->Rlmt.NumNets) {
2650 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2651 ("All nets should have been started.\n"))
2652 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2653 ("SK_RLMT_START Event EMPTY.\n"))
2654 return;
2655 }
2656
2657 if (pAC->Rlmt.Net[Para.Para32[0]].PrefPort >=
2658 pAC->Rlmt.Net[Para.Para32[0]].NumPorts) {
2659 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_RLMT_E009, SKERR_RLMT_E009_MSG);
2660
2661 /* Change PrefPort to internal default. */
2662 Para2.Para32[0] = 0xFFFFFFFF;
2663 Para2.Para32[1] = Para.Para32[0];
2664 (void)SkRlmtEvent(pAC, IoC, SK_RLMT_PREFPORT_CHANGE, Para2);
2665 }
2666
2667 PortIdx = pAC->Rlmt.Net[Para.Para32[0]].PrefPort;
2668 PortNumber = pAC->Rlmt.Net[Para.Para32[0]].Port[PortIdx]->PortNumber;
2669
2670 pAC->Rlmt.Net[Para.Para32[0]].LinksUp = 0;
2671 pAC->Rlmt.Net[Para.Para32[0]].PortsUp = 0;
2672 pAC->Rlmt.Net[Para.Para32[0]].CheckingState = 0;
2673 pAC->Rlmt.Net[Para.Para32[0]].RlmtState = SK_RLMT_RS_NET_DOWN;
2674
2675 /* Start preferred port. */
2676 SkRlmtPortStart(pAC, IoC, PortNumber);
2677
2678 /* Start Timer (for first port only). */
2679 Para2.Para32[0] = PortNumber;
2680 Para2.Para32[1] = (SK_U32)-1;
2681 SkTimerStart(pAC, IoC, &pAC->Rlmt.Port[PortNumber].UpTimer,
2682 SK_RLMT_PORTSTART_TIM_VAL, SKGE_RLMT, SK_RLMT_PORTSTART_TIM, Para2);
2683
2684 pAC->Rlmt.NetsStarted++;
2685
2686 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2687 ("SK_RLMT_START Event END.\n"))
2688} /* SkRlmtEvtStart */
2689
2690
2691/******************************************************************************
2692 *
2693 * SkRlmtEvtStop - STOP
2694 *
2695 * Description:
2696 * This routine handles STOP events.
2697 *
2698 * Context:
2699 * runtime, pageable?
2700 * may be called after SK_INIT_IO
2701 *
2702 * Returns:
2703 * Nothing
2704 */
2705RLMT_STATIC void SkRlmtEvtStop(
2706SK_AC *pAC, /* Adapter Context */
2707SK_IOC IoC, /* I/O Context */
2708SK_EVPARA Para) /* SK_U32 NetNumber; SK_U32 -1 */
2709{
2710 SK_EVPARA Para2;
2711 SK_U32 PortNumber;
2712 SK_U32 i;
2713
2714 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2715 ("SK_RLMT_STOP Net %d Event BEGIN.\n", Para.Para32[0]))
2716
2717 if (Para.Para32[1] != (SK_U32)-1) {
2718 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2719 ("Bad Parameter.\n"))
2720 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2721 ("SK_RLMT_STOP Event EMPTY.\n"))
2722 return;
2723 }
2724
2725 if (Para.Para32[0] >= pAC->Rlmt.NumNets) {
2726 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2727 ("Bad NetNumber %d.\n", Para.Para32[0]))
2728 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2729 ("SK_RLMT_STOP Event EMPTY.\n"))
2730 return;
2731 }
2732
2733 if (pAC->Rlmt.Net[Para.Para32[0]].RlmtState == SK_RLMT_RS_INIT) {
2734 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2735 ("SK_RLMT_STOP Event EMPTY.\n"))
2736 return;
2737 }
2738
2739 if (pAC->Rlmt.NetsStarted == 0) {
2740 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2741 ("All nets are stopped.\n"))
2742 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2743 ("SK_RLMT_STOP Event EMPTY.\n"))
2744 return;
2745 }
2746
2747 /* Stop RLMT timers. */
2748 SkTimerStop(pAC, IoC, &pAC->Rlmt.Net[Para.Para32[0]].LocTimer);
2749 SkTimerStop(pAC, IoC, &pAC->Rlmt.Net[Para.Para32[0]].SegTimer);
2750
2751 /* Stop net. */
2752 pAC->Rlmt.Net[Para.Para32[0]].RlmtState = SK_RLMT_RS_INIT;
2753 pAC->Rlmt.Net[Para.Para32[0]].RootIdSet = SK_FALSE;
2754 Para2.Para32[0] = SK_RLMT_NET_DOWN_FINAL;
2755 Para2.Para32[1] = Para.Para32[0]; /* Net# */
2756 SkEventQueue(pAC, SKGE_DRV, SK_DRV_NET_DOWN, Para2);
2757
2758 /* Stop ports. */
2759 for (i = 0; i < pAC->Rlmt.Net[Para.Para32[0]].NumPorts; i++) {
2760 PortNumber = pAC->Rlmt.Net[Para.Para32[0]].Port[i]->PortNumber;
2761 if (pAC->Rlmt.Port[PortNumber].PortState != SK_RLMT_PS_INIT) {
2762 SkTimerStop(pAC, IoC, &pAC->Rlmt.Port[PortNumber].UpTimer);
2763 SkTimerStop(pAC, IoC, &pAC->Rlmt.Port[PortNumber].DownRxTimer);
2764 SkTimerStop(pAC, IoC, &pAC->Rlmt.Port[PortNumber].DownTxTimer);
2765
2766 pAC->Rlmt.Port[PortNumber].PortState = SK_RLMT_PS_INIT;
2767 pAC->Rlmt.Port[PortNumber].RootIdSet = SK_FALSE;
2768 pAC->Rlmt.Port[PortNumber].PortStarted = SK_FALSE;
2769 Para2.Para32[0] = PortNumber;
2770 Para2.Para32[1] = (SK_U32)-1;
2771 SkEventQueue(pAC, SKGE_HWAC, SK_HWEV_PORT_STOP, Para2);
2772 }
2773 }
2774
2775 pAC->Rlmt.NetsStarted--;
2776
2777 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2778 ("SK_RLMT_STOP Event END.\n"))
2779} /* SkRlmtEvtStop */
2780
2781
2782/******************************************************************************
2783 *
2784 * SkRlmtEvtTim - TIM
2785 *
2786 * Description:
2787 * This routine handles TIM events.
2788 *
2789 * Context:
2790 * runtime, pageable?
2791 * may be called after SK_INIT_IO
2792 *
2793 * Returns:
2794 * Nothing
2795 */
2796RLMT_STATIC void SkRlmtEvtTim(
2797SK_AC *pAC, /* Adapter Context */
2798SK_IOC IoC, /* I/O Context */
2799SK_EVPARA Para) /* SK_U32 NetNumber; SK_U32 -1 */
2800{
2801 SK_RLMT_PORT *pRPort;
2802 SK_U32 Timeout;
2803 SK_U32 NewTimeout;
2804 SK_U32 PortNumber;
2805 SK_U32 i;
2806
2807 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2808 ("SK_RLMT_TIM Event BEGIN.\n"))
2809
2810 if (Para.Para32[1] != (SK_U32)-1) {
2811 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2812 ("Bad Parameter.\n"))
2813 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2814 ("SK_RLMT_TIM Event EMPTY.\n"))
2815 return;
2816 }
2817
2818 if ((pAC->Rlmt.Net[Para.Para32[0]].RlmtMode & SK_RLMT_CHECK_OTHERS) == 0 ||
2819 pAC->Rlmt.Net[Para.Para32[0]].LinksUp == 0) {
2820 /* Mode changed or all links down: No more link checking. */
2821 return;
2822 }
2823
2824#if 0
2825 pAC->Rlmt.SwitchCheckCounter--;
2826 if (pAC->Rlmt.SwitchCheckCounter == 0) {
2827 pAC->Rlmt.SwitchCheckCounter;
2828 }
2829#endif /* 0 */
2830
2831 NewTimeout = SK_RLMT_DEF_TO_VAL;
2832 for (i = 0; i < pAC->Rlmt.Net[Para.Para32[0]].NumPorts; i++) {
2833 PortNumber = pAC->Rlmt.Net[Para.Para32[0]].Port[i]->PortNumber;
2834 pRPort = &pAC->Rlmt.Port[PortNumber];
2835 if (!pRPort->LinkDown) {
2836 Timeout = SkRlmtCheckPort(pAC, IoC, PortNumber);
2837 if (Timeout < NewTimeout) {
2838 NewTimeout = Timeout;
2839 }
2840
2841 /*
2842 * These counters should be set to 0 for all ports before the
2843 * first frame is sent in the next loop.
2844 */
2845 pRPort->PacketsPerTimeSlot = 0;
2846 /* pRPort->DataPacketsPerTimeSlot = 0; */
2847 pRPort->BpduPacketsPerTimeSlot = 0;
2848 }
2849 }
2850 pAC->Rlmt.Net[Para.Para32[0]].TimeoutValue = NewTimeout;
2851
2852 if (pAC->Rlmt.Net[Para.Para32[0]].LinksUp > 1) {
2853 /*
2854 * If checking remote ports, also send packets if
2855 * (LinksUp == 1) &&
2856 * this port checks at least one (remote) port.
2857 */
2858
2859 /*
2860 * Must be new loop, as SkRlmtCheckPort can request to
2861 * check segmentation when e.g. checking the last port.
2862 */
2863 for (i = 0; i < pAC->Rlmt.Net[Para.Para32[0]].NumPorts; i++) {
2864 if (!pAC->Rlmt.Net[Para.Para32[0]].Port[i]->LinkDown) {
2865 SkRlmtSend(pAC, IoC,
2866 pAC->Rlmt.Net[Para.Para32[0]].Port[i]->PortNumber);
2867 }
2868 }
2869 }
2870
2871 SkTimerStart(pAC, IoC, &pAC->Rlmt.Net[Para.Para32[0]].LocTimer,
2872 pAC->Rlmt.Net[Para.Para32[0]].TimeoutValue, SKGE_RLMT, SK_RLMT_TIM,
2873 Para);
2874
2875 if (pAC->Rlmt.Net[Para.Para32[0]].LinksUp > 1 &&
2876 (pAC->Rlmt.Net[Para.Para32[0]].RlmtMode & SK_RLMT_CHECK_SEG) &&
2877 (pAC->Rlmt.Net[Para.Para32[0]].CheckingState & SK_RLMT_RCS_START_SEG)) {
2878 SkTimerStart(pAC, IoC, &pAC->Rlmt.Net[Para.Para32[0]].SegTimer,
2879 SK_RLMT_SEG_TO_VAL, SKGE_RLMT, SK_RLMT_SEG_TIM, Para);
2880 pAC->Rlmt.Net[Para.Para32[0]].CheckingState &= ~SK_RLMT_RCS_START_SEG;
2881 pAC->Rlmt.Net[Para.Para32[0]].CheckingState |=
2882 SK_RLMT_RCS_SEG | SK_RLMT_RCS_REPORT_SEG;
2883 }
2884
2885 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2886 ("SK_RLMT_TIM Event END.\n"))
2887} /* SkRlmtEvtTim */
2888
2889
2890/******************************************************************************
2891 *
2892 * SkRlmtEvtSegTim - SEG_TIM
2893 *
2894 * Description:
2895 * This routine handles SEG_TIM events.
2896 *
2897 * Context:
2898 * runtime, pageable?
2899 * may be called after SK_INIT_IO
2900 *
2901 * Returns:
2902 * Nothing
2903 */
2904RLMT_STATIC void SkRlmtEvtSegTim(
2905SK_AC *pAC, /* Adapter Context */
2906SK_IOC IoC, /* I/O Context */
2907SK_EVPARA Para) /* SK_U32 NetNumber; SK_U32 -1 */
2908{
2909#ifdef xDEBUG
2910 int j;
2911#endif /* DEBUG */
2912
2913 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2914 ("SK_RLMT_SEG_TIM Event BEGIN.\n"))
2915
2916 if (Para.Para32[1] != (SK_U32)-1) {
2917 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2918 ("Bad Parameter.\n"))
2919 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2920 ("SK_RLMT_SEG_TIM Event EMPTY.\n"))
2921 return;
2922 }
2923
2924#ifdef xDEBUG
2925 for (j = 0; j < pAC->Rlmt.Net[Para.Para32[0]].NumPorts; j++) {
2926 SK_ADDR_PORT *pAPort;
2927 SK_U32 k;
2928 SK_U16 *InAddr;
2929 SK_U8 InAddr8[6];
2930
2931 InAddr = (SK_U16 *)&InAddr8[0];
2932 pAPort = pAC->Rlmt.Net[Para.Para32[0]].Port[j]->AddrPort;
2933 for (k = 0; k < pAPort->NextExactMatchRlmt; k++) {
2934 /* Get exact match address k from port j. */
2935 XM_INADDR(IoC, pAC->Rlmt.Net[Para.Para32[0]].Port[j]->PortNumber,
2936 XM_EXM(k), InAddr);
2937 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2938 ("MC address %d on Port %u: %02x %02x %02x %02x %02x %02x -- %02x %02x %02x %02x %02x %02x.\n",
2939 k, pAC->Rlmt.Net[Para.Para32[0]].Port[j]->PortNumber,
2940 InAddr8[0], InAddr8[1], InAddr8[2],
2941 InAddr8[3], InAddr8[4], InAddr8[5],
2942 pAPort->Exact[k].a[0], pAPort->Exact[k].a[1],
2943 pAPort->Exact[k].a[2], pAPort->Exact[k].a[3],
2944 pAPort->Exact[k].a[4], pAPort->Exact[k].a[5]))
2945 }
2946 }
2947#endif /* xDEBUG */
wdenk42d1f032003-10-15 23:53:47 +00002948
wdenk7152b1d2003-09-05 23:19:14 +00002949 SkRlmtCheckSeg(pAC, IoC, Para.Para32[0]);
2950
2951 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2952 ("SK_RLMT_SEG_TIM Event END.\n"))
2953} /* SkRlmtEvtSegTim */
2954
2955
2956/******************************************************************************
2957 *
2958 * SkRlmtEvtPacketRx - PACKET_RECEIVED
2959 *
2960 * Description:
2961 * This routine handles PACKET_RECEIVED events.
2962 *
2963 * Context:
2964 * runtime, pageable?
2965 * may be called after SK_INIT_IO
2966 *
2967 * Returns:
2968 * Nothing
2969 */
2970RLMT_STATIC void SkRlmtEvtPacketRx(
2971SK_AC *pAC, /* Adapter Context */
2972SK_IOC IoC, /* I/O Context */
2973SK_EVPARA Para) /* SK_MBUF *pMb */
2974{
2975 SK_MBUF *pMb;
2976 SK_MBUF *pNextMb;
2977 SK_U32 NetNumber;
2978
wdenk42d1f032003-10-15 23:53:47 +00002979
wdenk7152b1d2003-09-05 23:19:14 +00002980 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2981 ("SK_RLMT_PACKET_RECEIVED Event BEGIN.\n"))
2982
2983 /* Should we ignore frames during port switching? */
2984
2985#ifdef DEBUG
2986 pMb = Para.pParaPtr;
2987 if (pMb == NULL) {
2988 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL, ("No mbuf.\n"))
2989 }
2990 else if (pMb->pNext != NULL) {
2991 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2992 ("More than one mbuf or pMb->pNext not set.\n"))
2993 }
2994#endif /* DEBUG */
2995
2996 for (pMb = Para.pParaPtr; pMb != NULL; pMb = pNextMb) {
2997 pNextMb = pMb->pNext;
2998 pMb->pNext = NULL;
2999
3000 NetNumber = pAC->Rlmt.Port[pMb->PortIdx].Net->NetNumber;
3001 if (pAC->Rlmt.Net[NetNumber].RlmtState == SK_RLMT_RS_INIT) {
3002 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
3003 }
3004 else {
3005 SkRlmtPacketReceive(pAC, IoC, pMb);
3006 }
3007 }
3008
3009 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3010 ("SK_RLMT_PACKET_RECEIVED Event END.\n"))
3011} /* SkRlmtEvtPacketRx */
3012
3013
3014/******************************************************************************
3015 *
3016 * SkRlmtEvtStatsClear - STATS_CLEAR
3017 *
3018 * Description:
3019 * This routine handles STATS_CLEAR events.
3020 *
3021 * Context:
3022 * runtime, pageable?
3023 * may be called after SK_INIT_IO
3024 *
3025 * Returns:
3026 * Nothing
3027 */
3028RLMT_STATIC void SkRlmtEvtStatsClear(
3029SK_AC *pAC, /* Adapter Context */
3030SK_IOC IoC, /* I/O Context */
3031SK_EVPARA Para) /* SK_U32 NetNumber; SK_U32 -1 */
3032{
3033 SK_U32 i;
3034 SK_RLMT_PORT *pRPort;
3035
3036 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3037 ("SK_RLMT_STATS_CLEAR Event BEGIN.\n"))
3038
3039 if (Para.Para32[1] != (SK_U32)-1) {
3040 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3041 ("Bad Parameter.\n"))
3042 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3043 ("SK_RLMT_STATS_CLEAR Event EMPTY.\n"))
3044 return;
3045 }
3046
3047 if (Para.Para32[0] >= pAC->Rlmt.NumNets) {
3048 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3049 ("Bad NetNumber %d.\n", Para.Para32[0]))
3050 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3051 ("SK_RLMT_STATS_CLEAR Event EMPTY.\n"))
3052 return;
3053 }
3054
3055 /* Clear statistics for logical and physical ports. */
3056 for (i = 0; i < pAC->Rlmt.Net[Para.Para32[0]].NumPorts; i++) {
3057 pRPort =
3058 &pAC->Rlmt.Port[pAC->Rlmt.Net[Para.Para32[0]].Port[i]->PortNumber];
3059 pRPort->TxHelloCts = 0;
3060 pRPort->RxHelloCts = 0;
3061 pRPort->TxSpHelloReqCts = 0;
3062 pRPort->RxSpHelloCts = 0;
3063 }
3064
3065 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3066 ("SK_RLMT_STATS_CLEAR Event END.\n"))
3067} /* SkRlmtEvtStatsClear */
3068
3069
3070/******************************************************************************
3071 *
3072 * SkRlmtEvtStatsUpdate - STATS_UPDATE
3073 *
3074 * Description:
3075 * This routine handles STATS_UPDATE events.
3076 *
3077 * Context:
3078 * runtime, pageable?
3079 * may be called after SK_INIT_IO
3080 *
3081 * Returns:
3082 * Nothing
3083 */
3084RLMT_STATIC void SkRlmtEvtStatsUpdate(
3085SK_AC *pAC, /* Adapter Context */
3086SK_IOC IoC, /* I/O Context */
3087SK_EVPARA Para) /* SK_U32 NetNumber; SK_U32 -1 */
3088{
3089 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3090 ("SK_RLMT_STATS_UPDATE Event BEGIN.\n"))
3091
3092 if (Para.Para32[1] != (SK_U32)-1) {
3093 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3094 ("Bad Parameter.\n"))
3095 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3096 ("SK_RLMT_STATS_UPDATE Event EMPTY.\n"))
3097 return;
3098 }
3099
3100 if (Para.Para32[0] >= pAC->Rlmt.NumNets) {
3101 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3102 ("Bad NetNumber %d.\n", Para.Para32[0]))
3103 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3104 ("SK_RLMT_STATS_UPDATE Event EMPTY.\n"))
3105 return;
3106 }
3107
3108 /* Update statistics - currently always up-to-date. */
3109
3110 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3111 ("SK_RLMT_STATS_UPDATE Event END.\n"))
3112} /* SkRlmtEvtStatsUpdate */
3113
3114
3115/******************************************************************************
3116 *
3117 * SkRlmtEvtPrefportChange - PREFPORT_CHANGE
3118 *
3119 * Description:
3120 * This routine handles PREFPORT_CHANGE events.
3121 *
3122 * Context:
3123 * runtime, pageable?
3124 * may be called after SK_INIT_IO
3125 *
3126 * Returns:
3127 * Nothing
3128 */
3129RLMT_STATIC void SkRlmtEvtPrefportChange(
3130SK_AC *pAC, /* Adapter Context */
3131SK_IOC IoC, /* I/O Context */
3132SK_EVPARA Para) /* SK_U32 PortIndex; SK_U32 NetNumber */
3133{
3134 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3135 ("SK_RLMT_PREFPORT_CHANGE to Port %d Event BEGIN.\n", Para.Para32[0]))
3136
3137 if (Para.Para32[1] >= pAC->Rlmt.NumNets) {
3138 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3139 ("Bad NetNumber %d.\n", Para.Para32[1]))
3140 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3141 ("SK_RLMT_PREFPORT_CHANGE Event EMPTY.\n"))
3142 return;
3143 }
3144
3145 /* 0xFFFFFFFF == auto-mode. */
3146 if (Para.Para32[0] == 0xFFFFFFFF) {
3147 pAC->Rlmt.Net[Para.Para32[1]].PrefPort = SK_RLMT_DEF_PREF_PORT;
3148 }
3149 else {
3150 if (Para.Para32[0] >= pAC->Rlmt.Net[Para.Para32[1]].NumPorts) {
3151 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_RLMT_E010, SKERR_RLMT_E010_MSG);
3152
3153 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3154 ("SK_RLMT_PREFPORT_CHANGE Event EMPTY.\n"))
3155 return;
3156 }
3157
3158 pAC->Rlmt.Net[Para.Para32[1]].PrefPort = Para.Para32[0];
3159 }
3160
3161 pAC->Rlmt.Net[Para.Para32[1]].Preference = Para.Para32[0];
3162
3163 if (pAC->Rlmt.Net[Para.Para32[1]].RlmtState != SK_RLMT_RS_INIT) {
3164 SkRlmtCheckSwitch(pAC, IoC, Para.Para32[1]);
3165 }
3166
3167 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3168 ("SK_RLMT_PREFPORT_CHANGE Event END.\n"))
3169} /* SkRlmtEvtPrefportChange */
3170
3171
3172/******************************************************************************
3173 *
3174 * SkRlmtEvtSetNets - SET_NETS
3175 *
3176 * Description:
3177 * This routine handles SET_NETS events.
3178 *
3179 * Context:
3180 * runtime, pageable?
3181 * may be called after SK_INIT_IO
3182 *
3183 * Returns:
3184 * Nothing
3185 */
3186RLMT_STATIC void SkRlmtEvtSetNets(
3187SK_AC *pAC, /* Adapter Context */
3188SK_IOC IoC, /* I/O Context */
3189SK_EVPARA Para) /* SK_U32 NumNets; SK_U32 -1 */
3190{
3191 int i;
3192
3193 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3194 ("SK_RLMT_SET_NETS Event BEGIN.\n"))
3195
3196 if (Para.Para32[1] != (SK_U32)-1) {
3197 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3198 ("Bad Parameter.\n"))
3199 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3200 ("SK_RLMT_SET_NETS Event EMPTY.\n"))
3201 return;
3202 }
3203
3204 if (Para.Para32[0] == 0 || Para.Para32[0] > SK_MAX_NETS ||
3205 Para.Para32[0] > (SK_U32)pAC->GIni.GIMacsFound) {
3206 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3207 ("Bad number of nets: %d.\n", Para.Para32[0]))
3208 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3209 ("SK_RLMT_SET_NETS Event EMPTY.\n"))
3210 return;
3211 }
3212
3213 if (Para.Para32[0] == pAC->Rlmt.NumNets) { /* No change. */
3214 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3215 ("SK_RLMT_SET_NETS Event EMPTY.\n"))
3216 return;
3217 }
3218
3219 /* Entering and leaving dual mode only allowed while nets are stopped. */
3220 if (pAC->Rlmt.NetsStarted > 0) {
3221 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3222 ("Changing dual mode only allowed while all nets are stopped.\n"))
3223 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3224 ("SK_RLMT_SET_NETS Event EMPTY.\n"))
3225 return;
3226 }
3227
3228 if (Para.Para32[0] == 1) {
3229 if (pAC->Rlmt.NumNets > 1) {
3230 /* Clear logical MAC addr from second net's active port. */
3231 (void)SkAddrOverride(pAC, IoC, pAC->Rlmt.Net[1].Port[pAC->Addr.
3232 Net[1].ActivePort]->PortNumber, NULL, SK_ADDR_CLEAR_LOGICAL);
3233 pAC->Rlmt.Net[1].NumPorts = 0;
3234 }
3235
3236 pAC->Rlmt.NumNets = Para.Para32[0];
3237 for (i = 0; (SK_U32)i < pAC->Rlmt.NumNets; i++) {
3238 pAC->Rlmt.Net[i].RlmtState = SK_RLMT_RS_INIT;
3239 pAC->Rlmt.Net[i].RootIdSet = SK_FALSE;
3240 pAC->Rlmt.Net[i].Preference = 0xFFFFFFFF; /* "Automatic" */
3241 pAC->Rlmt.Net[i].PrefPort = SK_RLMT_DEF_PREF_PORT;
3242 /* Just assuming. */
3243 pAC->Rlmt.Net[i].ActivePort = pAC->Rlmt.Net[i].PrefPort;
3244 pAC->Rlmt.Net[i].RlmtMode = SK_RLMT_DEF_MODE;
3245 pAC->Rlmt.Net[i].TimeoutValue = SK_RLMT_DEF_TO_VAL;
3246 pAC->Rlmt.Net[i].NetNumber = i;
3247 }
3248
3249 pAC->Rlmt.Port[1].Net= &pAC->Rlmt.Net[0];
3250 pAC->Rlmt.Net[0].NumPorts = pAC->GIni.GIMacsFound;
3251
3252 SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_SET_NETS, Para);
3253
3254 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3255 ("RLMT: Changed to one net with two ports.\n"))
3256 }
3257 else if (Para.Para32[0] == 2) {
3258 pAC->Rlmt.Port[1].Net= &pAC->Rlmt.Net[1];
3259 pAC->Rlmt.Net[1].NumPorts = pAC->GIni.GIMacsFound - 1;
3260 pAC->Rlmt.Net[0].NumPorts =
3261 pAC->GIni.GIMacsFound - pAC->Rlmt.Net[1].NumPorts;
wdenk42d1f032003-10-15 23:53:47 +00003262
wdenk7152b1d2003-09-05 23:19:14 +00003263 pAC->Rlmt.NumNets = Para.Para32[0];
3264 for (i = 0; (SK_U32)i < pAC->Rlmt.NumNets; i++) {
3265 pAC->Rlmt.Net[i].RlmtState = SK_RLMT_RS_INIT;
3266 pAC->Rlmt.Net[i].RootIdSet = SK_FALSE;
3267 pAC->Rlmt.Net[i].Preference = 0xFFFFFFFF; /* "Automatic" */
3268 pAC->Rlmt.Net[i].PrefPort = SK_RLMT_DEF_PREF_PORT;
3269 /* Just assuming. */
3270 pAC->Rlmt.Net[i].ActivePort = pAC->Rlmt.Net[i].PrefPort;
3271 pAC->Rlmt.Net[i].RlmtMode = SK_RLMT_DEF_MODE;
3272 pAC->Rlmt.Net[i].TimeoutValue = SK_RLMT_DEF_TO_VAL;
3273
3274 pAC->Rlmt.Net[i].NetNumber = i;
3275 }
3276
3277 /* Set logical MAC addr on second net's active port. */
3278 (void)SkAddrOverride(pAC, IoC, pAC->Rlmt.Net[1].Port[pAC->Addr.
3279 Net[1].ActivePort]->PortNumber, NULL, SK_ADDR_SET_LOGICAL);
3280
3281 SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_SET_NETS, Para);
3282
3283 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3284 ("RLMT: Changed to two nets with one port each.\n"))
3285 }
3286 else {
3287 /* Not implemented for more than two nets. */
3288 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3289 ("SetNets not implemented for more than two nets.\n"))
3290 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3291 ("SK_RLMT_SET_NETS Event EMPTY.\n"))
3292 return;
3293 }
3294
3295 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3296 ("SK_RLMT_SET_NETS Event END.\n"))
3297} /* SkRlmtSetNets */
3298
3299
3300/******************************************************************************
3301 *
3302 * SkRlmtEvtModeChange - MODE_CHANGE
3303 *
3304 * Description:
3305 * This routine handles MODE_CHANGE events.
3306 *
3307 * Context:
3308 * runtime, pageable?
3309 * may be called after SK_INIT_IO
3310 *
3311 * Returns:
3312 * Nothing
3313 */
3314RLMT_STATIC void SkRlmtEvtModeChange(
3315SK_AC *pAC, /* Adapter Context */
3316SK_IOC IoC, /* I/O Context */
3317SK_EVPARA Para) /* SK_U32 NewMode; SK_U32 NetNumber */
3318{
3319 SK_EVPARA Para2;
3320 SK_U32 i;
3321 SK_U32 PrevRlmtMode;
3322
3323 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3324 ("SK_RLMT_MODE_CHANGE Event BEGIN.\n"))
3325
3326 if (Para.Para32[1] >= pAC->Rlmt.NumNets) {
3327 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3328 ("Bad NetNumber %d.\n", Para.Para32[1]))
3329 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3330 ("SK_RLMT_MODE_CHANGE Event EMPTY.\n"))
3331 return;
3332 }
3333
3334 Para.Para32[0] |= SK_RLMT_CHECK_LINK;
3335
3336 if ((pAC->Rlmt.Net[Para.Para32[1]].NumPorts == 1) &&
3337 Para.Para32[0] != SK_RLMT_MODE_CLS) {
3338 pAC->Rlmt.Net[Para.Para32[1]].RlmtMode = SK_RLMT_MODE_CLS;
3339 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3340 ("Forced RLMT mode to CLS on single port net.\n"))
3341 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3342 ("SK_RLMT_MODE_CHANGE Event EMPTY.\n"))
3343 return;
3344 }
3345
3346 /* Update RLMT mode. */
3347 PrevRlmtMode = pAC->Rlmt.Net[Para.Para32[1]].RlmtMode;
3348 pAC->Rlmt.Net[Para.Para32[1]].RlmtMode = Para.Para32[0];
3349
3350 if ((PrevRlmtMode & SK_RLMT_CHECK_LOC_LINK) !=
3351 (pAC->Rlmt.Net[Para.Para32[1]].RlmtMode & SK_RLMT_CHECK_LOC_LINK)) {
3352 /* SK_RLMT_CHECK_LOC_LINK bit changed. */
3353 if ((PrevRlmtMode & SK_RLMT_CHECK_OTHERS) == 0 &&
3354 pAC->Rlmt.Net[Para.Para32[1]].NumPorts > 1 &&
3355 pAC->Rlmt.Net[Para.Para32[1]].PortsUp >= 1) {
3356 /* 20001207 RA: Was "PortsUp == 1". */
3357 Para2.Para32[0] = Para.Para32[1];
3358 Para2.Para32[1] = (SK_U32)-1;
3359 SkTimerStart(pAC, IoC, &pAC->Rlmt.Net[Para.Para32[1]].LocTimer,
3360 pAC->Rlmt.Net[Para.Para32[1]].TimeoutValue,
3361 SKGE_RLMT, SK_RLMT_TIM, Para2);
3362 }
3363 }
3364
3365 if ((PrevRlmtMode & SK_RLMT_CHECK_SEG) !=
3366 (pAC->Rlmt.Net[Para.Para32[1]].RlmtMode & SK_RLMT_CHECK_SEG)) {
3367 /* SK_RLMT_CHECK_SEG bit changed. */
3368 for (i = 0; i < pAC->Rlmt.Net[Para.Para32[1]].NumPorts; i++) {
3369 (void)SkAddrMcClear(pAC, IoC,
3370 pAC->Rlmt.Net[Para.Para32[1]].Port[i]->PortNumber,
3371 SK_ADDR_PERMANENT | SK_MC_SW_ONLY);
3372
3373 /* Add RLMT MC address. */
3374 (void)SkAddrMcAdd(pAC, IoC,
3375 pAC->Rlmt.Net[Para.Para32[1]].Port[i]->PortNumber,
3376 &SkRlmtMcAddr, SK_ADDR_PERMANENT);
3377
3378 if ((pAC->Rlmt.Net[Para.Para32[1]].RlmtMode &
3379 SK_RLMT_CHECK_SEG) != 0) {
3380 /* Add BPDU MC address. */
3381 (void)SkAddrMcAdd(pAC, IoC,
3382 pAC->Rlmt.Net[Para.Para32[1]].Port[i]->PortNumber,
3383 &BridgeMcAddr, SK_ADDR_PERMANENT);
3384
3385 if (pAC->Rlmt.Net[Para.Para32[1]].RlmtState != SK_RLMT_RS_INIT) {
3386 if (!pAC->Rlmt.Net[Para.Para32[1]].Port[i]->LinkDown &&
3387 (Para2.pParaPtr = SkRlmtBuildSpanningTreePacket(
3388 pAC, IoC, i)) != NULL) {
3389 pAC->Rlmt.Net[Para.Para32[1]].Port[i]->RootIdSet =
3390 SK_FALSE;
3391 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para2);
3392 }
3393 }
3394 }
3395 (void)SkAddrMcUpdate(pAC, IoC,
3396 pAC->Rlmt.Net[Para.Para32[1]].Port[i]->PortNumber);
3397 } /* for ... */
3398
3399 if ((pAC->Rlmt.Net[Para.Para32[1]].RlmtMode & SK_RLMT_CHECK_SEG) != 0) {
3400 Para2.Para32[0] = Para.Para32[1];
3401 Para2.Para32[1] = (SK_U32)-1;
3402 SkTimerStart(pAC, IoC, &pAC->Rlmt.Net[Para.Para32[1]].SegTimer,
3403 SK_RLMT_SEG_TO_VAL, SKGE_RLMT, SK_RLMT_SEG_TIM, Para2);
3404 }
3405 } /* SK_RLMT_CHECK_SEG bit changed. */
3406
3407 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3408 ("SK_RLMT_MODE_CHANGE Event END.\n"))
3409} /* SkRlmtEvtModeChange */
3410
3411
3412/******************************************************************************
3413 *
3414 * SkRlmtEvent - a PORT- or an RLMT-specific event happened
3415 *
3416 * Description:
3417 * This routine calls subroutines to handle PORT- and RLMT-specific events.
3418 *
3419 * Context:
3420 * runtime, pageable?
3421 * may be called after SK_INIT_IO
3422 *
3423 * Returns:
3424 * 0
3425 */
3426int SkRlmtEvent(
3427SK_AC *pAC, /* Adapter Context */
3428SK_IOC IoC, /* I/O Context */
3429SK_U32 Event, /* Event code */
3430SK_EVPARA Para) /* Event-specific parameter */
3431{
3432 switch (Event) {
wdenk42d1f032003-10-15 23:53:47 +00003433
wdenk7152b1d2003-09-05 23:19:14 +00003434 /* ----- PORT events ----- */
3435
3436 case SK_RLMT_PORTSTART_TIM: /* From RLMT via TIME. */
3437 SkRlmtEvtPortStartTim(pAC, IoC, Para);
3438 break;
3439 case SK_RLMT_LINK_UP: /* From SIRQ. */
3440 SkRlmtEvtLinkUp(pAC, IoC, Para);
3441 break;
3442 case SK_RLMT_PORTUP_TIM: /* From RLMT via TIME. */
3443 SkRlmtEvtPortUpTim(pAC, IoC, Para);
3444 break;
3445 case SK_RLMT_PORTDOWN: /* From RLMT. */
3446 case SK_RLMT_PORTDOWN_RX_TIM: /* From RLMT via TIME. */
3447 case SK_RLMT_PORTDOWN_TX_TIM: /* From RLMT via TIME. */
3448 SkRlmtEvtPortDownX(pAC, IoC, Event, Para);
3449 break;
3450 case SK_RLMT_LINK_DOWN: /* From SIRQ. */
3451 SkRlmtEvtLinkDown(pAC, IoC, Para);
3452 break;
3453 case SK_RLMT_PORT_ADDR: /* From ADDR. */
3454 SkRlmtEvtPortAddr(pAC, IoC, Para);
3455 break;
3456
3457 /* ----- RLMT events ----- */
3458
3459 case SK_RLMT_START: /* From DRV. */
3460 SkRlmtEvtStart(pAC, IoC, Para);
3461 break;
3462 case SK_RLMT_STOP: /* From DRV. */
3463 SkRlmtEvtStop(pAC, IoC, Para);
3464 break;
3465 case SK_RLMT_TIM: /* From RLMT via TIME. */
3466 SkRlmtEvtTim(pAC, IoC, Para);
3467 break;
3468 case SK_RLMT_SEG_TIM:
3469 SkRlmtEvtSegTim(pAC, IoC, Para);
3470 break;
3471 case SK_RLMT_PACKET_RECEIVED: /* From DRV. */
3472 SkRlmtEvtPacketRx(pAC, IoC, Para);
3473 break;
3474 case SK_RLMT_STATS_CLEAR: /* From PNMI. */
3475 SkRlmtEvtStatsClear(pAC, IoC, Para);
3476 break;
3477 case SK_RLMT_STATS_UPDATE: /* From PNMI. */
3478 SkRlmtEvtStatsUpdate(pAC, IoC, Para);
3479 break;
3480 case SK_RLMT_PREFPORT_CHANGE: /* From PNMI. */
3481 SkRlmtEvtPrefportChange(pAC, IoC, Para);
3482 break;
3483 case SK_RLMT_MODE_CHANGE: /* From PNMI. */
3484 SkRlmtEvtModeChange(pAC, IoC, Para);
3485 break;
3486 case SK_RLMT_SET_NETS: /* From DRV. */
3487 SkRlmtEvtSetNets(pAC, IoC, Para);
3488 break;
3489
3490 /* ----- Unknown events ----- */
3491
3492 default: /* Create error log entry. */
3493 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3494 ("Unknown RLMT Event %d.\n", Event))
3495 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_RLMT_E003, SKERR_RLMT_E003_MSG);
3496 break;
3497 } /* switch() */
3498
3499 return (0);
3500} /* SkRlmtEvent */
3501
3502#ifdef __cplusplus
3503}
3504#endif /* __cplusplus */