blob: a178dff3ccce0bafc4e8be7cfac6683874d4b6c1 [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++) {
Wolfgang Denk2d6d9f02009-09-11 09:36:31 +0200660 SK_U64 *pRandom = &Random;
wdenk7152b1d2003-09-05 23:19:14 +0000661 Random = SkOsGetTime(pAC);
Wolfgang Denk2d6d9f02009-09-11 09:36:31 +0200662 *(SK_U32*)&pAC->Rlmt.Port[i].Random = *(SK_U32*)pRandom;
wdenk7152b1d2003-09-05 23:19:14 +0000663
664 for (j = 0; j < 4; j++) {
665 pAC->Rlmt.Port[i].Random[j] ^= pAC->Rlmt.Port[i].AddrPort->
666 CurrentMacAddress.a[SK_MAC_ADDR_LEN - 1 - j];
667 }
668
669 (void)SkAddrMcClear(pAC, IoC, i, SK_ADDR_PERMANENT | SK_MC_SW_ONLY);
wdenk42d1f032003-10-15 23:53:47 +0000670
wdenk7152b1d2003-09-05 23:19:14 +0000671 /* Add RLMT MC address. */
672 (void)SkAddrMcAdd(pAC, IoC, i, &SkRlmtMcAddr, SK_ADDR_PERMANENT);
673
674 if (pAC->Rlmt.Net[0].RlmtMode & SK_RLMT_CHECK_SEG) {
675 /* Add BPDU MC address. */
676 (void)SkAddrMcAdd(pAC, IoC, i, &BridgeMcAddr, SK_ADDR_PERMANENT);
677 }
678
679 (void)SkAddrMcUpdate(pAC, IoC, i);
680 }
681
wdenk42d1f032003-10-15 23:53:47 +0000682 VirtualMacAddressSet = SK_FALSE;
wdenk7152b1d2003-09-05 23:19:14 +0000683 /* Read virtual MAC address from Control Register File. */
684 for (j = 0; j < SK_MAC_ADDR_LEN; j++) {
wdenk42d1f032003-10-15 23:53:47 +0000685
686 SK_IN8(IoC, B2_MAC_1 + j, &VirtualMacAddress.a[j]);
687 VirtualMacAddressSet |= VirtualMacAddress.a[j];
wdenk7152b1d2003-09-05 23:19:14 +0000688 }
wdenk42d1f032003-10-15 23:53:47 +0000689
690 PhysicalAMacAddressSet = SK_FALSE;
wdenk7152b1d2003-09-05 23:19:14 +0000691 /* Read physical MAC address for MAC A from Control Register File. */
692 for (j = 0; j < SK_MAC_ADDR_LEN; j++) {
wdenk42d1f032003-10-15 23:53:47 +0000693
694 SK_IN8(IoC, B2_MAC_2 + j, &PhysicalAMacAddress.a[j]);
695 PhysicalAMacAddressSet |= PhysicalAMacAddress.a[j];
wdenk7152b1d2003-09-05 23:19:14 +0000696 }
697
wdenk42d1f032003-10-15 23:53:47 +0000698 /* check if the two mac addresses contain reasonable values */
699 if (!VirtualMacAddressSet || !PhysicalAMacAddressSet) {
wdenk7152b1d2003-09-05 23:19:14 +0000700
wdenk42d1f032003-10-15 23:53:47 +0000701 pAC->Rlmt.RlmtOff = SK_TRUE;
702 }
wdenk7152b1d2003-09-05 23:19:14 +0000703
wdenk42d1f032003-10-15 23:53:47 +0000704 /* if the two mac addresses are equal switch off the RLMT_PRE_LOOKAHEAD
705 and the RLMT_LOOKAHEAD macros */
706 else if (SK_ADDR_EQUAL(PhysicalAMacAddress.a, VirtualMacAddress.a)) {
wdenk7152b1d2003-09-05 23:19:14 +0000707
wdenk42d1f032003-10-15 23:53:47 +0000708 pAC->Rlmt.RlmtOff = SK_TRUE;
709 }
wdenk7152b1d2003-09-05 23:19:14 +0000710 else {
711 pAC->Rlmt.RlmtOff = SK_FALSE;
712 }
713 break;
714
715 default: /* error */
716 break;
717 }
718 return;
719} /* SkRlmtInit */
720
721
722/******************************************************************************
723 *
724 * SkRlmtBuildCheckChain - build the check chain
725 *
726 * Description:
727 * This routine builds the local check chain:
728 * - Each port that is up checks the next port.
729 * - The last port that is up checks the first port that is up.
730 *
731 * Notes:
732 * - Currently only local ports are considered when building the chain.
733 * - Currently the SuspectState is just reset;
734 * it would be better to save it ...
735 *
736 * Context:
737 * runtime, pageable?
738 *
739 * Returns:
740 * Nothing
741 */
742RLMT_STATIC void SkRlmtBuildCheckChain(
743SK_AC *pAC, /* Adapter Context */
744SK_U32 NetIdx) /* Net Number */
745{
746 SK_U32 i;
747 SK_U32 NumMacsUp;
748 SK_RLMT_PORT * FirstMacUp;
749 SK_RLMT_PORT * PrevMacUp;
750
751 FirstMacUp = NULL;
752 PrevMacUp = NULL;
wdenk42d1f032003-10-15 23:53:47 +0000753
wdenk7152b1d2003-09-05 23:19:14 +0000754 if (!(pAC->Rlmt.Net[NetIdx].RlmtMode & SK_RLMT_CHECK_LOC_LINK)) {
755 for (i = 0; i < pAC->Rlmt.Net[i].NumPorts; i++) {
756 pAC->Rlmt.Net[NetIdx].Port[i]->PortsChecked = 0;
757 }
758 return; /* Done. */
759 }
wdenk42d1f032003-10-15 23:53:47 +0000760
wdenk7152b1d2003-09-05 23:19:14 +0000761 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
762 ("SkRlmtBuildCheckChain.\n"))
763
764 NumMacsUp = 0;
765
766 for (i = 0; i < pAC->Rlmt.Net[NetIdx].NumPorts; i++) {
767 pAC->Rlmt.Net[NetIdx].Port[i]->PortsChecked = 0;
768 pAC->Rlmt.Net[NetIdx].Port[i]->PortsSuspect = 0;
769 pAC->Rlmt.Net[NetIdx].Port[i]->CheckingState &=
770 ~(SK_RLMT_PCS_RX | SK_RLMT_PCS_TX);
771
772 /*
773 * If more than two links are detected we should consider
774 * checking at least two other ports:
775 * 1. the next port that is not LinkDown and
776 * 2. the next port that is not PortDown.
777 */
778 if (!pAC->Rlmt.Net[NetIdx].Port[i]->LinkDown) {
779 if (NumMacsUp == 0) {
780 FirstMacUp = pAC->Rlmt.Net[NetIdx].Port[i];
781 }
782 else {
783 PrevMacUp->PortCheck[
784 pAC->Rlmt.Net[NetIdx].Port[i]->PortsChecked].CheckAddr =
785 pAC->Rlmt.Net[NetIdx].Port[i]->AddrPort->CurrentMacAddress;
786 PrevMacUp->PortCheck[
787 PrevMacUp->PortsChecked].SuspectTx = SK_FALSE;
788 PrevMacUp->PortsChecked++;
789 }
790 PrevMacUp = pAC->Rlmt.Net[NetIdx].Port[i];
791 NumMacsUp++;
792 }
793 }
794
795 if (NumMacsUp > 1) {
796 PrevMacUp->PortCheck[PrevMacUp->PortsChecked].CheckAddr =
797 FirstMacUp->AddrPort->CurrentMacAddress;
798 PrevMacUp->PortCheck[PrevMacUp->PortsChecked].SuspectTx =
799 SK_FALSE;
800 PrevMacUp->PortsChecked++;
801 }
802
803#ifdef DEBUG
804 for (i = 0; i < pAC->Rlmt.Net[NetIdx].NumPorts; i++) {
805 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
806 ("Port %d checks %d other ports: %2X.\n", i,
807 pAC->Rlmt.Net[NetIdx].Port[i]->PortsChecked,
808 pAC->Rlmt.Net[NetIdx].Port[i]->PortCheck[0].CheckAddr.a[5]))
809 }
810#endif /* DEBUG */
811
812 return;
813} /* SkRlmtBuildCheckChain */
814
815
816/******************************************************************************
817 *
818 * SkRlmtBuildPacket - build an RLMT packet
819 *
820 * Description:
821 * This routine sets up an RLMT packet.
822 *
823 * Context:
824 * runtime, pageable?
825 *
826 * Returns:
827 * NULL or pointer to RLMT mbuf
828 */
829RLMT_STATIC SK_MBUF *SkRlmtBuildPacket(
830SK_AC *pAC, /* Adapter Context */
831SK_IOC IoC, /* I/O Context */
832SK_U32 PortNumber, /* Sending port */
833SK_U16 PacketType, /* RLMT packet type */
834SK_MAC_ADDR *SrcAddr, /* Source address */
835SK_MAC_ADDR *DestAddr) /* Destination address */
836{
837 int i;
838 SK_U16 Length;
839 SK_MBUF *pMb;
840 SK_RLMT_PACKET *pPacket;
841
842#ifdef DEBUG
843 SK_U8 CheckSrc = 0;
844 SK_U8 CheckDest = 0;
wdenk42d1f032003-10-15 23:53:47 +0000845
wdenk7152b1d2003-09-05 23:19:14 +0000846 for (i = 0; i < SK_MAC_ADDR_LEN; ++i) {
847 CheckSrc |= SrcAddr->a[i];
848 CheckDest |= DestAddr->a[i];
849 }
850
851 if ((CheckSrc == 0) || (CheckDest == 0)) {
852 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_ERR,
853 ("SkRlmtBuildPacket: Invalid %s%saddr.\n",
854 (CheckSrc == 0 ? "Src" : ""), (CheckDest == 0 ? "Dest" : "")))
855 }
856#endif
857
858 if ((pMb = SkDrvAllocRlmtMbuf(pAC, IoC, SK_RLMT_MAX_PACKET_SIZE)) != NULL) {
859 pPacket = (SK_RLMT_PACKET*)pMb->pData;
860 for (i = 0; i < SK_MAC_ADDR_LEN; i++) {
861 pPacket->DstAddr[i] = DestAddr->a[i];
862 pPacket->SrcAddr[i] = SrcAddr->a[i];
863 }
864 pPacket->DSap = SK_RLMT_DSAP;
865 pPacket->SSap = SK_RLMT_SSAP;
866 pPacket->Ctrl = SK_RLMT_CTRL;
867 pPacket->Indicator[0] = SK_RLMT_INDICATOR0;
868 pPacket->Indicator[1] = SK_RLMT_INDICATOR1;
869 pPacket->Indicator[2] = SK_RLMT_INDICATOR2;
870 pPacket->Indicator[3] = SK_RLMT_INDICATOR3;
871 pPacket->Indicator[4] = SK_RLMT_INDICATOR4;
872 pPacket->Indicator[5] = SK_RLMT_INDICATOR5;
873 pPacket->Indicator[6] = SK_RLMT_INDICATOR6;
874
875 SK_U16_TO_NETWORK_ORDER(PacketType, &pPacket->RlmtPacketType[0]);
876
877 for (i = 0; i < 4; i++) {
878 pPacket->Random[i] = pAC->Rlmt.Port[PortNumber].Random[i];
879 }
wdenk42d1f032003-10-15 23:53:47 +0000880
wdenk7152b1d2003-09-05 23:19:14 +0000881 SK_U16_TO_NETWORK_ORDER(
882 SK_RLMT_PACKET_VERSION, &pPacket->RlmtPacketVersion[0]);
883
884 for (i = 0; i < SK_PACKET_DATA_LEN; i++) {
885 pPacket->Data[i] = 0x00;
886 }
887
888 Length = SK_RLMT_MAX_PACKET_SIZE; /* Or smaller. */
889 pMb->Length = Length;
890 pMb->PortIdx = PortNumber;
891 Length -= 14;
892 SK_U16_TO_NETWORK_ORDER(Length, &pPacket->TypeLen[0]);
893
894 if (PacketType == SK_PACKET_ALIVE) {
895 pAC->Rlmt.Port[PortNumber].TxHelloCts++;
896 }
897 }
898
899 return (pMb);
900} /* SkRlmtBuildPacket */
901
902
903/******************************************************************************
904 *
905 * SkRlmtBuildSpanningTreePacket - build spanning tree check packet
906 *
907 * Description:
908 * This routine sets up a BPDU packet for spanning tree check.
909 *
910 * Context:
911 * runtime, pageable?
912 *
913 * Returns:
914 * NULL or pointer to RLMT mbuf
915 */
916RLMT_STATIC SK_MBUF *SkRlmtBuildSpanningTreePacket(
917SK_AC *pAC, /* Adapter Context */
918SK_IOC IoC, /* I/O Context */
919SK_U32 PortNumber) /* Sending port */
920{
921 unsigned i;
922 SK_U16 Length;
923 SK_MBUF *pMb;
924 SK_SPTREE_PACKET *pSPacket;
925
926 if ((pMb = SkDrvAllocRlmtMbuf(pAC, IoC, SK_RLMT_MAX_PACKET_SIZE)) !=
927 NULL) {
928 pSPacket = (SK_SPTREE_PACKET*)pMb->pData;
929 for (i = 0; i < SK_MAC_ADDR_LEN; i++) {
930 pSPacket->DstAddr[i] = BridgeMcAddr.a[i];
931 pSPacket->SrcAddr[i] =
932 pAC->Addr.Port[PortNumber].CurrentMacAddress.a[i];
933 }
934 pSPacket->DSap = SK_RLMT_SPT_DSAP;
935 pSPacket->SSap = SK_RLMT_SPT_SSAP;
936 pSPacket->Ctrl = SK_RLMT_SPT_CTRL;
937
938 pSPacket->ProtocolId[0] = SK_RLMT_SPT_PROTOCOL_ID0;
939 pSPacket->ProtocolId[1] = SK_RLMT_SPT_PROTOCOL_ID1;
940 pSPacket->ProtocolVersionId = SK_RLMT_SPT_PROTOCOL_VERSION_ID;
941 pSPacket->BpduType = SK_RLMT_SPT_BPDU_TYPE;
942 pSPacket->Flags = SK_RLMT_SPT_FLAGS;
943 pSPacket->RootId[0] = SK_RLMT_SPT_ROOT_ID0;
944 pSPacket->RootId[1] = SK_RLMT_SPT_ROOT_ID1;
945 pSPacket->RootPathCost[0] = SK_RLMT_SPT_ROOT_PATH_COST0;
946 pSPacket->RootPathCost[1] = SK_RLMT_SPT_ROOT_PATH_COST1;
947 pSPacket->RootPathCost[2] = SK_RLMT_SPT_ROOT_PATH_COST2;
948 pSPacket->RootPathCost[3] = SK_RLMT_SPT_ROOT_PATH_COST3;
949 pSPacket->BridgeId[0] = SK_RLMT_SPT_BRIDGE_ID0;
950 pSPacket->BridgeId[1] = SK_RLMT_SPT_BRIDGE_ID1;
951
952 /*
953 * Use logical MAC address as bridge ID and filter these packets
954 * on receive.
955 */
956 for (i = 0; i < SK_MAC_ADDR_LEN; i++) {
957 pSPacket->BridgeId[i + 2] = pSPacket->RootId[i + 2] =
958 pAC->Addr.Net[pAC->Rlmt.Port[PortNumber].Net->NetNumber].
959 CurrentMacAddress.a[i];
960 }
961 pSPacket->PortId[0] = SK_RLMT_SPT_PORT_ID0;
962 pSPacket->PortId[1] = SK_RLMT_SPT_PORT_ID1;
963 pSPacket->MessageAge[0] = SK_RLMT_SPT_MSG_AGE0;
964 pSPacket->MessageAge[1] = SK_RLMT_SPT_MSG_AGE1;
965 pSPacket->MaxAge[0] = SK_RLMT_SPT_MAX_AGE0;
966 pSPacket->MaxAge[1] = SK_RLMT_SPT_MAX_AGE1;
967 pSPacket->HelloTime[0] = SK_RLMT_SPT_HELLO_TIME0;
968 pSPacket->HelloTime[1] = SK_RLMT_SPT_HELLO_TIME1;
969 pSPacket->ForwardDelay[0] = SK_RLMT_SPT_FWD_DELAY0;
970 pSPacket->ForwardDelay[1] = SK_RLMT_SPT_FWD_DELAY1;
971
972 Length = SK_RLMT_MAX_PACKET_SIZE; /* Or smaller. */
973 pMb->Length = Length;
974 pMb->PortIdx = PortNumber;
975 Length -= 14;
976 SK_U16_TO_NETWORK_ORDER(Length, &pSPacket->TypeLen[0]);
977
978 pAC->Rlmt.Port[PortNumber].TxSpHelloReqCts++;
979 }
980
981 return (pMb);
982} /* SkRlmtBuildSpanningTreePacket */
983
984
985/******************************************************************************
986 *
987 * SkRlmtSend - build and send check packets
988 *
989 * Description:
990 * Depending on the RLMT state and the checking state, several packets
991 * are sent through the indicated port.
992 *
993 * Context:
994 * runtime, pageable?
995 *
996 * Returns:
997 * Nothing.
998 */
999RLMT_STATIC void SkRlmtSend(
1000SK_AC *pAC, /* Adapter Context */
1001SK_IOC IoC, /* I/O Context */
1002SK_U32 PortNumber) /* Sending port */
1003{
1004 unsigned j;
1005 SK_EVPARA Para;
1006 SK_RLMT_PORT *pRPort;
1007
1008 pRPort = &pAC->Rlmt.Port[PortNumber];
1009 if (pAC->Rlmt.Port[PortNumber].Net->RlmtMode & SK_RLMT_CHECK_LOC_LINK) {
1010 if (pRPort->CheckingState & (SK_RLMT_PCS_TX | SK_RLMT_PCS_RX)) {
1011 /* Port is suspicious. Send the RLMT packet to the RLMT mc addr. */
1012 if ((Para.pParaPtr = SkRlmtBuildPacket(pAC, IoC, PortNumber,
1013 SK_PACKET_ALIVE, &pAC->Addr.Port[PortNumber].CurrentMacAddress,
1014 &SkRlmtMcAddr)) != NULL) {
1015 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para);
1016 }
1017 }
1018 else {
1019 /*
1020 * Send a directed RLMT packet to all ports that are
1021 * checked by the indicated port.
1022 */
1023 for (j = 0; j < pRPort->PortsChecked; j++) {
1024 if ((Para.pParaPtr = SkRlmtBuildPacket(pAC, IoC, PortNumber,
1025 SK_PACKET_ALIVE, &pAC->Addr.Port[PortNumber].CurrentMacAddress,
1026 &pRPort->PortCheck[j].CheckAddr)) != NULL) {
1027 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para);
1028 }
1029 }
1030 }
1031 }
1032
1033 if ((pAC->Rlmt.Port[PortNumber].Net->RlmtMode & SK_RLMT_CHECK_SEG) &&
1034 (pAC->Rlmt.Port[PortNumber].Net->CheckingState & SK_RLMT_RCS_SEND_SEG)) {
1035 /*
1036 * Send a BPDU packet to make a connected switch tell us
1037 * the correct root bridge.
1038 */
1039 if ((Para.pParaPtr =
1040 SkRlmtBuildSpanningTreePacket(pAC, IoC, PortNumber)) != NULL) {
1041 pAC->Rlmt.Port[PortNumber].Net->CheckingState &= ~SK_RLMT_RCS_SEND_SEG;
1042 pRPort->RootIdSet = SK_FALSE;
1043
1044 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para);
1045 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_TX,
1046 ("SkRlmtSend: BPDU Packet on Port %u.\n", PortNumber))
1047 }
1048 }
1049 return;
1050} /* SkRlmtSend */
1051
1052
1053/******************************************************************************
1054 *
1055 * SkRlmtPortReceives - check if port is (going) down and bring it up
1056 *
1057 * Description:
1058 * This routine checks if a port who received a non-BPDU packet
1059 * needs to go up or needs to be stopped going down.
1060 *
1061 * Context:
1062 * runtime, pageable?
1063 *
1064 * Returns:
1065 * Nothing.
1066 */
1067RLMT_STATIC void SkRlmtPortReceives(
1068SK_AC *pAC, /* Adapter Context */
1069SK_IOC IoC, /* I/O Context */
1070SK_U32 PortNumber) /* Port to check */
1071{
1072 SK_RLMT_PORT *pRPort;
1073 SK_EVPARA Para;
1074
1075 pRPort = &pAC->Rlmt.Port[PortNumber];
1076 pRPort->PortNoRx = SK_FALSE;
1077
1078 if ((pRPort->PortState == SK_RLMT_PS_DOWN) &&
1079 !(pRPort->CheckingState & SK_RLMT_PCS_TX)) {
1080 /*
1081 * Port is marked down (rx), but received a non-BPDU packet.
1082 * Bring it up.
1083 */
1084 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1085 ("SkRlmtPacketReceive: Received on PortDown.\n"))
1086
1087 pRPort->PortState = SK_RLMT_PS_GOING_UP;
1088 pRPort->GuTimeStamp = SkOsGetTime(pAC);
1089 Para.Para32[0] = PortNumber;
1090 Para.Para32[1] = (SK_U32)-1;
1091 SkTimerStart(pAC, IoC, &pRPort->UpTimer, SK_RLMT_PORTUP_TIM_VAL,
1092 SKGE_RLMT, SK_RLMT_PORTUP_TIM, Para);
1093 pRPort->CheckingState &= ~SK_RLMT_PCS_RX;
1094 /* pAC->Rlmt.CheckSwitch = SK_TRUE; */
1095 SkRlmtCheckSwitch(pAC, IoC, pRPort->Net->NetNumber);
1096 } /* PortDown && !SuspectTx */
1097 else if (pRPort->CheckingState & SK_RLMT_PCS_RX) {
1098 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1099 ("SkRlmtPacketReceive: Stop bringing port down.\n"))
1100 SkTimerStop(pAC, IoC, &pRPort->DownRxTimer);
1101 pRPort->CheckingState &= ~SK_RLMT_PCS_RX;
1102 /* pAC->Rlmt.CheckSwitch = SK_TRUE; */
1103 SkRlmtCheckSwitch(pAC, IoC, pRPort->Net->NetNumber);
1104 } /* PortGoingDown */
1105
1106 return;
1107} /* SkRlmtPortReceives */
1108
1109
1110/******************************************************************************
1111 *
1112 * SkRlmtPacketReceive - receive a packet for closer examination
1113 *
1114 * Description:
1115 * This routine examines a packet more closely than SK_RLMT_LOOKAHEAD.
1116 *
1117 * Context:
1118 * runtime, pageable?
1119 *
1120 * Returns:
1121 * Nothing.
1122 */
1123RLMT_STATIC void SkRlmtPacketReceive(
1124SK_AC *pAC, /* Adapter Context */
1125SK_IOC IoC, /* I/O Context */
1126SK_MBUF *pMb) /* Received packet */
1127{
1128#ifdef xDEBUG
1129 extern void DumpData(char *p, int size);
1130#endif /* DEBUG */
1131 int i;
1132 unsigned j;
1133 SK_U16 PacketType;
1134 SK_U32 PortNumber;
1135 SK_ADDR_PORT *pAPort;
1136 SK_RLMT_PORT *pRPort;
1137 SK_RLMT_PACKET *pRPacket;
1138 SK_SPTREE_PACKET *pSPacket;
1139 SK_EVPARA Para;
1140
1141 PortNumber = pMb->PortIdx;
1142 pAPort = &pAC->Addr.Port[PortNumber];
1143 pRPort = &pAC->Rlmt.Port[PortNumber];
1144
1145 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1146 ("SkRlmtPacketReceive: PortNumber == %d.\n", PortNumber))
1147
1148 pRPacket = (SK_RLMT_PACKET*)pMb->pData;
1149 pSPacket = (SK_SPTREE_PACKET*)pRPacket;
1150
1151#ifdef xDEBUG
1152 DumpData((char *)pRPacket, 32);
1153#endif /* DEBUG */
1154
1155 if ((pRPort->PacketsPerTimeSlot - pRPort->BpduPacketsPerTimeSlot) != 0) {
1156 SkRlmtPortReceives(pAC, IoC, PortNumber);
1157 }
wdenk42d1f032003-10-15 23:53:47 +00001158
wdenk7152b1d2003-09-05 23:19:14 +00001159 /* Check destination address. */
1160
1161 if (!SK_ADDR_EQUAL(pAPort->CurrentMacAddress.a, pRPacket->DstAddr) &&
1162 !SK_ADDR_EQUAL(SkRlmtMcAddr.a, pRPacket->DstAddr) &&
1163 !SK_ADDR_EQUAL(BridgeMcAddr.a, pRPacket->DstAddr)) {
1164
1165 /* Not sent to current MAC or registered MC address => Trash it. */
1166 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1167 ("SkRlmtPacketReceive: Not for me.\n"))
1168
1169 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1170 return;
1171 }
1172 else if (SK_ADDR_EQUAL(pAPort->CurrentMacAddress.a, pRPacket->SrcAddr)) {
1173
1174 /*
1175 * Was sent by same port (may happen during port switching
1176 * or in case of duplicate MAC addresses).
1177 */
1178
1179 /*
1180 * Check for duplicate address here:
1181 * If Packet.Random != My.Random => DupAddr.
1182 */
1183 for (i = 3; i >= 0; i--) {
1184 if (pRPort->Random[i] != pRPacket->Random[i]) {
1185 break;
1186 }
1187 }
1188
1189 /*
1190 * CAUTION: Do not check for duplicate MAC address in RLMT Alive Reply
1191 * packets (they have the LLC_COMMAND_RESPONSE_BIT set in
1192 * pRPacket->SSap).
1193 */
1194 if (i >= 0 && pRPacket->DSap == SK_RLMT_DSAP &&
1195 pRPacket->Ctrl == SK_RLMT_CTRL &&
1196 pRPacket->SSap == SK_RLMT_SSAP &&
1197 pRPacket->Indicator[0] == SK_RLMT_INDICATOR0 &&
1198 pRPacket->Indicator[1] == SK_RLMT_INDICATOR1 &&
1199 pRPacket->Indicator[2] == SK_RLMT_INDICATOR2 &&
1200 pRPacket->Indicator[3] == SK_RLMT_INDICATOR3 &&
1201 pRPacket->Indicator[4] == SK_RLMT_INDICATOR4 &&
1202 pRPacket->Indicator[5] == SK_RLMT_INDICATOR5 &&
1203 pRPacket->Indicator[6] == SK_RLMT_INDICATOR6) {
1204 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1205 ("SkRlmtPacketReceive: Duplicate MAC Address.\n"))
1206
1207 /* Error Log entry. */
1208 SK_ERR_LOG(pAC, SK_ERRCL_COMM, SKERR_RLMT_E006, SKERR_RLMT_E006_MSG);
1209 }
1210 else {
1211 /* Simply trash it. */
1212 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1213 ("SkRlmtPacketReceive: Sent by me.\n"))
1214 }
1215
1216 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1217 return;
1218 }
1219
1220 /* Check SuspectTx entries. */
1221 if (pRPort->PortsSuspect > 0) {
1222 for (j = 0; j < pRPort->PortsChecked; j++) {
1223 if (pRPort->PortCheck[j].SuspectTx &&
1224 SK_ADDR_EQUAL(
1225 pRPacket->SrcAddr, pRPort->PortCheck[j].CheckAddr.a)) {
1226 pRPort->PortCheck[j].SuspectTx = SK_FALSE;
1227 pRPort->PortsSuspect--;
1228 break;
1229 }
1230 }
1231 }
1232
1233 /* Determine type of packet. */
1234 if (pRPacket->DSap == SK_RLMT_DSAP &&
1235 pRPacket->Ctrl == SK_RLMT_CTRL &&
1236 (pRPacket->SSap & ~LLC_COMMAND_RESPONSE_BIT) == SK_RLMT_SSAP &&
1237 pRPacket->Indicator[0] == SK_RLMT_INDICATOR0 &&
1238 pRPacket->Indicator[1] == SK_RLMT_INDICATOR1 &&
1239 pRPacket->Indicator[2] == SK_RLMT_INDICATOR2 &&
1240 pRPacket->Indicator[3] == SK_RLMT_INDICATOR3 &&
1241 pRPacket->Indicator[4] == SK_RLMT_INDICATOR4 &&
1242 pRPacket->Indicator[5] == SK_RLMT_INDICATOR5 &&
1243 pRPacket->Indicator[6] == SK_RLMT_INDICATOR6) {
1244
1245 /* It's an RLMT packet. */
1246 PacketType = (SK_U16)((pRPacket->RlmtPacketType[0] << 8) |
1247 pRPacket->RlmtPacketType[1]);
1248
1249 switch (PacketType) {
1250 case SK_PACKET_ANNOUNCE: /* Not yet used. */
1251#if 0
1252 /* Build the check chain. */
1253 SkRlmtBuildCheckChain(pAC);
1254#endif /* 0 */
1255
1256 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1257 ("SkRlmtPacketReceive: Announce.\n"))
1258
1259 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1260 break;
1261
1262 case SK_PACKET_ALIVE:
1263 if (pRPacket->SSap & LLC_COMMAND_RESPONSE_BIT) {
1264 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1265 ("SkRlmtPacketReceive: Alive Reply.\n"))
1266
1267 if (!(pAC->Addr.Port[PortNumber].PromMode & SK_PROM_MODE_LLC) ||
1268 SK_ADDR_EQUAL(
1269 pRPacket->DstAddr, pAPort->CurrentMacAddress.a)) {
1270 /* Obviously we could send something. */
1271 if (pRPort->CheckingState & SK_RLMT_PCS_TX) {
1272 pRPort->CheckingState &= ~SK_RLMT_PCS_TX;
1273 SkTimerStop(pAC, IoC, &pRPort->DownTxTimer);
1274 }
1275
1276 if ((pRPort->PortState == SK_RLMT_PS_DOWN) &&
1277 !(pRPort->CheckingState & SK_RLMT_PCS_RX)) {
1278 pRPort->PortState = SK_RLMT_PS_GOING_UP;
1279 pRPort->GuTimeStamp = SkOsGetTime(pAC);
1280
1281 SkTimerStop(pAC, IoC, &pRPort->DownTxTimer);
1282
1283 Para.Para32[0] = PortNumber;
1284 Para.Para32[1] = (SK_U32)-1;
1285 SkTimerStart(pAC, IoC, &pRPort->UpTimer,
1286 SK_RLMT_PORTUP_TIM_VAL, SKGE_RLMT,
1287 SK_RLMT_PORTUP_TIM, Para);
1288 }
1289 }
1290
1291 /* Mark sending port as alive? */
1292 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1293 }
1294 else { /* Alive Request Packet. */
1295 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1296 ("SkRlmtPacketReceive: Alive Request.\n"))
1297
1298 pRPort->RxHelloCts++;
1299
1300 /* Answer. */
1301 for (i = 0; i < SK_MAC_ADDR_LEN; i++) {
1302 pRPacket->DstAddr[i] = pRPacket->SrcAddr[i];
1303 pRPacket->SrcAddr[i] =
1304 pAC->Addr.Port[PortNumber].CurrentMacAddress.a[i];
1305 }
1306 pRPacket->SSap |= LLC_COMMAND_RESPONSE_BIT;
1307
1308 Para.pParaPtr = pMb;
1309 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para);
1310 }
1311 break;
1312
1313 case SK_PACKET_CHECK_TX:
1314 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1315 ("SkRlmtPacketReceive: Check your tx line.\n"))
1316
1317 /* A port checking us requests us to check our tx line. */
1318 pRPort->CheckingState |= SK_RLMT_PCS_TX;
1319
1320 /* Start PortDownTx timer. */
1321 Para.Para32[0] = PortNumber;
1322 Para.Para32[1] = (SK_U32)-1;
1323 SkTimerStart(pAC, IoC, &pRPort->DownTxTimer,
1324 SK_RLMT_PORTDOWN_TIM_VAL, SKGE_RLMT,
1325 SK_RLMT_PORTDOWN_TX_TIM, Para);
1326
1327 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1328
1329 if ((Para.pParaPtr = SkRlmtBuildPacket(pAC, IoC, PortNumber,
1330 SK_PACKET_ALIVE, &pAC->Addr.Port[PortNumber].CurrentMacAddress,
1331 &SkRlmtMcAddr)) != NULL) {
1332 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para);
1333 }
1334 break;
1335
1336 case SK_PACKET_ADDR_CHANGED:
1337 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1338 ("SkRlmtPacketReceive: Address Change.\n"))
1339
1340 /* Build the check chain. */
1341 SkRlmtBuildCheckChain(pAC, pRPort->Net->NetNumber);
1342 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1343 break;
1344
1345 default:
1346 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1347 ("SkRlmtPacketReceive: Unknown RLMT packet.\n"))
1348
1349 /* RA;:;: ??? */
1350 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1351 }
1352 }
1353 else if (pSPacket->DSap == SK_RLMT_SPT_DSAP &&
1354 pSPacket->Ctrl == SK_RLMT_SPT_CTRL &&
1355 (pSPacket->SSap & ~LLC_COMMAND_RESPONSE_BIT) == SK_RLMT_SPT_SSAP) {
1356 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1357 ("SkRlmtPacketReceive: BPDU Packet.\n"))
1358
1359 /* Spanning Tree packet. */
1360 pRPort->RxSpHelloCts++;
1361
1362 if (!SK_ADDR_EQUAL(&pSPacket->RootId[2], &pAC->Addr.Net[pAC->Rlmt.
1363 Port[PortNumber].Net->NetNumber].CurrentMacAddress.a[0])) {
1364 /*
1365 * Check segmentation if a new root bridge is set and
1366 * the segmentation check is not currently running.
1367 */
1368 if (!SK_ADDR_EQUAL(&pSPacket->RootId[2], &pRPort->Root.Id[2]) &&
1369 (pAC->Rlmt.Port[PortNumber].Net->LinksUp > 1) &&
1370 (pAC->Rlmt.Port[PortNumber].Net->RlmtMode & SK_RLMT_CHECK_SEG)
1371 != 0 && (pAC->Rlmt.Port[PortNumber].Net->CheckingState &
1372 SK_RLMT_RCS_SEG) == 0) {
1373 pAC->Rlmt.Port[PortNumber].Net->CheckingState |=
1374 SK_RLMT_RCS_START_SEG | SK_RLMT_RCS_SEND_SEG;
1375 }
1376
1377 /* Store tree view of this port. */
1378 for (i = 0; i < 8; i++) {
1379 pRPort->Root.Id[i] = pSPacket->RootId[i];
1380 }
1381 pRPort->RootIdSet = SK_TRUE;
1382
1383 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_DUMP,
1384 ("Root ID %d: %02x %02x %02x %02x %02x %02x %02x %02x.\n",
1385 PortNumber,
1386 pRPort->Root.Id[0], pRPort->Root.Id[1],
1387 pRPort->Root.Id[2], pRPort->Root.Id[3],
1388 pRPort->Root.Id[4], pRPort->Root.Id[5],
1389 pRPort->Root.Id[6], pRPort->Root.Id[7]))
1390 }
1391
1392 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1393 if ((pAC->Rlmt.Port[PortNumber].Net->CheckingState &
1394 SK_RLMT_RCS_REPORT_SEG) != 0) {
1395 SkRlmtCheckSeg(pAC, IoC, pAC->Rlmt.Port[PortNumber].Net->NetNumber);
1396 }
1397 }
1398 else {
1399 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_RX,
1400 ("SkRlmtPacketReceive: Unknown Packet Type.\n"))
1401
1402 /* Unknown packet. */
1403 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
1404 }
1405 return;
1406} /* SkRlmtPacketReceive */
1407
1408
1409/******************************************************************************
1410 *
1411 * SkRlmtCheckPort - check if a port works
1412 *
1413 * Description:
1414 * This routine checks if a port whose link is up received something
1415 * and if it seems to transmit successfully.
1416 *
1417 * # PortState: PsInit, PsLinkDown, PsDown, PsGoingUp, PsUp
1418 * # PortCheckingState (Bitfield): ChkTx, ChkRx, ChkSeg
1419 * # RlmtCheckingState (Bitfield): ChkSeg, StartChkSeg, ReportSeg
1420 *
1421 * if (Rx - RxBpdu == 0) { # No rx.
1422 * if (state == PsUp) {
1423 * PortCheckingState |= ChkRx
1424 * }
1425 * if (ModeCheckSeg && (Timeout ==
1426 * TO_SHORTEN(RLMT_DEFAULT_TIMEOUT))) {
1427 * RlmtCheckingState |= ChkSeg)
1428 * PortCheckingState |= ChkSeg
1429 * }
1430 * NewTimeout = TO_SHORTEN(Timeout)
1431 * if (NewTimeout < RLMT_MIN_TIMEOUT) {
1432 * NewTimeout = RLMT_MIN_TIMEOUT
1433 * PortState = PsDown
1434 * ...
1435 * }
1436 * }
1437 * else { # something was received
1438 * # Set counter to 0 at LinkDown?
1439 * # No - rx may be reported after LinkDown ???
1440 * PortCheckingState &= ~ChkRx
1441 * NewTimeout = RLMT_DEFAULT_TIMEOUT
1442 * if (RxAck == 0) {
1443 * possible reasons:
1444 * is my tx line bad? --
1445 * send RLMT multicast and report
1446 * back internally? (only possible
1447 * between ports on same adapter)
1448 * }
1449 * if (RxChk == 0) {
1450 * possible reasons:
1451 * - tx line of port set to check me
1452 * maybe bad
1453 * - no other port/adapter available or set
1454 * to check me
1455 * - adapter checking me has a longer
1456 * timeout
1457 * ??? anything that can be done here?
1458 * }
1459 * }
1460 *
1461 * Context:
1462 * runtime, pageable?
1463 *
1464 * Returns:
1465 * New timeout value.
1466 */
1467RLMT_STATIC SK_U32 SkRlmtCheckPort(
1468SK_AC *pAC, /* Adapter Context */
1469SK_IOC IoC, /* I/O Context */
1470SK_U32 PortNumber) /* Port to check */
1471{
1472 unsigned i;
1473 SK_U32 NewTimeout;
1474 SK_RLMT_PORT *pRPort;
1475 SK_EVPARA Para;
1476
1477 pRPort = &pAC->Rlmt.Port[PortNumber];
1478
1479 if ((pRPort->PacketsPerTimeSlot - pRPort->BpduPacketsPerTimeSlot) == 0) {
1480 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1481 ("SkRlmtCheckPort %d: No (%d) receives in last time slot.\n",
1482 PortNumber, pRPort->PacketsPerTimeSlot))
1483
1484 /*
1485 * Check segmentation if there was no receive at least twice
1486 * in a row (PortNoRx is already set) and the segmentation
1487 * check is not currently running.
1488 */
1489
1490 if (pRPort->PortNoRx && (pAC->Rlmt.Port[PortNumber].Net->LinksUp > 1) &&
1491 (pAC->Rlmt.Port[PortNumber].Net->RlmtMode & SK_RLMT_CHECK_SEG) &&
1492 !(pAC->Rlmt.Port[PortNumber].Net->CheckingState & SK_RLMT_RCS_SEG)) {
1493 pAC->Rlmt.Port[PortNumber].Net->CheckingState |=
1494 SK_RLMT_RCS_START_SEG | SK_RLMT_RCS_SEND_SEG;
1495 }
1496
1497 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1498 ("SkRlmtCheckPort: PortsSuspect %d, PcsRx %d.\n",
1499 pRPort->PortsSuspect, pRPort->CheckingState & SK_RLMT_PCS_RX))
1500
1501 if (pRPort->PortState != SK_RLMT_PS_DOWN) {
1502 NewTimeout = TO_SHORTEN(pAC->Rlmt.Port[PortNumber].Net->TimeoutValue);
1503 if (NewTimeout < SK_RLMT_MIN_TO_VAL) {
1504 NewTimeout = SK_RLMT_MIN_TO_VAL;
1505 }
1506
1507 if (!(pRPort->CheckingState & SK_RLMT_PCS_RX)) {
1508 Para.Para32[0] = PortNumber;
1509 pRPort->CheckingState |= SK_RLMT_PCS_RX;
1510
1511 /*
1512 * What shall we do if the port checked by this one receives
1513 * our request frames? What's bad - our rx line or his tx line?
1514 */
1515 Para.Para32[1] = (SK_U32)-1;
1516 SkTimerStart(pAC, IoC, &pRPort->DownRxTimer,
1517 SK_RLMT_PORTDOWN_TIM_VAL, SKGE_RLMT,
1518 SK_RLMT_PORTDOWN_RX_TIM, Para);
1519
1520 for (i = 0; i < pRPort->PortsChecked; i++) {
1521 if (pRPort->PortCheck[i].SuspectTx) {
1522 continue;
1523 }
1524 pRPort->PortCheck[i].SuspectTx = SK_TRUE;
1525 pRPort->PortsSuspect++;
1526 if ((Para.pParaPtr =
1527 SkRlmtBuildPacket(pAC, IoC, PortNumber, SK_PACKET_CHECK_TX,
1528 &pAC->Addr.Port[PortNumber].CurrentMacAddress,
1529 &pRPort->PortCheck[i].CheckAddr)) != NULL) {
1530 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para);
1531 }
1532 }
1533 }
1534 }
1535 else { /* PortDown -- or all partners suspect. */
1536 NewTimeout = SK_RLMT_DEF_TO_VAL;
1537 }
1538 pRPort->PortNoRx = SK_TRUE;
1539 }
1540 else { /* A non-BPDU packet was received. */
1541 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1542 ("SkRlmtCheckPort %d: %d (%d) receives in last time slot.\n",
1543 PortNumber,
1544 pRPort->PacketsPerTimeSlot - pRPort->BpduPacketsPerTimeSlot,
1545 pRPort->PacketsPerTimeSlot))
wdenk42d1f032003-10-15 23:53:47 +00001546
wdenk7152b1d2003-09-05 23:19:14 +00001547 SkRlmtPortReceives(pAC, IoC, PortNumber);
1548 if (pAC->Rlmt.CheckSwitch) {
1549 SkRlmtCheckSwitch(pAC, IoC, pRPort->Net->NetNumber);
1550 }
1551
1552 NewTimeout = SK_RLMT_DEF_TO_VAL;
1553 }
1554
1555 return (NewTimeout);
1556} /* SkRlmtCheckPort */
1557
1558
1559/******************************************************************************
1560 *
1561 * SkRlmtSelectBcRx - select new active port, criteria 1 (CLP)
1562 *
1563 * Description:
1564 * This routine selects the port that received a broadcast frame
1565 * substantially later than all other ports.
1566 *
1567 * Context:
1568 * runtime, pageable?
1569 *
1570 * Returns:
1571 * SK_BOOL
1572 */
1573RLMT_STATIC SK_BOOL SkRlmtSelectBcRx(
1574SK_AC *pAC, /* Adapter Context */
1575SK_IOC IoC, /* I/O Context */
1576SK_U32 Active, /* Active port */
1577SK_U32 PrefPort, /* Preferred port */
1578SK_U32 *pSelect) /* New active port */
1579{
1580 SK_U64 BcTimeStamp;
1581 SK_U32 i;
1582 SK_BOOL PortFound;
1583
1584 BcTimeStamp = 0; /* Not totally necessary, but feeling better. */
1585 PortFound = SK_FALSE;
wdenk42d1f032003-10-15 23:53:47 +00001586
wdenk7152b1d2003-09-05 23:19:14 +00001587 /* Select port with the latest TimeStamp. */
1588 for (i = 0; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
1589
1590 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1591 ("TimeStamp Port %d (Down: %d, NoRx: %d): %08x %08x.\n",
1592 i,
wdenk42d1f032003-10-15 23:53:47 +00001593 pAC->Rlmt.Port[i].PortDown, pAC->Rlmt.Port[i].PortNoRx,
wdenk7152b1d2003-09-05 23:19:14 +00001594 *((SK_U32*)(&pAC->Rlmt.Port[i].BcTimeStamp) + OFFS_HI32),
1595 *((SK_U32*)(&pAC->Rlmt.Port[i].BcTimeStamp) + OFFS_LO32)))
1596
1597 if (!pAC->Rlmt.Port[i].PortDown && !pAC->Rlmt.Port[i].PortNoRx) {
1598 if (!PortFound || pAC->Rlmt.Port[i].BcTimeStamp > BcTimeStamp) {
1599 BcTimeStamp = pAC->Rlmt.Port[i].BcTimeStamp;
1600 *pSelect = i;
1601 PortFound = SK_TRUE;
1602 }
1603 }
1604 }
1605
1606 if (PortFound) {
1607 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1608 ("Port %d received the last broadcast.\n", *pSelect))
1609
1610 /* Look if another port's time stamp is similar. */
1611 for (i = 0; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
1612 if (i == *pSelect) {
1613 continue;
1614 }
1615 if (!pAC->Rlmt.Port[i].PortDown && !pAC->Rlmt.Port[i].PortNoRx &&
1616 (pAC->Rlmt.Port[i].BcTimeStamp >
1617 BcTimeStamp - SK_RLMT_BC_DELTA ||
1618 pAC->Rlmt.Port[i].BcTimeStamp +
1619 SK_RLMT_BC_DELTA > BcTimeStamp)) {
1620 PortFound = SK_FALSE;
wdenk42d1f032003-10-15 23:53:47 +00001621
wdenk7152b1d2003-09-05 23:19:14 +00001622 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1623 ("Port %d received a broadcast at a similar time.\n", i))
1624 break;
1625 }
1626 }
1627 }
1628
1629#ifdef DEBUG
1630 if (PortFound) {
1631 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1632 ("SK_RLMT_SELECT_BCRX found Port %d receiving the substantially "
1633 "latest broadcast (%u).\n",
1634 *pSelect,
1635 BcTimeStamp - pAC->Rlmt.Port[1 - *pSelect].BcTimeStamp))
1636 }
1637#endif /* DEBUG */
1638
1639 return (PortFound);
1640} /* SkRlmtSelectBcRx */
1641
1642
1643/******************************************************************************
1644 *
1645 * SkRlmtSelectNotSuspect - select new active port, criteria 2 (CLP)
1646 *
1647 * Description:
1648 * This routine selects a good port (it is PortUp && !SuspectRx).
1649 *
1650 * Context:
1651 * runtime, pageable?
1652 *
1653 * Returns:
1654 * SK_BOOL
1655 */
1656RLMT_STATIC SK_BOOL SkRlmtSelectNotSuspect(
1657SK_AC *pAC, /* Adapter Context */
1658SK_IOC IoC, /* I/O Context */
1659SK_U32 Active, /* Active port */
1660SK_U32 PrefPort, /* Preferred port */
1661SK_U32 *pSelect) /* New active port */
1662{
1663 SK_U32 i;
1664 SK_BOOL PortFound;
1665
1666 PortFound = SK_FALSE;
1667
1668 /* Select first port that is PortUp && !SuspectRx. */
1669 for (i = 0; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
1670 if (!pAC->Rlmt.Port[i].PortDown &&
1671 !(pAC->Rlmt.Port[i].CheckingState & SK_RLMT_PCS_RX)) {
1672 *pSelect = i;
1673 if (!pAC->Rlmt.Port[Active].PortDown &&
1674 !(pAC->Rlmt.Port[Active].CheckingState & SK_RLMT_PCS_RX)) {
1675 *pSelect = Active;
1676 }
1677 if (!pAC->Rlmt.Port[PrefPort].PortDown &&
1678 !(pAC->Rlmt.Port[PrefPort].CheckingState & SK_RLMT_PCS_RX)) {
1679 *pSelect = PrefPort;
1680 }
1681 PortFound = SK_TRUE;
1682 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1683 ("SK_RLMT_SELECT_NOTSUSPECT found Port %d up and not check RX.\n",
1684 *pSelect))
1685 break;
1686 }
1687 }
1688 return (PortFound);
1689} /* SkRlmtSelectNotSuspect */
1690
1691
1692/******************************************************************************
1693 *
1694 * SkRlmtSelectUp - select new active port, criteria 3, 4 (CLP)
1695 *
1696 * Description:
1697 * This routine selects a port that is up.
1698 *
1699 * Context:
1700 * runtime, pageable?
1701 *
1702 * Returns:
1703 * SK_BOOL
1704 */
1705RLMT_STATIC SK_BOOL SkRlmtSelectUp(
1706SK_AC *pAC, /* Adapter Context */
1707SK_IOC IoC, /* I/O Context */
1708SK_U32 Active, /* Active port */
1709SK_U32 PrefPort, /* Preferred port */
1710SK_U32 *pSelect, /* New active port */
1711SK_BOOL AutoNegDone) /* Successfully auto-negotiated? */
1712{
1713 SK_U32 i;
1714 SK_BOOL PortFound;
1715
1716 PortFound = SK_FALSE;
1717
1718 /* Select first port that is PortUp. */
1719 for (i = 0; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
1720 if (pAC->Rlmt.Port[i].PortState == SK_RLMT_PS_UP &&
1721 pAC->GIni.GP[i].PAutoNegFail != AutoNegDone) {
1722 *pSelect = i;
1723 if (pAC->Rlmt.Port[Active].PortState == SK_RLMT_PS_UP &&
1724 pAC->GIni.GP[Active].PAutoNegFail != AutoNegDone) {
1725 *pSelect = Active;
1726 }
1727 if (pAC->Rlmt.Port[PrefPort].PortState == SK_RLMT_PS_UP &&
1728 pAC->GIni.GP[PrefPort].PAutoNegFail != AutoNegDone) {
1729 *pSelect = PrefPort;
1730 }
1731 PortFound = SK_TRUE;
1732 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1733 ("SK_RLMT_SELECT_UP found Port %d up.\n", *pSelect))
1734 break;
1735 }
1736 }
1737 return (PortFound);
1738} /* SkRlmtSelectUp */
1739
1740
1741/******************************************************************************
1742 *
1743 * SkRlmtSelectGoingUp - select new active port, criteria 5, 6 (CLP)
1744 *
1745 * Description:
1746 * This routine selects the port that is going up for the longest time.
1747 *
1748 * Context:
1749 * runtime, pageable?
1750 *
1751 * Returns:
1752 * SK_BOOL
1753 */
1754RLMT_STATIC SK_BOOL SkRlmtSelectGoingUp(
1755SK_AC *pAC, /* Adapter Context */
1756SK_IOC IoC, /* I/O Context */
1757SK_U32 Active, /* Active port */
1758SK_U32 PrefPort, /* Preferred port */
1759SK_U32 *pSelect, /* New active port */
1760SK_BOOL AutoNegDone) /* Successfully auto-negotiated? */
1761{
1762 SK_U64 GuTimeStamp;
1763 SK_U32 i;
1764 SK_BOOL PortFound;
1765
1766 GuTimeStamp = 0;
1767 PortFound = SK_FALSE;
1768
1769 /* Select port that is PortGoingUp for the longest time. */
1770 for (i = 0; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
1771 if (pAC->Rlmt.Port[i].PortState == SK_RLMT_PS_GOING_UP &&
1772 pAC->GIni.GP[i].PAutoNegFail != AutoNegDone) {
1773 GuTimeStamp = pAC->Rlmt.Port[i].GuTimeStamp;
1774 *pSelect = i;
1775 PortFound = SK_TRUE;
1776 break;
1777 }
1778 }
1779
1780 if (!PortFound) {
1781 return (SK_FALSE);
1782 }
1783
1784 for (i = *pSelect + 1; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
1785 if (pAC->Rlmt.Port[i].PortState == SK_RLMT_PS_GOING_UP &&
1786 pAC->Rlmt.Port[i].GuTimeStamp < GuTimeStamp &&
1787 pAC->GIni.GP[i].PAutoNegFail != AutoNegDone) {
1788 GuTimeStamp = pAC->Rlmt.Port[i].GuTimeStamp;
1789 *pSelect = i;
1790 }
1791 }
1792
1793 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1794 ("SK_RLMT_SELECT_GOINGUP found Port %d going up.\n", *pSelect))
1795 return (SK_TRUE);
1796} /* SkRlmtSelectGoingUp */
1797
1798
1799/******************************************************************************
1800 *
1801 * SkRlmtSelectDown - select new active port, criteria 7, 8 (CLP)
1802 *
1803 * Description:
1804 * This routine selects a port that is down.
1805 *
1806 * Context:
1807 * runtime, pageable?
1808 *
1809 * Returns:
1810 * SK_BOOL
1811 */
1812RLMT_STATIC SK_BOOL SkRlmtSelectDown(
1813SK_AC *pAC, /* Adapter Context */
1814SK_IOC IoC, /* I/O Context */
1815SK_U32 Active, /* Active port */
1816SK_U32 PrefPort, /* Preferred port */
1817SK_U32 *pSelect, /* New active port */
1818SK_BOOL AutoNegDone) /* Successfully auto-negotiated? */
1819{
1820 SK_U32 i;
1821 SK_BOOL PortFound;
1822
1823 PortFound = SK_FALSE;
1824
1825 /* Select first port that is PortDown. */
1826 for (i = 0; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
1827 if (pAC->Rlmt.Port[i].PortState == SK_RLMT_PS_DOWN &&
1828 pAC->GIni.GP[i].PAutoNegFail != AutoNegDone) {
1829 *pSelect = i;
1830 if (pAC->Rlmt.Port[Active].PortState == SK_RLMT_PS_DOWN &&
1831 pAC->GIni.GP[Active].PAutoNegFail != AutoNegDone) {
1832 *pSelect = Active;
1833 }
1834 if (pAC->Rlmt.Port[PrefPort].PortState == SK_RLMT_PS_DOWN &&
1835 pAC->GIni.GP[PrefPort].PAutoNegFail != AutoNegDone) {
1836 *pSelect = PrefPort;
1837 }
1838 PortFound = SK_TRUE;
1839 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
1840 ("SK_RLMT_SELECT_DOWN found Port %d down.\n", *pSelect))
1841 break;
1842 }
1843 }
1844 return (PortFound);
1845} /* SkRlmtSelectDown */
1846
1847
1848/******************************************************************************
1849 *
1850 * SkRlmtCheckSwitch - select new active port and switch to it
1851 *
1852 * Description:
1853 * This routine decides which port should be the active one and queues
1854 * port switching if necessary.
1855 *
1856 * Context:
1857 * runtime, pageable?
1858 *
1859 * Returns:
1860 * Nothing.
1861 */
1862RLMT_STATIC void SkRlmtCheckSwitch(
1863SK_AC *pAC, /* Adapter Context */
1864SK_IOC IoC, /* I/O Context */
1865SK_U32 NetIdx) /* Net index */
1866{
1867 SK_EVPARA Para;
1868 SK_U32 Active;
1869 SK_U32 PrefPort;
1870 SK_U32 i;
1871 SK_BOOL PortFound;
1872
1873 Active = pAC->Rlmt.Net[NetIdx].ActivePort; /* Index of active port. */
1874 PrefPort = pAC->Rlmt.Net[NetIdx].PrefPort; /* Index of preferred port. */
1875 PortFound = SK_FALSE;
1876 pAC->Rlmt.CheckSwitch = SK_FALSE;
1877
1878#if 0 /* RW 2001/10/18 - active port becomes always prefered one */
1879 if (pAC->Rlmt.Net[NetIdx].Preference == 0xFFFFFFFF) { /* Automatic */
1880 /* disable auto-fail back */
1881 PrefPort = Active;
1882 }
1883#endif
1884
1885 if (pAC->Rlmt.Net[NetIdx].LinksUp == 0) {
1886 /* Last link went down - shut down the net. */
1887 pAC->Rlmt.Net[NetIdx].RlmtState = SK_RLMT_RS_NET_DOWN;
1888 Para.Para32[0] = SK_RLMT_NET_DOWN_TEMP;
1889 Para.Para32[1] = NetIdx;
1890 SkEventQueue(pAC, SKGE_DRV, SK_DRV_NET_DOWN, Para);
1891
1892 Para.Para32[0] = pAC->Rlmt.Net[NetIdx].
1893 Port[pAC->Rlmt.Net[NetIdx].ActivePort]->PortNumber;
1894 Para.Para32[1] = NetIdx;
1895 SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_ACTIVE_DOWN, Para);
1896 return;
1897 } /* pAC->Rlmt.LinksUp == 0 */
1898 else if (pAC->Rlmt.Net[NetIdx].LinksUp == 1 &&
1899 pAC->Rlmt.Net[NetIdx].RlmtState == SK_RLMT_RS_NET_DOWN) {
1900 /* First link came up - get the net up. */
1901 pAC->Rlmt.Net[NetIdx].RlmtState = SK_RLMT_RS_NET_UP;
1902
1903 /*
1904 * If pAC->Rlmt.ActivePort != Para.Para32[0],
1905 * the DRV switches to the port that came up.
1906 */
1907 for (i = 0; i < pAC->Rlmt.Net[NetIdx].NumPorts; i++) {
1908 if (!pAC->Rlmt.Net[NetIdx].Port[i]->LinkDown) {
1909 if (!pAC->Rlmt.Net[NetIdx].Port[Active]->LinkDown) {
1910 i = Active;
1911 }
1912 if (!pAC->Rlmt.Net[NetIdx].Port[PrefPort]->LinkDown) {
1913 i = PrefPort;
1914 }
1915 PortFound = SK_TRUE;
1916 break;
1917 }
1918 }
1919
1920 if (PortFound) {
1921 Para.Para32[0] = pAC->Rlmt.Net[NetIdx].Port[i]->PortNumber;
1922 Para.Para32[1] = NetIdx;
1923 SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_ACTIVE_UP, Para);
1924
1925 pAC->Rlmt.Net[NetIdx].ActivePort = i;
1926 Para.Para32[0] = pAC->Rlmt.Net[NetIdx].Port[i]->PortNumber;
1927 Para.Para32[1] = NetIdx;
1928 SkEventQueue(pAC, SKGE_DRV, SK_DRV_NET_UP, Para);
1929
1930 if ((pAC->Rlmt.Net[NetIdx].RlmtMode & SK_RLMT_TRANSPARENT) == 0 &&
1931 (Para.pParaPtr = SkRlmtBuildPacket(pAC, IoC,
1932 pAC->Rlmt.Net[NetIdx].Port[i]->PortNumber,
1933 SK_PACKET_ANNOUNCE, &pAC->Addr.Net[NetIdx].
1934 CurrentMacAddress, &SkRlmtMcAddr)) != NULL) {
1935 /*
1936 * Send announce packet to RLMT multicast address to force
1937 * switches to learn the new location of the logical MAC address.
1938 */
1939 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para);
1940 }
1941 }
1942 else {
1943 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_RLMT_E007, SKERR_RLMT_E007_MSG);
1944 }
1945
1946 return;
1947 } /* LinksUp == 1 && RlmtState == SK_RLMT_RS_NET_DOWN */
1948 else { /* Cannot be reached in dual-net mode. */
1949 Para.Para32[0] = Active;
1950
1951 /*
1952 * Preselection:
1953 * If RLMT Mode != CheckLinkState
1954 * select port that received a broadcast frame substantially later
1955 * than all other ports
1956 * else select first port that is not SuspectRx
1957 * else select first port that is PortUp
1958 * else select port that is PortGoingUp for the longest time
1959 * else select first port that is PortDown
1960 * else stop.
1961 *
1962 * For the preselected port:
1963 * If ActivePort is equal in quality, select ActivePort.
1964 *
1965 * If PrefPort is equal in quality, select PrefPort.
1966 *
1967 * If ActivePort != SelectedPort,
1968 * If old ActivePort is LinkDown,
1969 * SwitchHard
1970 * else
1971 * SwitchSoft
1972 */
1973 /* check of ChgBcPrio flag added */
1974 if ((pAC->Rlmt.Net[0].RlmtMode != SK_RLMT_MODE_CLS) &&
1975 (!pAC->Rlmt.Net[0].ChgBcPrio)) {
wdenk42d1f032003-10-15 23:53:47 +00001976
wdenk7152b1d2003-09-05 23:19:14 +00001977 if (!PortFound) {
1978 PortFound = SkRlmtSelectBcRx(
1979 pAC, IoC, Active, PrefPort, &Para.Para32[1]);
1980 }
1981
1982 if (!PortFound) {
1983 PortFound = SkRlmtSelectNotSuspect(
1984 pAC, IoC, Active, PrefPort, &Para.Para32[1]);
1985 }
1986 } /* pAC->Rlmt.RlmtMode != SK_RLMT_MODE_CLS */
1987
1988 /* with changed priority for last broadcast received */
1989 if ((pAC->Rlmt.Net[0].RlmtMode != SK_RLMT_MODE_CLS) &&
1990 (pAC->Rlmt.Net[0].ChgBcPrio)) {
1991 if (!PortFound) {
1992 PortFound = SkRlmtSelectNotSuspect(
1993 pAC, IoC, Active, PrefPort, &Para.Para32[1]);
1994 }
1995
1996 if (!PortFound) {
1997 PortFound = SkRlmtSelectBcRx(
1998 pAC, IoC, Active, PrefPort, &Para.Para32[1]);
1999 }
2000 } /* pAC->Rlmt.RlmtMode != SK_RLMT_MODE_CLS */
2001
2002 if (!PortFound) {
2003 PortFound = SkRlmtSelectUp(
2004 pAC, IoC, Active, PrefPort, &Para.Para32[1], AUTONEG_SUCCESS);
2005 }
2006
2007 if (!PortFound) {
2008 PortFound = SkRlmtSelectUp(
2009 pAC, IoC, Active, PrefPort, &Para.Para32[1], AUTONEG_FAILED);
2010 }
2011
2012 if (!PortFound) {
2013 PortFound = SkRlmtSelectGoingUp(
2014 pAC, IoC, Active, PrefPort, &Para.Para32[1], AUTONEG_SUCCESS);
2015 }
2016
2017 if (!PortFound) {
2018 PortFound = SkRlmtSelectGoingUp(
2019 pAC, IoC, Active, PrefPort, &Para.Para32[1], AUTONEG_FAILED);
2020 }
2021
2022 if (pAC->Rlmt.Net[0].RlmtMode != SK_RLMT_MODE_CLS) {
2023 if (!PortFound) {
2024 PortFound = SkRlmtSelectDown(pAC, IoC,
2025 Active, PrefPort, &Para.Para32[1], AUTONEG_SUCCESS);
2026 }
2027
2028 if (!PortFound) {
2029 PortFound = SkRlmtSelectDown(pAC, IoC,
2030 Active, PrefPort, &Para.Para32[1], AUTONEG_FAILED);
2031 }
2032 } /* pAC->Rlmt.RlmtMode != SK_RLMT_MODE_CLS */
2033
2034 if (PortFound) {
2035
2036 if (Para.Para32[1] != Active) {
2037 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2038 ("Active: %d, Para1: %d.\n", Active, Para.Para32[1]))
2039 pAC->Rlmt.Net[NetIdx].ActivePort = Para.Para32[1];
2040 Para.Para32[0] = pAC->Rlmt.Net[NetIdx].
2041 Port[Para.Para32[0]]->PortNumber;
2042 Para.Para32[1] = pAC->Rlmt.Net[NetIdx].
2043 Port[Para.Para32[1]]->PortNumber;
2044 SK_HWAC_LINK_LED(pAC, IoC, Para.Para32[1], SK_LED_ACTIVE);
2045 if (pAC->Rlmt.Port[Active].LinkDown) {
2046 SkEventQueue(pAC, SKGE_DRV, SK_DRV_SWITCH_HARD, Para);
2047 }
2048 else {
2049 SK_HWAC_LINK_LED(pAC, IoC, Para.Para32[0], SK_LED_STANDBY);
2050 SkEventQueue(pAC, SKGE_DRV, SK_DRV_SWITCH_SOFT, Para);
2051 }
2052 Para.Para32[1] = NetIdx;
2053 Para.Para32[0] =
2054 pAC->Rlmt.Net[NetIdx].Port[Para.Para32[0]]->PortNumber;
2055 SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_ACTIVE_DOWN, Para);
2056 Para.Para32[0] = pAC->Rlmt.Net[NetIdx].
2057 Port[pAC->Rlmt.Net[NetIdx].ActivePort]->PortNumber;
2058 SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_ACTIVE_UP, Para);
2059 if ((pAC->Rlmt.Net[NetIdx].RlmtMode & SK_RLMT_TRANSPARENT) == 0 &&
2060 (Para.pParaPtr = SkRlmtBuildPacket(pAC, IoC, Para.Para32[0],
2061 SK_PACKET_ANNOUNCE, &pAC->Addr.Net[NetIdx].CurrentMacAddress,
2062 &SkRlmtMcAddr)) != NULL) {
2063 /*
2064 * Send announce packet to RLMT multicast address to force
2065 * switches to learn the new location of the logical
2066 * MAC address.
2067 */
2068 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para);
2069 } /* (Para.pParaPtr = SkRlmtBuildPacket(...)) != NULL */
2070 } /* Para.Para32[1] != Active */
2071 } /* PortFound */
2072 else {
2073 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_RLMT_E004, SKERR_RLMT_E004_MSG);
2074 }
2075 } /* LinksUp > 1 || LinksUp == 1 && RlmtState != SK_RLMT_RS_NET_DOWN */
2076 return;
2077} /* SkRlmtCheckSwitch */
2078
2079
2080/******************************************************************************
2081 *
2082 * SkRlmtCheckSeg - Report if segmentation is detected
2083 *
2084 * Description:
2085 * This routine checks if the ports see different root bridges and reports
2086 * segmentation in such a case.
2087 *
2088 * Context:
2089 * runtime, pageable?
2090 *
2091 * Returns:
2092 * Nothing.
2093 */
2094RLMT_STATIC void SkRlmtCheckSeg(
2095SK_AC *pAC, /* Adapter Context */
2096SK_IOC IoC, /* I/O Context */
2097SK_U32 NetIdx) /* Net number */
2098{
2099 SK_EVPARA Para;
2100 SK_RLMT_NET *pNet;
2101 SK_U32 i, j;
2102 SK_BOOL Equal;
2103
2104 pNet = &pAC->Rlmt.Net[NetIdx];
2105 pNet->RootIdSet = SK_FALSE;
2106 Equal = SK_TRUE;
2107
2108 for (i = 0; i < pNet->NumPorts; i++) {
2109 if (pNet->Port[i]->LinkDown || !pNet->Port[i]->RootIdSet) {
2110 continue;
2111 }
2112
2113 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_DUMP,
2114 ("Root ID %d: %02x %02x %02x %02x %02x %02x %02x %02x.\n", i,
2115 pNet->Port[i]->Root.Id[0], pNet->Port[i]->Root.Id[1],
2116 pNet->Port[i]->Root.Id[2], pNet->Port[i]->Root.Id[3],
2117 pNet->Port[i]->Root.Id[4], pNet->Port[i]->Root.Id[5],
2118 pNet->Port[i]->Root.Id[6], pNet->Port[i]->Root.Id[7]))
2119
2120 if (!pNet->RootIdSet) {
2121 pNet->Root = pNet->Port[i]->Root;
2122 pNet->RootIdSet = SK_TRUE;
2123 continue;
2124 }
2125
2126 for (j = 0; j < 8; j ++) {
2127 Equal &= pNet->Port[i]->Root.Id[j] == pNet->Root.Id[j];
2128 if (!Equal) {
2129 break;
2130 }
2131 }
wdenk42d1f032003-10-15 23:53:47 +00002132
wdenk7152b1d2003-09-05 23:19:14 +00002133 if (!Equal) {
2134 SK_ERR_LOG(pAC, SK_ERRCL_COMM, SKERR_RLMT_E005, SKERR_RLMT_E005_MSG);
2135 Para.Para32[0] = NetIdx;
2136 Para.Para32[1] = (SK_U32)-1;
2137 SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_SEGMENTATION, Para);
2138
2139 pNet->CheckingState &= ~SK_RLMT_RCS_REPORT_SEG;
2140
2141 /* 2000-03-06 RA: New. */
2142 Para.Para32[0] = NetIdx;
2143 Para.Para32[1] = (SK_U32)-1;
2144 SkTimerStart(pAC, IoC, &pNet->SegTimer, SK_RLMT_SEG_TO_VAL,
2145 SKGE_RLMT, SK_RLMT_SEG_TIM, Para);
2146 break;
2147 }
2148 } /* for (i = 0; i < pNet->NumPorts; i++) */
2149
2150 /* 2000-03-06 RA: Moved here. */
2151 /* Segmentation check not running anymore. */
2152 pNet->CheckingState &= ~SK_RLMT_RCS_SEG;
2153
2154} /* SkRlmtCheckSeg */
2155
2156
2157/******************************************************************************
2158 *
2159 * SkRlmtPortStart - initialize port variables and start port
2160 *
2161 * Description:
2162 * This routine initializes a port's variables and issues a PORT_START
2163 * to the HWAC module. This handles retries if the start fails or the
2164 * link eventually goes down.
2165 *
2166 * Context:
2167 * runtime, pageable?
2168 *
2169 * Returns:
2170 * Nothing
2171 */
2172RLMT_STATIC void SkRlmtPortStart(
2173SK_AC *pAC, /* Adapter Context */
2174SK_IOC IoC, /* I/O Context */
2175SK_U32 PortNumber) /* Port number */
2176{
2177 SK_EVPARA Para;
2178
2179 pAC->Rlmt.Port[PortNumber].PortState = SK_RLMT_PS_LINK_DOWN;
2180 pAC->Rlmt.Port[PortNumber].PortStarted = SK_TRUE;
2181 pAC->Rlmt.Port[PortNumber].LinkDown = SK_TRUE;
2182 pAC->Rlmt.Port[PortNumber].PortDown = SK_TRUE;
2183 pAC->Rlmt.Port[PortNumber].CheckingState = 0;
2184 pAC->Rlmt.Port[PortNumber].RootIdSet = SK_FALSE;
2185 Para.Para32[0] = PortNumber;
2186 Para.Para32[1] = (SK_U32)-1;
2187 SkEventQueue(pAC, SKGE_HWAC, SK_HWEV_PORT_START, Para);
2188} /* SkRlmtPortStart */
2189
2190
2191/******************************************************************************
2192 *
2193 * SkRlmtEvtPortStartTim - PORT_START_TIM
2194 *
2195 * Description:
2196 * This routine handles PORT_START_TIM events.
2197 *
2198 * Context:
2199 * runtime, pageable?
2200 * may be called after SK_INIT_IO
2201 *
2202 * Returns:
2203 * Nothing
2204 */
2205RLMT_STATIC void SkRlmtEvtPortStartTim(
2206SK_AC *pAC, /* Adapter Context */
2207SK_IOC IoC, /* I/O Context */
2208SK_EVPARA Para) /* SK_U32 PortNumber; SK_U32 -1 */
2209{
2210 SK_U32 i;
2211
2212 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2213 ("SK_RLMT_PORTSTART_TIMEOUT Port %d Event BEGIN.\n", Para.Para32[0]))
2214
2215 if (Para.Para32[1] != (SK_U32)-1) {
2216 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2217 ("Bad Parameter.\n"))
2218 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2219 ("SK_RLMT_PORTSTART_TIMEOUT Event EMPTY.\n"))
2220 return;
2221 }
2222
2223 /*
2224 * Used to start non-preferred ports if the preferred one
2225 * does not come up.
2226 * This timeout needs only be set when starting the first
2227 * (preferred) port.
2228 */
2229 if (pAC->Rlmt.Port[Para.Para32[0]].LinkDown) {
2230 /* PORT_START failed. */
2231 for (i = 0; i < pAC->Rlmt.Port[Para.Para32[0]].Net->NumPorts; i++) {
2232 if (!pAC->Rlmt.Port[Para.Para32[0]].Net->Port[i]->PortStarted) {
2233 SkRlmtPortStart(pAC, IoC,
2234 pAC->Rlmt.Port[Para.Para32[0]].Net->Port[i]->PortNumber);
2235 }
2236 }
2237 }
2238
2239 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2240 ("SK_RLMT_PORTSTART_TIMEOUT Event END.\n"))
2241} /* SkRlmtEvtPortStartTim */
2242
2243
2244/******************************************************************************
2245 *
2246 * SkRlmtEvtLinkUp - LINK_UP
2247 *
2248 * Description:
2249 * This routine handles LLINK_UP events.
2250 *
2251 * Context:
2252 * runtime, pageable?
2253 * may be called after SK_INIT_IO
2254 *
2255 * Returns:
2256 * Nothing
2257 */
2258RLMT_STATIC void SkRlmtEvtLinkUp(
2259SK_AC *pAC, /* Adapter Context */
2260SK_IOC IoC, /* I/O Context */
2261SK_EVPARA Para) /* SK_U32 PortNumber; SK_U32 Undefined */
2262{
2263 SK_U32 i;
2264 SK_RLMT_PORT *pRPort;
2265 SK_EVPARA Para2;
2266
2267 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2268 ("SK_RLMT_LINK_UP Port %d Event BEGIN.\n", Para.Para32[0]))
2269
2270 pRPort = &pAC->Rlmt.Port[Para.Para32[0]];
2271 if (!pRPort->PortStarted) {
2272 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_RLMT_E008, SKERR_RLMT_E008_MSG);
2273
2274 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2275 ("SK_RLMT_LINK_UP Event EMPTY.\n"))
2276 return;
2277 }
2278
2279 if (!pRPort->LinkDown) {
2280 /* RA;:;: Any better solution? */
2281 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2282 ("SK_RLMT_LINK_UP Event EMPTY.\n"))
2283 return;
2284 }
2285
2286 SkTimerStop(pAC, IoC, &pRPort->UpTimer);
2287 SkTimerStop(pAC, IoC, &pRPort->DownRxTimer);
2288 SkTimerStop(pAC, IoC, &pRPort->DownTxTimer);
2289
2290 /* Do something if timer already fired? */
2291
2292 pRPort->LinkDown = SK_FALSE;
2293 pRPort->PortState = SK_RLMT_PS_GOING_UP;
2294 pRPort->GuTimeStamp = SkOsGetTime(pAC);
2295 pRPort->BcTimeStamp = 0;
2296 pRPort->Net->LinksUp++;
2297 if (pRPort->Net->LinksUp == 1) {
2298 SK_HWAC_LINK_LED(pAC, IoC, Para.Para32[0], SK_LED_ACTIVE);
2299 }
2300 else {
2301 SK_HWAC_LINK_LED(pAC, IoC, Para.Para32[0], SK_LED_STANDBY);
2302 }
2303
2304 for (i = 0; i < pRPort->Net->NumPorts; i++) {
2305 if (!pRPort->Net->Port[i]->PortStarted) {
2306 SkRlmtPortStart(pAC, IoC, pRPort->Net->Port[i]->PortNumber);
2307 }
2308 }
2309
2310 SkRlmtCheckSwitch(pAC, IoC, pRPort->Net->NetNumber);
2311
2312 if (pRPort->Net->LinksUp >= 2) {
2313 if (pRPort->Net->RlmtMode & SK_RLMT_CHECK_LOC_LINK) {
2314 /* Build the check chain. */
2315 SkRlmtBuildCheckChain(pAC, pRPort->Net->NetNumber);
2316 }
2317 }
2318
2319 /* If the first link comes up, start the periodical RLMT timeout. */
2320 if (pRPort->Net->NumPorts > 1 && pRPort->Net->LinksUp == 1 &&
2321 (pRPort->Net->RlmtMode & SK_RLMT_CHECK_OTHERS) != 0) {
2322 Para2.Para32[0] = pRPort->Net->NetNumber;
2323 Para2.Para32[1] = (SK_U32)-1;
2324 SkTimerStart(pAC, IoC, &pRPort->Net->LocTimer,
2325 pRPort->Net->TimeoutValue, SKGE_RLMT, SK_RLMT_TIM, Para2);
2326 }
2327
2328 Para2 = Para;
2329 Para2.Para32[1] = (SK_U32)-1;
2330 SkTimerStart(pAC, IoC, &pRPort->UpTimer, SK_RLMT_PORTUP_TIM_VAL,
2331 SKGE_RLMT, SK_RLMT_PORTUP_TIM, Para2);
wdenk42d1f032003-10-15 23:53:47 +00002332
wdenk7152b1d2003-09-05 23:19:14 +00002333 /* Later: if (pAC->Rlmt.RlmtMode & SK_RLMT_CHECK_LOC_LINK) && */
2334 if ((pRPort->Net->RlmtMode & SK_RLMT_TRANSPARENT) == 0 &&
2335 (pRPort->Net->RlmtMode & SK_RLMT_CHECK_LINK) != 0 &&
2336 (Para2.pParaPtr =
2337 SkRlmtBuildPacket(pAC, IoC, Para.Para32[0], SK_PACKET_ANNOUNCE,
2338 &pAC->Addr.Port[Para.Para32[0]].CurrentMacAddress, &SkRlmtMcAddr)
2339 ) != NULL) {
2340 /* Send "new" packet to RLMT multicast address. */
2341 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para2);
2342 }
2343
2344 if (pRPort->Net->RlmtMode & SK_RLMT_CHECK_SEG) {
2345 if ((Para2.pParaPtr =
2346 SkRlmtBuildSpanningTreePacket(pAC, IoC, Para.Para32[0])) != NULL) {
2347 pAC->Rlmt.Port[Para.Para32[0]].RootIdSet = SK_FALSE;
2348 pRPort->Net->CheckingState |=
2349 SK_RLMT_RCS_SEG | SK_RLMT_RCS_REPORT_SEG;
2350
2351 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para2);
2352
2353 Para.Para32[1] = (SK_U32)-1;
2354 SkTimerStart(pAC, IoC, &pRPort->Net->SegTimer,
2355 SK_RLMT_SEG_TO_VAL, SKGE_RLMT, SK_RLMT_SEG_TIM, Para);
2356 }
2357 }
2358
2359 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2360 ("SK_RLMT_LINK_UP Event END.\n"))
2361} /* SkRlmtEvtLinkUp */
2362
2363
2364/******************************************************************************
2365 *
2366 * SkRlmtEvtPortUpTim - PORT_UP_TIM
2367 *
2368 * Description:
2369 * This routine handles PORT_UP_TIM events.
2370 *
2371 * Context:
2372 * runtime, pageable?
2373 * may be called after SK_INIT_IO
2374 *
2375 * Returns:
2376 * Nothing
2377 */
2378RLMT_STATIC void SkRlmtEvtPortUpTim(
2379SK_AC *pAC, /* Adapter Context */
2380SK_IOC IoC, /* I/O Context */
2381SK_EVPARA Para) /* SK_U32 PortNumber; SK_U32 -1 */
2382{
2383 SK_RLMT_PORT *pRPort;
2384
2385 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2386 ("SK_RLMT_PORTUP_TIM Port %d Event BEGIN.\n", Para.Para32[0]))
2387
2388 if (Para.Para32[1] != (SK_U32)-1) {
2389 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2390 ("Bad Parameter.\n"))
2391 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2392 ("SK_RLMT_PORTUP_TIM Event EMPTY.\n"))
2393 return;
2394 }
2395
2396 pRPort = &pAC->Rlmt.Port[Para.Para32[0]];
2397 if (pRPort->LinkDown || (pRPort->PortState == SK_RLMT_PS_UP)) {
2398 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2399 ("SK_RLMT_PORTUP_TIM Port %d Event EMPTY.\n", Para.Para32[0]))
2400 return;
2401 }
2402
2403 pRPort->PortDown = SK_FALSE;
2404 pRPort->PortState = SK_RLMT_PS_UP;
2405 pRPort->Net->PortsUp++;
2406 if (pRPort->Net->RlmtState != SK_RLMT_RS_INIT) {
2407 if (pAC->Rlmt.NumNets <= 1) {
2408 SkRlmtCheckSwitch(pAC, IoC, pRPort->Net->NetNumber);
2409 }
2410 SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_PORT_UP, Para);
2411 }
2412
2413 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2414 ("SK_RLMT_PORTUP_TIM Event END.\n"))
2415} /* SkRlmtEvtPortUpTim */
2416
2417
2418/******************************************************************************
2419 *
2420 * SkRlmtEvtPortDownTim - PORT_DOWN_*
2421 *
2422 * Description:
2423 * This routine handles PORT_DOWN_* events.
2424 *
2425 * Context:
2426 * runtime, pageable?
2427 * may be called after SK_INIT_IO
2428 *
2429 * Returns:
2430 * Nothing
2431 */
2432RLMT_STATIC void SkRlmtEvtPortDownX(
2433SK_AC *pAC, /* Adapter Context */
2434SK_IOC IoC, /* I/O Context */
2435SK_U32 Event, /* Event code */
2436SK_EVPARA Para) /* SK_U32 PortNumber; SK_U32 -1 */
2437{
2438 SK_RLMT_PORT *pRPort;
2439
2440 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2441 ("SK_RLMT_PORTDOWN* Port %d Event (%d) BEGIN.\n",
2442 Para.Para32[0], Event))
2443
2444 if (Para.Para32[1] != (SK_U32)-1) {
2445 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2446 ("Bad Parameter.\n"))
2447 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2448 ("SK_RLMT_PORTDOWN* Event EMPTY.\n"))
2449 return;
2450 }
2451
2452 pRPort = &pAC->Rlmt.Port[Para.Para32[0]];
2453 if (!pRPort->PortStarted || (Event == SK_RLMT_PORTDOWN_TX_TIM &&
2454 !(pRPort->CheckingState & SK_RLMT_PCS_TX))) {
2455 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2456 ("SK_RLMT_PORTDOWN* Event (%d) EMPTY.\n", Event))
2457 return;
2458 }
wdenk42d1f032003-10-15 23:53:47 +00002459
wdenk7152b1d2003-09-05 23:19:14 +00002460 /* Stop port's timers. */
2461 SkTimerStop(pAC, IoC, &pRPort->UpTimer);
2462 SkTimerStop(pAC, IoC, &pRPort->DownRxTimer);
2463 SkTimerStop(pAC, IoC, &pRPort->DownTxTimer);
2464
2465 if (pRPort->PortState != SK_RLMT_PS_LINK_DOWN) {
2466 pRPort->PortState = SK_RLMT_PS_DOWN;
2467 }
2468
2469 if (!pRPort->PortDown) {
2470 pRPort->Net->PortsUp--;
2471 pRPort->PortDown = SK_TRUE;
2472 SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_PORT_DOWN, Para);
2473 }
2474
2475 pRPort->PacketsPerTimeSlot = 0;
2476 /* pRPort->DataPacketsPerTimeSlot = 0; */
2477 pRPort->BpduPacketsPerTimeSlot = 0;
2478 pRPort->BcTimeStamp = 0;
2479
2480 /*
2481 * RA;:;: To be checked:
2482 * - actions at RLMT_STOP: We should not switch anymore.
2483 */
2484 if (pRPort->Net->RlmtState != SK_RLMT_RS_INIT) {
2485 if (Para.Para32[0] ==
2486 pRPort->Net->Port[pRPort->Net->ActivePort]->PortNumber) {
2487 /* Active Port went down. */
2488 SkRlmtCheckSwitch(pAC, IoC, pRPort->Net->NetNumber);
2489 }
2490 }
2491
2492 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2493 ("SK_RLMT_PORTDOWN* Event (%d) END.\n", Event))
2494} /* SkRlmtEvtPortDownX */
2495
2496
2497/******************************************************************************
2498 *
2499 * SkRlmtEvtLinkDown - LINK_DOWN
2500 *
2501 * Description:
2502 * This routine handles LINK_DOWN events.
2503 *
2504 * Context:
2505 * runtime, pageable?
2506 * may be called after SK_INIT_IO
2507 *
2508 * Returns:
2509 * Nothing
2510 */
2511RLMT_STATIC void SkRlmtEvtLinkDown(
2512SK_AC *pAC, /* Adapter Context */
2513SK_IOC IoC, /* I/O Context */
2514SK_EVPARA Para) /* SK_U32 PortNumber; SK_U32 Undefined */
2515{
2516 SK_RLMT_PORT *pRPort;
2517
2518 pRPort = &pAC->Rlmt.Port[Para.Para32[0]];
2519 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2520 ("SK_RLMT_LINK_DOWN Port %d Event BEGIN.\n", Para.Para32[0]))
2521
2522 if (!pAC->Rlmt.Port[Para.Para32[0]].LinkDown) {
2523 pRPort->Net->LinksUp--;
2524 pRPort->LinkDown = SK_TRUE;
2525 pRPort->PortState = SK_RLMT_PS_LINK_DOWN;
2526 SK_HWAC_LINK_LED(pAC, IoC, Para.Para32[0], SK_LED_OFF);
2527
2528 if ((pRPort->Net->RlmtMode & SK_RLMT_CHECK_LOC_LINK) != 0) {
2529 /* Build the check chain. */
2530 SkRlmtBuildCheckChain(pAC, pRPort->Net->NetNumber);
2531 }
2532
2533 /* Ensure that port is marked down. */
2534 Para.Para32[1] = -1;
2535 (void)SkRlmtEvent(pAC, IoC, SK_RLMT_PORTDOWN, Para);
2536 }
2537
2538 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2539 ("SK_RLMT_LINK_DOWN Event END.\n"))
2540} /* SkRlmtEvtLinkDown */
2541
2542
2543/******************************************************************************
2544 *
2545 * SkRlmtEvtPortAddr - PORT_ADDR
2546 *
2547 * Description:
2548 * This routine handles PORT_ADDR events.
2549 *
2550 * Context:
2551 * runtime, pageable?
2552 * may be called after SK_INIT_IO
2553 *
2554 * Returns:
2555 * Nothing
2556 */
2557RLMT_STATIC void SkRlmtEvtPortAddr(
2558SK_AC *pAC, /* Adapter Context */
2559SK_IOC IoC, /* I/O Context */
2560SK_EVPARA Para) /* SK_U32 PortNumber; SK_U32 -1 */
2561{
2562 SK_U32 i, j;
2563 SK_RLMT_PORT *pRPort;
2564 SK_MAC_ADDR *pOldMacAddr;
2565 SK_MAC_ADDR *pNewMacAddr;
2566
2567 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2568 ("SK_RLMT_PORT_ADDR Port %d Event BEGIN.\n", Para.Para32[0]))
2569
2570 if (Para.Para32[1] != (SK_U32)-1) {
2571 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2572 ("Bad Parameter.\n"))
2573 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2574 ("SK_RLMT_PORT_ADDR Event EMPTY.\n"))
2575 return;
2576 }
2577
2578 /* Port's physical MAC address changed. */
2579 pOldMacAddr = &pAC->Addr.Port[Para.Para32[0]].PreviousMacAddress;
2580 pNewMacAddr = &pAC->Addr.Port[Para.Para32[0]].CurrentMacAddress;
2581
2582 /*
2583 * NOTE: This is not scalable for solutions where ports are
2584 * checked remotely. There, we need to send an RLMT
2585 * address change packet - and how do we ensure delivery?
2586 */
2587 for (i = 0; i < (SK_U32)pAC->GIni.GIMacsFound; i++) {
2588 pRPort = &pAC->Rlmt.Port[i];
2589 for (j = 0; j < pRPort->PortsChecked; j++) {
2590 if (SK_ADDR_EQUAL(
2591 pRPort->PortCheck[j].CheckAddr.a, pOldMacAddr->a)) {
2592 pRPort->PortCheck[j].CheckAddr = *pNewMacAddr;
2593 }
2594 }
2595 }
2596
2597 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2598 ("SK_RLMT_PORT_ADDR Event END.\n"))
2599} /* SkRlmtEvtPortAddr */
2600
2601
2602/******************************************************************************
2603 *
2604 * SkRlmtEvtStart - START
2605 *
2606 * Description:
2607 * This routine handles START events.
2608 *
2609 * Context:
2610 * runtime, pageable?
2611 * may be called after SK_INIT_IO
2612 *
2613 * Returns:
2614 * Nothing
2615 */
2616RLMT_STATIC void SkRlmtEvtStart(
2617SK_AC *pAC, /* Adapter Context */
2618SK_IOC IoC, /* I/O Context */
2619SK_EVPARA Para) /* SK_U32 NetNumber; SK_U32 -1 */
2620{
2621 SK_EVPARA Para2;
2622 SK_U32 PortIdx;
2623 SK_U32 PortNumber;
2624
2625 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2626 ("SK_RLMT_START Net %d Event BEGIN.\n", Para.Para32[0]))
2627
2628 if (Para.Para32[1] != (SK_U32)-1) {
2629 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2630 ("Bad Parameter.\n"))
2631 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2632 ("SK_RLMT_START Event EMPTY.\n"))
2633 return;
2634 }
2635
2636 if (Para.Para32[0] >= pAC->Rlmt.NumNets) {
2637 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2638 ("Bad NetNumber %d.\n", Para.Para32[0]))
2639 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2640 ("SK_RLMT_START Event EMPTY.\n"))
2641 return;
2642 }
2643
2644 if (pAC->Rlmt.Net[Para.Para32[0]].RlmtState != SK_RLMT_RS_INIT) {
2645 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2646 ("SK_RLMT_START Event EMPTY.\n"))
2647 return;
2648 }
2649
2650 if (pAC->Rlmt.NetsStarted >= pAC->Rlmt.NumNets) {
2651 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2652 ("All nets should have been started.\n"))
2653 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2654 ("SK_RLMT_START Event EMPTY.\n"))
2655 return;
2656 }
2657
2658 if (pAC->Rlmt.Net[Para.Para32[0]].PrefPort >=
2659 pAC->Rlmt.Net[Para.Para32[0]].NumPorts) {
2660 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_RLMT_E009, SKERR_RLMT_E009_MSG);
2661
2662 /* Change PrefPort to internal default. */
2663 Para2.Para32[0] = 0xFFFFFFFF;
2664 Para2.Para32[1] = Para.Para32[0];
2665 (void)SkRlmtEvent(pAC, IoC, SK_RLMT_PREFPORT_CHANGE, Para2);
2666 }
2667
2668 PortIdx = pAC->Rlmt.Net[Para.Para32[0]].PrefPort;
2669 PortNumber = pAC->Rlmt.Net[Para.Para32[0]].Port[PortIdx]->PortNumber;
2670
2671 pAC->Rlmt.Net[Para.Para32[0]].LinksUp = 0;
2672 pAC->Rlmt.Net[Para.Para32[0]].PortsUp = 0;
2673 pAC->Rlmt.Net[Para.Para32[0]].CheckingState = 0;
2674 pAC->Rlmt.Net[Para.Para32[0]].RlmtState = SK_RLMT_RS_NET_DOWN;
2675
2676 /* Start preferred port. */
2677 SkRlmtPortStart(pAC, IoC, PortNumber);
2678
2679 /* Start Timer (for first port only). */
2680 Para2.Para32[0] = PortNumber;
2681 Para2.Para32[1] = (SK_U32)-1;
2682 SkTimerStart(pAC, IoC, &pAC->Rlmt.Port[PortNumber].UpTimer,
2683 SK_RLMT_PORTSTART_TIM_VAL, SKGE_RLMT, SK_RLMT_PORTSTART_TIM, Para2);
2684
2685 pAC->Rlmt.NetsStarted++;
2686
2687 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2688 ("SK_RLMT_START Event END.\n"))
2689} /* SkRlmtEvtStart */
2690
2691
2692/******************************************************************************
2693 *
2694 * SkRlmtEvtStop - STOP
2695 *
2696 * Description:
2697 * This routine handles STOP events.
2698 *
2699 * Context:
2700 * runtime, pageable?
2701 * may be called after SK_INIT_IO
2702 *
2703 * Returns:
2704 * Nothing
2705 */
2706RLMT_STATIC void SkRlmtEvtStop(
2707SK_AC *pAC, /* Adapter Context */
2708SK_IOC IoC, /* I/O Context */
2709SK_EVPARA Para) /* SK_U32 NetNumber; SK_U32 -1 */
2710{
2711 SK_EVPARA Para2;
2712 SK_U32 PortNumber;
2713 SK_U32 i;
2714
2715 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2716 ("SK_RLMT_STOP Net %d Event BEGIN.\n", Para.Para32[0]))
2717
2718 if (Para.Para32[1] != (SK_U32)-1) {
2719 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2720 ("Bad Parameter.\n"))
2721 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2722 ("SK_RLMT_STOP Event EMPTY.\n"))
2723 return;
2724 }
2725
2726 if (Para.Para32[0] >= pAC->Rlmt.NumNets) {
2727 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2728 ("Bad NetNumber %d.\n", Para.Para32[0]))
2729 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2730 ("SK_RLMT_STOP Event EMPTY.\n"))
2731 return;
2732 }
2733
2734 if (pAC->Rlmt.Net[Para.Para32[0]].RlmtState == SK_RLMT_RS_INIT) {
2735 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2736 ("SK_RLMT_STOP Event EMPTY.\n"))
2737 return;
2738 }
2739
2740 if (pAC->Rlmt.NetsStarted == 0) {
2741 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2742 ("All nets are stopped.\n"))
2743 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2744 ("SK_RLMT_STOP Event EMPTY.\n"))
2745 return;
2746 }
2747
2748 /* Stop RLMT timers. */
2749 SkTimerStop(pAC, IoC, &pAC->Rlmt.Net[Para.Para32[0]].LocTimer);
2750 SkTimerStop(pAC, IoC, &pAC->Rlmt.Net[Para.Para32[0]].SegTimer);
2751
2752 /* Stop net. */
2753 pAC->Rlmt.Net[Para.Para32[0]].RlmtState = SK_RLMT_RS_INIT;
2754 pAC->Rlmt.Net[Para.Para32[0]].RootIdSet = SK_FALSE;
2755 Para2.Para32[0] = SK_RLMT_NET_DOWN_FINAL;
2756 Para2.Para32[1] = Para.Para32[0]; /* Net# */
2757 SkEventQueue(pAC, SKGE_DRV, SK_DRV_NET_DOWN, Para2);
2758
2759 /* Stop ports. */
2760 for (i = 0; i < pAC->Rlmt.Net[Para.Para32[0]].NumPorts; i++) {
2761 PortNumber = pAC->Rlmt.Net[Para.Para32[0]].Port[i]->PortNumber;
2762 if (pAC->Rlmt.Port[PortNumber].PortState != SK_RLMT_PS_INIT) {
2763 SkTimerStop(pAC, IoC, &pAC->Rlmt.Port[PortNumber].UpTimer);
2764 SkTimerStop(pAC, IoC, &pAC->Rlmt.Port[PortNumber].DownRxTimer);
2765 SkTimerStop(pAC, IoC, &pAC->Rlmt.Port[PortNumber].DownTxTimer);
2766
2767 pAC->Rlmt.Port[PortNumber].PortState = SK_RLMT_PS_INIT;
2768 pAC->Rlmt.Port[PortNumber].RootIdSet = SK_FALSE;
2769 pAC->Rlmt.Port[PortNumber].PortStarted = SK_FALSE;
2770 Para2.Para32[0] = PortNumber;
2771 Para2.Para32[1] = (SK_U32)-1;
2772 SkEventQueue(pAC, SKGE_HWAC, SK_HWEV_PORT_STOP, Para2);
2773 }
2774 }
2775
2776 pAC->Rlmt.NetsStarted--;
2777
2778 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2779 ("SK_RLMT_STOP Event END.\n"))
2780} /* SkRlmtEvtStop */
2781
2782
2783/******************************************************************************
2784 *
2785 * SkRlmtEvtTim - TIM
2786 *
2787 * Description:
2788 * This routine handles TIM events.
2789 *
2790 * Context:
2791 * runtime, pageable?
2792 * may be called after SK_INIT_IO
2793 *
2794 * Returns:
2795 * Nothing
2796 */
2797RLMT_STATIC void SkRlmtEvtTim(
2798SK_AC *pAC, /* Adapter Context */
2799SK_IOC IoC, /* I/O Context */
2800SK_EVPARA Para) /* SK_U32 NetNumber; SK_U32 -1 */
2801{
2802 SK_RLMT_PORT *pRPort;
2803 SK_U32 Timeout;
2804 SK_U32 NewTimeout;
2805 SK_U32 PortNumber;
2806 SK_U32 i;
2807
2808 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2809 ("SK_RLMT_TIM Event BEGIN.\n"))
2810
2811 if (Para.Para32[1] != (SK_U32)-1) {
2812 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2813 ("Bad Parameter.\n"))
2814 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2815 ("SK_RLMT_TIM Event EMPTY.\n"))
2816 return;
2817 }
2818
2819 if ((pAC->Rlmt.Net[Para.Para32[0]].RlmtMode & SK_RLMT_CHECK_OTHERS) == 0 ||
2820 pAC->Rlmt.Net[Para.Para32[0]].LinksUp == 0) {
2821 /* Mode changed or all links down: No more link checking. */
2822 return;
2823 }
2824
2825#if 0
2826 pAC->Rlmt.SwitchCheckCounter--;
2827 if (pAC->Rlmt.SwitchCheckCounter == 0) {
2828 pAC->Rlmt.SwitchCheckCounter;
2829 }
2830#endif /* 0 */
2831
2832 NewTimeout = SK_RLMT_DEF_TO_VAL;
2833 for (i = 0; i < pAC->Rlmt.Net[Para.Para32[0]].NumPorts; i++) {
2834 PortNumber = pAC->Rlmt.Net[Para.Para32[0]].Port[i]->PortNumber;
2835 pRPort = &pAC->Rlmt.Port[PortNumber];
2836 if (!pRPort->LinkDown) {
2837 Timeout = SkRlmtCheckPort(pAC, IoC, PortNumber);
2838 if (Timeout < NewTimeout) {
2839 NewTimeout = Timeout;
2840 }
2841
2842 /*
2843 * These counters should be set to 0 for all ports before the
2844 * first frame is sent in the next loop.
2845 */
2846 pRPort->PacketsPerTimeSlot = 0;
2847 /* pRPort->DataPacketsPerTimeSlot = 0; */
2848 pRPort->BpduPacketsPerTimeSlot = 0;
2849 }
2850 }
2851 pAC->Rlmt.Net[Para.Para32[0]].TimeoutValue = NewTimeout;
2852
2853 if (pAC->Rlmt.Net[Para.Para32[0]].LinksUp > 1) {
2854 /*
2855 * If checking remote ports, also send packets if
2856 * (LinksUp == 1) &&
2857 * this port checks at least one (remote) port.
2858 */
2859
2860 /*
2861 * Must be new loop, as SkRlmtCheckPort can request to
2862 * check segmentation when e.g. checking the last port.
2863 */
2864 for (i = 0; i < pAC->Rlmt.Net[Para.Para32[0]].NumPorts; i++) {
2865 if (!pAC->Rlmt.Net[Para.Para32[0]].Port[i]->LinkDown) {
2866 SkRlmtSend(pAC, IoC,
2867 pAC->Rlmt.Net[Para.Para32[0]].Port[i]->PortNumber);
2868 }
2869 }
2870 }
2871
2872 SkTimerStart(pAC, IoC, &pAC->Rlmt.Net[Para.Para32[0]].LocTimer,
2873 pAC->Rlmt.Net[Para.Para32[0]].TimeoutValue, SKGE_RLMT, SK_RLMT_TIM,
2874 Para);
2875
2876 if (pAC->Rlmt.Net[Para.Para32[0]].LinksUp > 1 &&
2877 (pAC->Rlmt.Net[Para.Para32[0]].RlmtMode & SK_RLMT_CHECK_SEG) &&
2878 (pAC->Rlmt.Net[Para.Para32[0]].CheckingState & SK_RLMT_RCS_START_SEG)) {
2879 SkTimerStart(pAC, IoC, &pAC->Rlmt.Net[Para.Para32[0]].SegTimer,
2880 SK_RLMT_SEG_TO_VAL, SKGE_RLMT, SK_RLMT_SEG_TIM, Para);
2881 pAC->Rlmt.Net[Para.Para32[0]].CheckingState &= ~SK_RLMT_RCS_START_SEG;
2882 pAC->Rlmt.Net[Para.Para32[0]].CheckingState |=
2883 SK_RLMT_RCS_SEG | SK_RLMT_RCS_REPORT_SEG;
2884 }
2885
2886 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2887 ("SK_RLMT_TIM Event END.\n"))
2888} /* SkRlmtEvtTim */
2889
2890
2891/******************************************************************************
2892 *
2893 * SkRlmtEvtSegTim - SEG_TIM
2894 *
2895 * Description:
2896 * This routine handles SEG_TIM events.
2897 *
2898 * Context:
2899 * runtime, pageable?
2900 * may be called after SK_INIT_IO
2901 *
2902 * Returns:
2903 * Nothing
2904 */
2905RLMT_STATIC void SkRlmtEvtSegTim(
2906SK_AC *pAC, /* Adapter Context */
2907SK_IOC IoC, /* I/O Context */
2908SK_EVPARA Para) /* SK_U32 NetNumber; SK_U32 -1 */
2909{
2910#ifdef xDEBUG
2911 int j;
2912#endif /* DEBUG */
2913
2914 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2915 ("SK_RLMT_SEG_TIM Event BEGIN.\n"))
2916
2917 if (Para.Para32[1] != (SK_U32)-1) {
2918 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2919 ("Bad Parameter.\n"))
2920 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2921 ("SK_RLMT_SEG_TIM Event EMPTY.\n"))
2922 return;
2923 }
2924
2925#ifdef xDEBUG
2926 for (j = 0; j < pAC->Rlmt.Net[Para.Para32[0]].NumPorts; j++) {
2927 SK_ADDR_PORT *pAPort;
2928 SK_U32 k;
2929 SK_U16 *InAddr;
2930 SK_U8 InAddr8[6];
2931
2932 InAddr = (SK_U16 *)&InAddr8[0];
2933 pAPort = pAC->Rlmt.Net[Para.Para32[0]].Port[j]->AddrPort;
2934 for (k = 0; k < pAPort->NextExactMatchRlmt; k++) {
2935 /* Get exact match address k from port j. */
2936 XM_INADDR(IoC, pAC->Rlmt.Net[Para.Para32[0]].Port[j]->PortNumber,
2937 XM_EXM(k), InAddr);
2938 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2939 ("MC address %d on Port %u: %02x %02x %02x %02x %02x %02x -- %02x %02x %02x %02x %02x %02x.\n",
2940 k, pAC->Rlmt.Net[Para.Para32[0]].Port[j]->PortNumber,
2941 InAddr8[0], InAddr8[1], InAddr8[2],
2942 InAddr8[3], InAddr8[4], InAddr8[5],
2943 pAPort->Exact[k].a[0], pAPort->Exact[k].a[1],
2944 pAPort->Exact[k].a[2], pAPort->Exact[k].a[3],
2945 pAPort->Exact[k].a[4], pAPort->Exact[k].a[5]))
2946 }
2947 }
2948#endif /* xDEBUG */
wdenk42d1f032003-10-15 23:53:47 +00002949
wdenk7152b1d2003-09-05 23:19:14 +00002950 SkRlmtCheckSeg(pAC, IoC, Para.Para32[0]);
2951
2952 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2953 ("SK_RLMT_SEG_TIM Event END.\n"))
2954} /* SkRlmtEvtSegTim */
2955
2956
2957/******************************************************************************
2958 *
2959 * SkRlmtEvtPacketRx - PACKET_RECEIVED
2960 *
2961 * Description:
2962 * This routine handles PACKET_RECEIVED events.
2963 *
2964 * Context:
2965 * runtime, pageable?
2966 * may be called after SK_INIT_IO
2967 *
2968 * Returns:
2969 * Nothing
2970 */
2971RLMT_STATIC void SkRlmtEvtPacketRx(
2972SK_AC *pAC, /* Adapter Context */
2973SK_IOC IoC, /* I/O Context */
2974SK_EVPARA Para) /* SK_MBUF *pMb */
2975{
2976 SK_MBUF *pMb;
2977 SK_MBUF *pNextMb;
2978 SK_U32 NetNumber;
2979
wdenk42d1f032003-10-15 23:53:47 +00002980
wdenk7152b1d2003-09-05 23:19:14 +00002981 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2982 ("SK_RLMT_PACKET_RECEIVED Event BEGIN.\n"))
2983
2984 /* Should we ignore frames during port switching? */
2985
2986#ifdef DEBUG
2987 pMb = Para.pParaPtr;
2988 if (pMb == NULL) {
2989 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL, ("No mbuf.\n"))
2990 }
2991 else if (pMb->pNext != NULL) {
2992 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
2993 ("More than one mbuf or pMb->pNext not set.\n"))
2994 }
2995#endif /* DEBUG */
2996
2997 for (pMb = Para.pParaPtr; pMb != NULL; pMb = pNextMb) {
2998 pNextMb = pMb->pNext;
2999 pMb->pNext = NULL;
3000
3001 NetNumber = pAC->Rlmt.Port[pMb->PortIdx].Net->NetNumber;
3002 if (pAC->Rlmt.Net[NetNumber].RlmtState == SK_RLMT_RS_INIT) {
3003 SkDrvFreeRlmtMbuf(pAC, IoC, pMb);
3004 }
3005 else {
3006 SkRlmtPacketReceive(pAC, IoC, pMb);
3007 }
3008 }
3009
3010 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3011 ("SK_RLMT_PACKET_RECEIVED Event END.\n"))
3012} /* SkRlmtEvtPacketRx */
3013
3014
3015/******************************************************************************
3016 *
3017 * SkRlmtEvtStatsClear - STATS_CLEAR
3018 *
3019 * Description:
3020 * This routine handles STATS_CLEAR events.
3021 *
3022 * Context:
3023 * runtime, pageable?
3024 * may be called after SK_INIT_IO
3025 *
3026 * Returns:
3027 * Nothing
3028 */
3029RLMT_STATIC void SkRlmtEvtStatsClear(
3030SK_AC *pAC, /* Adapter Context */
3031SK_IOC IoC, /* I/O Context */
3032SK_EVPARA Para) /* SK_U32 NetNumber; SK_U32 -1 */
3033{
3034 SK_U32 i;
3035 SK_RLMT_PORT *pRPort;
3036
3037 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3038 ("SK_RLMT_STATS_CLEAR Event BEGIN.\n"))
3039
3040 if (Para.Para32[1] != (SK_U32)-1) {
3041 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3042 ("Bad Parameter.\n"))
3043 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3044 ("SK_RLMT_STATS_CLEAR Event EMPTY.\n"))
3045 return;
3046 }
3047
3048 if (Para.Para32[0] >= pAC->Rlmt.NumNets) {
3049 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3050 ("Bad NetNumber %d.\n", Para.Para32[0]))
3051 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3052 ("SK_RLMT_STATS_CLEAR Event EMPTY.\n"))
3053 return;
3054 }
3055
3056 /* Clear statistics for logical and physical ports. */
3057 for (i = 0; i < pAC->Rlmt.Net[Para.Para32[0]].NumPorts; i++) {
3058 pRPort =
3059 &pAC->Rlmt.Port[pAC->Rlmt.Net[Para.Para32[0]].Port[i]->PortNumber];
3060 pRPort->TxHelloCts = 0;
3061 pRPort->RxHelloCts = 0;
3062 pRPort->TxSpHelloReqCts = 0;
3063 pRPort->RxSpHelloCts = 0;
3064 }
3065
3066 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3067 ("SK_RLMT_STATS_CLEAR Event END.\n"))
3068} /* SkRlmtEvtStatsClear */
3069
3070
3071/******************************************************************************
3072 *
3073 * SkRlmtEvtStatsUpdate - STATS_UPDATE
3074 *
3075 * Description:
3076 * This routine handles STATS_UPDATE events.
3077 *
3078 * Context:
3079 * runtime, pageable?
3080 * may be called after SK_INIT_IO
3081 *
3082 * Returns:
3083 * Nothing
3084 */
3085RLMT_STATIC void SkRlmtEvtStatsUpdate(
3086SK_AC *pAC, /* Adapter Context */
3087SK_IOC IoC, /* I/O Context */
3088SK_EVPARA Para) /* SK_U32 NetNumber; SK_U32 -1 */
3089{
3090 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3091 ("SK_RLMT_STATS_UPDATE Event BEGIN.\n"))
3092
3093 if (Para.Para32[1] != (SK_U32)-1) {
3094 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3095 ("Bad Parameter.\n"))
3096 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3097 ("SK_RLMT_STATS_UPDATE Event EMPTY.\n"))
3098 return;
3099 }
3100
3101 if (Para.Para32[0] >= pAC->Rlmt.NumNets) {
3102 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3103 ("Bad NetNumber %d.\n", Para.Para32[0]))
3104 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3105 ("SK_RLMT_STATS_UPDATE Event EMPTY.\n"))
3106 return;
3107 }
3108
3109 /* Update statistics - currently always up-to-date. */
3110
3111 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3112 ("SK_RLMT_STATS_UPDATE Event END.\n"))
3113} /* SkRlmtEvtStatsUpdate */
3114
3115
3116/******************************************************************************
3117 *
3118 * SkRlmtEvtPrefportChange - PREFPORT_CHANGE
3119 *
3120 * Description:
3121 * This routine handles PREFPORT_CHANGE events.
3122 *
3123 * Context:
3124 * runtime, pageable?
3125 * may be called after SK_INIT_IO
3126 *
3127 * Returns:
3128 * Nothing
3129 */
3130RLMT_STATIC void SkRlmtEvtPrefportChange(
3131SK_AC *pAC, /* Adapter Context */
3132SK_IOC IoC, /* I/O Context */
3133SK_EVPARA Para) /* SK_U32 PortIndex; SK_U32 NetNumber */
3134{
3135 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3136 ("SK_RLMT_PREFPORT_CHANGE to Port %d Event BEGIN.\n", Para.Para32[0]))
3137
3138 if (Para.Para32[1] >= pAC->Rlmt.NumNets) {
3139 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3140 ("Bad NetNumber %d.\n", Para.Para32[1]))
3141 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3142 ("SK_RLMT_PREFPORT_CHANGE Event EMPTY.\n"))
3143 return;
3144 }
3145
3146 /* 0xFFFFFFFF == auto-mode. */
3147 if (Para.Para32[0] == 0xFFFFFFFF) {
3148 pAC->Rlmt.Net[Para.Para32[1]].PrefPort = SK_RLMT_DEF_PREF_PORT;
3149 }
3150 else {
3151 if (Para.Para32[0] >= pAC->Rlmt.Net[Para.Para32[1]].NumPorts) {
3152 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_RLMT_E010, SKERR_RLMT_E010_MSG);
3153
3154 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3155 ("SK_RLMT_PREFPORT_CHANGE Event EMPTY.\n"))
3156 return;
3157 }
3158
3159 pAC->Rlmt.Net[Para.Para32[1]].PrefPort = Para.Para32[0];
3160 }
3161
3162 pAC->Rlmt.Net[Para.Para32[1]].Preference = Para.Para32[0];
3163
3164 if (pAC->Rlmt.Net[Para.Para32[1]].RlmtState != SK_RLMT_RS_INIT) {
3165 SkRlmtCheckSwitch(pAC, IoC, Para.Para32[1]);
3166 }
3167
3168 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3169 ("SK_RLMT_PREFPORT_CHANGE Event END.\n"))
3170} /* SkRlmtEvtPrefportChange */
3171
3172
3173/******************************************************************************
3174 *
3175 * SkRlmtEvtSetNets - SET_NETS
3176 *
3177 * Description:
3178 * This routine handles SET_NETS events.
3179 *
3180 * Context:
3181 * runtime, pageable?
3182 * may be called after SK_INIT_IO
3183 *
3184 * Returns:
3185 * Nothing
3186 */
3187RLMT_STATIC void SkRlmtEvtSetNets(
3188SK_AC *pAC, /* Adapter Context */
3189SK_IOC IoC, /* I/O Context */
3190SK_EVPARA Para) /* SK_U32 NumNets; SK_U32 -1 */
3191{
3192 int i;
3193
3194 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3195 ("SK_RLMT_SET_NETS Event BEGIN.\n"))
3196
3197 if (Para.Para32[1] != (SK_U32)-1) {
3198 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3199 ("Bad Parameter.\n"))
3200 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3201 ("SK_RLMT_SET_NETS Event EMPTY.\n"))
3202 return;
3203 }
3204
3205 if (Para.Para32[0] == 0 || Para.Para32[0] > SK_MAX_NETS ||
3206 Para.Para32[0] > (SK_U32)pAC->GIni.GIMacsFound) {
3207 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3208 ("Bad number of nets: %d.\n", Para.Para32[0]))
3209 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3210 ("SK_RLMT_SET_NETS Event EMPTY.\n"))
3211 return;
3212 }
3213
3214 if (Para.Para32[0] == pAC->Rlmt.NumNets) { /* No change. */
3215 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3216 ("SK_RLMT_SET_NETS Event EMPTY.\n"))
3217 return;
3218 }
3219
3220 /* Entering and leaving dual mode only allowed while nets are stopped. */
3221 if (pAC->Rlmt.NetsStarted > 0) {
3222 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3223 ("Changing dual mode only allowed while all nets are stopped.\n"))
3224 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3225 ("SK_RLMT_SET_NETS Event EMPTY.\n"))
3226 return;
3227 }
3228
3229 if (Para.Para32[0] == 1) {
3230 if (pAC->Rlmt.NumNets > 1) {
3231 /* Clear logical MAC addr from second net's active port. */
3232 (void)SkAddrOverride(pAC, IoC, pAC->Rlmt.Net[1].Port[pAC->Addr.
3233 Net[1].ActivePort]->PortNumber, NULL, SK_ADDR_CLEAR_LOGICAL);
3234 pAC->Rlmt.Net[1].NumPorts = 0;
3235 }
3236
3237 pAC->Rlmt.NumNets = Para.Para32[0];
3238 for (i = 0; (SK_U32)i < pAC->Rlmt.NumNets; i++) {
3239 pAC->Rlmt.Net[i].RlmtState = SK_RLMT_RS_INIT;
3240 pAC->Rlmt.Net[i].RootIdSet = SK_FALSE;
3241 pAC->Rlmt.Net[i].Preference = 0xFFFFFFFF; /* "Automatic" */
3242 pAC->Rlmt.Net[i].PrefPort = SK_RLMT_DEF_PREF_PORT;
3243 /* Just assuming. */
3244 pAC->Rlmt.Net[i].ActivePort = pAC->Rlmt.Net[i].PrefPort;
3245 pAC->Rlmt.Net[i].RlmtMode = SK_RLMT_DEF_MODE;
3246 pAC->Rlmt.Net[i].TimeoutValue = SK_RLMT_DEF_TO_VAL;
3247 pAC->Rlmt.Net[i].NetNumber = i;
3248 }
3249
3250 pAC->Rlmt.Port[1].Net= &pAC->Rlmt.Net[0];
3251 pAC->Rlmt.Net[0].NumPorts = pAC->GIni.GIMacsFound;
3252
3253 SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_SET_NETS, Para);
3254
3255 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3256 ("RLMT: Changed to one net with two ports.\n"))
3257 }
3258 else if (Para.Para32[0] == 2) {
3259 pAC->Rlmt.Port[1].Net= &pAC->Rlmt.Net[1];
3260 pAC->Rlmt.Net[1].NumPorts = pAC->GIni.GIMacsFound - 1;
3261 pAC->Rlmt.Net[0].NumPorts =
3262 pAC->GIni.GIMacsFound - pAC->Rlmt.Net[1].NumPorts;
wdenk42d1f032003-10-15 23:53:47 +00003263
wdenk7152b1d2003-09-05 23:19:14 +00003264 pAC->Rlmt.NumNets = Para.Para32[0];
3265 for (i = 0; (SK_U32)i < pAC->Rlmt.NumNets; i++) {
3266 pAC->Rlmt.Net[i].RlmtState = SK_RLMT_RS_INIT;
3267 pAC->Rlmt.Net[i].RootIdSet = SK_FALSE;
3268 pAC->Rlmt.Net[i].Preference = 0xFFFFFFFF; /* "Automatic" */
3269 pAC->Rlmt.Net[i].PrefPort = SK_RLMT_DEF_PREF_PORT;
3270 /* Just assuming. */
3271 pAC->Rlmt.Net[i].ActivePort = pAC->Rlmt.Net[i].PrefPort;
3272 pAC->Rlmt.Net[i].RlmtMode = SK_RLMT_DEF_MODE;
3273 pAC->Rlmt.Net[i].TimeoutValue = SK_RLMT_DEF_TO_VAL;
3274
3275 pAC->Rlmt.Net[i].NetNumber = i;
3276 }
3277
3278 /* Set logical MAC addr on second net's active port. */
3279 (void)SkAddrOverride(pAC, IoC, pAC->Rlmt.Net[1].Port[pAC->Addr.
3280 Net[1].ActivePort]->PortNumber, NULL, SK_ADDR_SET_LOGICAL);
3281
3282 SkEventQueue(pAC, SKGE_PNMI, SK_PNMI_EVT_RLMT_SET_NETS, Para);
3283
3284 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3285 ("RLMT: Changed to two nets with one port each.\n"))
3286 }
3287 else {
3288 /* Not implemented for more than two nets. */
3289 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3290 ("SetNets not implemented for more than two nets.\n"))
3291 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3292 ("SK_RLMT_SET_NETS Event EMPTY.\n"))
3293 return;
3294 }
3295
3296 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3297 ("SK_RLMT_SET_NETS Event END.\n"))
3298} /* SkRlmtSetNets */
3299
3300
3301/******************************************************************************
3302 *
3303 * SkRlmtEvtModeChange - MODE_CHANGE
3304 *
3305 * Description:
3306 * This routine handles MODE_CHANGE events.
3307 *
3308 * Context:
3309 * runtime, pageable?
3310 * may be called after SK_INIT_IO
3311 *
3312 * Returns:
3313 * Nothing
3314 */
3315RLMT_STATIC void SkRlmtEvtModeChange(
3316SK_AC *pAC, /* Adapter Context */
3317SK_IOC IoC, /* I/O Context */
3318SK_EVPARA Para) /* SK_U32 NewMode; SK_U32 NetNumber */
3319{
3320 SK_EVPARA Para2;
3321 SK_U32 i;
3322 SK_U32 PrevRlmtMode;
3323
3324 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3325 ("SK_RLMT_MODE_CHANGE Event BEGIN.\n"))
3326
3327 if (Para.Para32[1] >= pAC->Rlmt.NumNets) {
3328 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3329 ("Bad NetNumber %d.\n", Para.Para32[1]))
3330 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3331 ("SK_RLMT_MODE_CHANGE Event EMPTY.\n"))
3332 return;
3333 }
3334
3335 Para.Para32[0] |= SK_RLMT_CHECK_LINK;
3336
3337 if ((pAC->Rlmt.Net[Para.Para32[1]].NumPorts == 1) &&
3338 Para.Para32[0] != SK_RLMT_MODE_CLS) {
3339 pAC->Rlmt.Net[Para.Para32[1]].RlmtMode = SK_RLMT_MODE_CLS;
3340 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3341 ("Forced RLMT mode to CLS on single port net.\n"))
3342 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3343 ("SK_RLMT_MODE_CHANGE Event EMPTY.\n"))
3344 return;
3345 }
3346
3347 /* Update RLMT mode. */
3348 PrevRlmtMode = pAC->Rlmt.Net[Para.Para32[1]].RlmtMode;
3349 pAC->Rlmt.Net[Para.Para32[1]].RlmtMode = Para.Para32[0];
3350
3351 if ((PrevRlmtMode & SK_RLMT_CHECK_LOC_LINK) !=
3352 (pAC->Rlmt.Net[Para.Para32[1]].RlmtMode & SK_RLMT_CHECK_LOC_LINK)) {
3353 /* SK_RLMT_CHECK_LOC_LINK bit changed. */
3354 if ((PrevRlmtMode & SK_RLMT_CHECK_OTHERS) == 0 &&
3355 pAC->Rlmt.Net[Para.Para32[1]].NumPorts > 1 &&
3356 pAC->Rlmt.Net[Para.Para32[1]].PortsUp >= 1) {
3357 /* 20001207 RA: Was "PortsUp == 1". */
3358 Para2.Para32[0] = Para.Para32[1];
3359 Para2.Para32[1] = (SK_U32)-1;
3360 SkTimerStart(pAC, IoC, &pAC->Rlmt.Net[Para.Para32[1]].LocTimer,
3361 pAC->Rlmt.Net[Para.Para32[1]].TimeoutValue,
3362 SKGE_RLMT, SK_RLMT_TIM, Para2);
3363 }
3364 }
3365
3366 if ((PrevRlmtMode & SK_RLMT_CHECK_SEG) !=
3367 (pAC->Rlmt.Net[Para.Para32[1]].RlmtMode & SK_RLMT_CHECK_SEG)) {
3368 /* SK_RLMT_CHECK_SEG bit changed. */
3369 for (i = 0; i < pAC->Rlmt.Net[Para.Para32[1]].NumPorts; i++) {
3370 (void)SkAddrMcClear(pAC, IoC,
3371 pAC->Rlmt.Net[Para.Para32[1]].Port[i]->PortNumber,
3372 SK_ADDR_PERMANENT | SK_MC_SW_ONLY);
3373
3374 /* Add RLMT MC address. */
3375 (void)SkAddrMcAdd(pAC, IoC,
3376 pAC->Rlmt.Net[Para.Para32[1]].Port[i]->PortNumber,
3377 &SkRlmtMcAddr, SK_ADDR_PERMANENT);
3378
3379 if ((pAC->Rlmt.Net[Para.Para32[1]].RlmtMode &
3380 SK_RLMT_CHECK_SEG) != 0) {
3381 /* Add BPDU MC address. */
3382 (void)SkAddrMcAdd(pAC, IoC,
3383 pAC->Rlmt.Net[Para.Para32[1]].Port[i]->PortNumber,
3384 &BridgeMcAddr, SK_ADDR_PERMANENT);
3385
3386 if (pAC->Rlmt.Net[Para.Para32[1]].RlmtState != SK_RLMT_RS_INIT) {
3387 if (!pAC->Rlmt.Net[Para.Para32[1]].Port[i]->LinkDown &&
3388 (Para2.pParaPtr = SkRlmtBuildSpanningTreePacket(
3389 pAC, IoC, i)) != NULL) {
3390 pAC->Rlmt.Net[Para.Para32[1]].Port[i]->RootIdSet =
3391 SK_FALSE;
3392 SkEventQueue(pAC, SKGE_DRV, SK_DRV_RLMT_SEND, Para2);
3393 }
3394 }
3395 }
3396 (void)SkAddrMcUpdate(pAC, IoC,
3397 pAC->Rlmt.Net[Para.Para32[1]].Port[i]->PortNumber);
3398 } /* for ... */
3399
3400 if ((pAC->Rlmt.Net[Para.Para32[1]].RlmtMode & SK_RLMT_CHECK_SEG) != 0) {
3401 Para2.Para32[0] = Para.Para32[1];
3402 Para2.Para32[1] = (SK_U32)-1;
3403 SkTimerStart(pAC, IoC, &pAC->Rlmt.Net[Para.Para32[1]].SegTimer,
3404 SK_RLMT_SEG_TO_VAL, SKGE_RLMT, SK_RLMT_SEG_TIM, Para2);
3405 }
3406 } /* SK_RLMT_CHECK_SEG bit changed. */
3407
3408 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3409 ("SK_RLMT_MODE_CHANGE Event END.\n"))
3410} /* SkRlmtEvtModeChange */
3411
3412
3413/******************************************************************************
3414 *
3415 * SkRlmtEvent - a PORT- or an RLMT-specific event happened
3416 *
3417 * Description:
3418 * This routine calls subroutines to handle PORT- and RLMT-specific events.
3419 *
3420 * Context:
3421 * runtime, pageable?
3422 * may be called after SK_INIT_IO
3423 *
3424 * Returns:
3425 * 0
3426 */
3427int SkRlmtEvent(
3428SK_AC *pAC, /* Adapter Context */
3429SK_IOC IoC, /* I/O Context */
3430SK_U32 Event, /* Event code */
3431SK_EVPARA Para) /* Event-specific parameter */
3432{
3433 switch (Event) {
wdenk42d1f032003-10-15 23:53:47 +00003434
wdenk7152b1d2003-09-05 23:19:14 +00003435 /* ----- PORT events ----- */
3436
3437 case SK_RLMT_PORTSTART_TIM: /* From RLMT via TIME. */
3438 SkRlmtEvtPortStartTim(pAC, IoC, Para);
3439 break;
3440 case SK_RLMT_LINK_UP: /* From SIRQ. */
3441 SkRlmtEvtLinkUp(pAC, IoC, Para);
3442 break;
3443 case SK_RLMT_PORTUP_TIM: /* From RLMT via TIME. */
3444 SkRlmtEvtPortUpTim(pAC, IoC, Para);
3445 break;
3446 case SK_RLMT_PORTDOWN: /* From RLMT. */
3447 case SK_RLMT_PORTDOWN_RX_TIM: /* From RLMT via TIME. */
3448 case SK_RLMT_PORTDOWN_TX_TIM: /* From RLMT via TIME. */
3449 SkRlmtEvtPortDownX(pAC, IoC, Event, Para);
3450 break;
3451 case SK_RLMT_LINK_DOWN: /* From SIRQ. */
3452 SkRlmtEvtLinkDown(pAC, IoC, Para);
3453 break;
3454 case SK_RLMT_PORT_ADDR: /* From ADDR. */
3455 SkRlmtEvtPortAddr(pAC, IoC, Para);
3456 break;
3457
3458 /* ----- RLMT events ----- */
3459
3460 case SK_RLMT_START: /* From DRV. */
3461 SkRlmtEvtStart(pAC, IoC, Para);
3462 break;
3463 case SK_RLMT_STOP: /* From DRV. */
3464 SkRlmtEvtStop(pAC, IoC, Para);
3465 break;
3466 case SK_RLMT_TIM: /* From RLMT via TIME. */
3467 SkRlmtEvtTim(pAC, IoC, Para);
3468 break;
3469 case SK_RLMT_SEG_TIM:
3470 SkRlmtEvtSegTim(pAC, IoC, Para);
3471 break;
3472 case SK_RLMT_PACKET_RECEIVED: /* From DRV. */
3473 SkRlmtEvtPacketRx(pAC, IoC, Para);
3474 break;
3475 case SK_RLMT_STATS_CLEAR: /* From PNMI. */
3476 SkRlmtEvtStatsClear(pAC, IoC, Para);
3477 break;
3478 case SK_RLMT_STATS_UPDATE: /* From PNMI. */
3479 SkRlmtEvtStatsUpdate(pAC, IoC, Para);
3480 break;
3481 case SK_RLMT_PREFPORT_CHANGE: /* From PNMI. */
3482 SkRlmtEvtPrefportChange(pAC, IoC, Para);
3483 break;
3484 case SK_RLMT_MODE_CHANGE: /* From PNMI. */
3485 SkRlmtEvtModeChange(pAC, IoC, Para);
3486 break;
3487 case SK_RLMT_SET_NETS: /* From DRV. */
3488 SkRlmtEvtSetNets(pAC, IoC, Para);
3489 break;
3490
3491 /* ----- Unknown events ----- */
3492
3493 default: /* Create error log entry. */
3494 SK_DBG_MSG(pAC, SK_DBGMOD_RLMT, SK_DBGCAT_CTRL,
3495 ("Unknown RLMT Event %d.\n", Event))
3496 SK_ERR_LOG(pAC, SK_ERRCL_SW, SKERR_RLMT_E003, SKERR_RLMT_E003_MSG);
3497 break;
3498 } /* switch() */
3499
3500 return (0);
3501} /* SkRlmtEvent */
3502
3503#ifdef __cplusplus
3504}
3505#endif /* __cplusplus */