1 /******************************************************************************
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
7 * Purpose: Header file for Redundant Link ManagemenT.
9 ******************************************************************************/
11 /******************************************************************************
13 * (C)Copyright 1998-2001 SysKonnect GmbH.
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.
20 * The information in this file is provided "AS IS" without warranty.
22 ******************************************************************************/
24 /******************************************************************************
29 * Revision 1.1.1.1 2011-02-28 14:37:53 lothar
30 * imported U-Boot Release 2009.08 from Freescale BSP L2.6.31_10.08.01
32 * Revision 1.35 2003/01/31 14:12:41 mkunz
33 * single port adapter runs now with two identical MAC addresses
35 * Revision 1.34 2002/09/23 15:13:41 rwahl
38 * Revision 1.33 2001/07/03 12:16:48 mkunz
39 * New Flag ChgBcPrio (Change priority of last broadcast received)
41 * Revision 1.32 2001/02/14 14:06:31 rassmann
44 * Revision 1.31 2001/02/05 14:25:26 rassmann
45 * Prepared RLMT for transparent operation.
47 * Revision 1.30 2001/01/22 13:41:39 rassmann
48 * Supporting two nets on dual-port adapters.
50 * Revision 1.29 2000/11/17 08:58:00 rassmann
51 * Moved CheckSwitch from SK_RLMT_PACKET_RECEIVED to SK_RLMT_TIM event.
53 * Revision 1.28 2000/11/09 12:24:34 rassmann
56 * Revision 1.27 1999/11/22 13:59:56 cgoos
57 * Changed license header to GPL.
59 * Revision 1.26 1999/10/04 14:01:19 rassmann
60 * Corrected reaction to reception of BPDU frames (#10441).
62 * Revision 1.25 1999/07/20 12:53:39 rassmann
63 * Fixed documentation errors for lookahead macros.
65 * Revision 1.24 1999/05/28 11:15:56 rassmann
66 * Changed behaviour to reflect Design Spec v1.2.
67 * Controlling Link LED(s).
68 * Introduced RLMT Packet Version field in RLMT Packet.
69 * Newstyle lookahead macros (checking meta-information before looking at
72 * Revision 1.23 1999/01/28 12:50:42 rassmann
73 * Not using broadcast time stamps in CheckLinkState mode.
75 * Revision 1.22 1999/01/27 14:13:04 rassmann
76 * Monitoring broadcast traffic.
77 * Switching more reliably and not too early if switch is
78 * configured for spanning tree.
80 * Revision 1.21 1998/12/08 13:11:25 rassmann
81 * Stopping SegTimer at RlmtStop.
83 * Revision 1.20 1998/11/24 12:37:33 rassmann
84 * Implemented segmentation check.
86 * Revision 1.19 1998/11/17 13:43:06 rassmann
87 * Handling (logical) tx failure.
88 * Sending packet on logical address after PORT_SWITCH.
90 * Revision 1.18 1998/11/13 16:56:56 rassmann
91 * Added macro version of SkRlmtLookaheadPacket.
93 * Revision 1.17 1998/11/06 18:06:05 rassmann
94 * Corrected timing when RLMT checks fail.
95 * Clearing tx counter earlier in periodical checks.
97 * Revision 1.16 1998/11/03 13:53:50 rassmann
98 * RLMT should switch now (at least in mode 3).
100 * Revision 1.15 1998/10/22 11:39:52 rassmann
101 * Corrected signed/unsigned mismatches.
102 * Corrected receive list handling and address recognition.
104 * Revision 1.14 1998/10/15 15:16:36 rassmann
105 * Finished Spanning Tree checking.
108 * Revision 1.13 1998/09/24 19:16:08 rassmann
110 * Introduced Timer for PORT_DOWN due to no RX.
112 * Revision 1.12 1998/09/16 11:09:52 rassmann
113 * Syntax corrections.
115 * Revision 1.11 1998/09/15 11:28:50 rassmann
116 * Syntax corrections.
118 * Revision 1.10 1998/09/14 17:07:38 rassmann
119 * Added code for port checking via LAN.
120 * Changed Mbuf definition.
122 * Revision 1.9 1998/09/07 11:14:15 rassmann
123 * Syntax corrections.
125 * Revision 1.8 1998/09/07 09:06:08 rassmann
126 * Syntax corrections.
128 * Revision 1.7 1998/09/04 19:41:34 rassmann
129 * Syntax corrections.
130 * Started entering code for checking local links.
132 * Revision 1.6 1998/09/04 12:14:28 rassmann
135 * Revision 1.5 1998/09/02 16:55:29 rassmann
136 * Updated to reflect new DRV/HWAC/RLMT interface.
138 * Revision 1.4 1998/09/02 07:26:02 afischer
139 * typedef for SK_RLMT_PORT
141 * Revision 1.3 1998/08/27 14:29:03 rassmann
144 * Revision 1.2 1998/08/27 14:26:25 rassmann
147 * Revision 1.1 1998/08/21 08:29:10 rassmann
148 * First public version.
150 ******************************************************************************/
152 /******************************************************************************
156 * This is the header file for Redundant Link ManagemenT.
158 * Include File Hierarchy:
169 ******************************************************************************/
171 #ifndef __INC_SKRLMT_H
172 #define __INC_SKRLMT_H
175 #error C++ is not yet supported.
177 #endif /* cplusplus */
179 /* defines ********************************************************************/
181 #define SK_RLMT_NET_DOWN_TEMP 1 /* NET_DOWN due to last port down. */
182 #define SK_RLMT_NET_DOWN_FINAL 2 /* NET_DOWN due to RLMT_STOP. */
184 /* ----- Default queue sizes - must be multiples of 8 KB ----- */
186 /* Less than 8 KB free in RX queue => pause frames. */
187 #define SK_RLMT_STANDBY_QRXSIZE 128 /* Size of rx standby queue in KB. */
188 #define SK_RLMT_STANDBY_QXASIZE 32 /* Size of async standby queue in KB. */
189 #define SK_RLMT_STANDBY_QXSSIZE 0 /* Size of sync standby queue in KB. */
191 #define SK_RLMT_MAX_TX_BUF_SIZE 60 /* Maximum RLMT transmit size. */
193 /* ----- PORT states ----- */
195 #define SK_RLMT_PS_INIT 0 /* Port state: Init. */
196 #define SK_RLMT_PS_LINK_DOWN 1 /* Port state: Link down. */
197 #define SK_RLMT_PS_DOWN 2 /* Port state: Port down. */
198 #define SK_RLMT_PS_GOING_UP 3 /* Port state: Going up. */
199 #define SK_RLMT_PS_UP 4 /* Port state: Up. */
201 /* ----- RLMT states ----- */
203 #define SK_RLMT_RS_INIT 0 /* RLMT state: Init. */
204 #define SK_RLMT_RS_NET_DOWN 1 /* RLMT state: Net down. */
205 #define SK_RLMT_RS_NET_UP 2 /* RLMT state: Net up. */
207 /* ----- PORT events ----- */
209 #define SK_RLMT_LINK_UP 1001 /* Link came up. */
210 #define SK_RLMT_LINK_DOWN 1002 /* Link went down. */
211 #define SK_RLMT_PORT_ADDR 1003 /* Port address changed. */
213 /* ----- RLMT events ----- */
215 #define SK_RLMT_START 2001 /* Start RLMT. */
216 #define SK_RLMT_STOP 2002 /* Stop RLMT. */
217 #define SK_RLMT_PACKET_RECEIVED 2003 /* Packet was received for RLMT. */
218 #define SK_RLMT_STATS_CLEAR 2004 /* Clear statistics. */
219 #define SK_RLMT_STATS_UPDATE 2005 /* Update statistics. */
220 #define SK_RLMT_PREFPORT_CHANGE 2006 /* Change preferred port. */
221 #define SK_RLMT_MODE_CHANGE 2007 /* New RlmtMode. */
222 #define SK_RLMT_SET_NETS 2008 /* Number of Nets (1 or 2). */
224 /* ----- RLMT mode bits ----- */
227 * CAUTION: These defines are private to RLMT.
228 * Please use the RLMT mode defines below.
231 #define SK_RLMT_CHECK_LINK 1 /* Check Link. */
232 #define SK_RLMT_CHECK_LOC_LINK 2 /* Check other link on same adapter. */
233 #define SK_RLMT_CHECK_SEG 4 /* Check segmentation. */
235 #ifndef RLMT_CHECK_REMOTE
236 #define SK_RLMT_CHECK_OTHERS SK_RLMT_CHECK_LOC_LINK
237 #else /* RLMT_CHECK_REMOTE */
238 #define SK_RLMT_CHECK_REM_LINK 8 /* Check link(s) on other adapter(s). */
239 #define SK_RLMT_MAX_REMOTE_PORTS_CHECKED 3
240 #define SK_RLMT_CHECK_OTHERS \
241 (SK_RLMT_CHECK_LOC_LINK | SK_RLMT_CHECK_REM_LINK)
242 #endif /* RLMT_CHECK_REMOTE */
244 #ifndef SK_RLMT_ENABLE_TRANSPARENT
245 #define SK_RLMT_TRANSPARENT 0 /* RLMT transparent - inactive. */
246 #else /* SK_RLMT_ENABLE_TRANSPARENT */
247 #define SK_RLMT_TRANSPARENT 128 /* RLMT transparent. */
248 #endif /* SK_RLMT_ENABLE_TRANSPARENT */
250 /* ----- RLMT modes ----- */
252 /* Check Link State. */
253 #define SK_RLMT_MODE_CLS (SK_RLMT_CHECK_LINK)
255 /* Check Local Ports: check other links on the same adapter. */
256 #define SK_RLMT_MODE_CLP (SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK)
258 /* Check Local Ports and Segmentation Status. */
259 #define SK_RLMT_MODE_CLPSS \
260 (SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK | SK_RLMT_CHECK_SEG)
262 #ifdef RLMT_CHECK_REMOTE
263 /* Check Local and Remote Ports: check links (local or remote). */
265 #define SK_RLMT_MODE_CRP \
266 (SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK | SK_RLMT_CHECK_REM_LINK)
268 /* Check Local and Remote Ports and Segmentation Status. */
270 #define SK_RLMT_MODE_CRPSS \
271 (SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK | \
272 SK_RLMT_CHECK_REM_LINK | SK_RLMT_CHECK_SEG)
273 #endif /* RLMT_CHECK_REMOTE */
275 /* ----- RLMT lookahead result bits ----- */
277 #define SK_RLMT_RX_RLMT 1 /* Give packet to RLMT. */
278 #define SK_RLMT_RX_PROTOCOL 2 /* Give packet to protocol. */
283 SK_AC *pAC /* adapter context */
284 SK_U32 PortNum /* receiving port */
285 unsigned PktLen /* received packet's length */
286 SK_BOOL IsBc /* Flag: packet is broadcast */
287 unsigned *pOffset /* offs. of bytes to present to SK_RLMT_LOOKAHEAD */
288 unsigned *pNumBytes /* #Bytes to present to SK_RLMT_LOOKAHEAD */
291 #define SK_RLMT_PRE_LOOKAHEAD(pAC,PortNum,PktLen,IsBc,pOffset,pNumBytes) { \
295 _PortNum = (SK_U32)(PortNum); \
296 /* _pAC->Rlmt.Port[_PortNum].PacketsRx++; */ \
297 _pAC->Rlmt.Port[_PortNum].PacketsPerTimeSlot++; \
298 if (_pAC->Rlmt.RlmtOff) { \
302 if ((_pAC->Rlmt.Port[_PortNum].Net->RlmtMode & SK_RLMT_TRANSPARENT) != 0) { \
306 if (_pAC->Rlmt.Port[_PortNum].Net->RlmtMode != SK_RLMT_MODE_CLS) { \
315 if ((PktLen) > SK_RLMT_MAX_TX_BUF_SIZE) { \
316 /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \
328 SK_AC *pAC /* adapter context */
329 SK_U32 PortNum /* receiving port */
330 SK_U8 *pLaPacket, /* received packet's data (points to pOffset) */
331 SK_BOOL IsBc /* Flag: packet is broadcast */
332 SK_BOOL IsMc /* Flag: packet is multicast */
333 unsigned *pForRlmt /* Result: bits SK_RLMT_RX_RLMT, SK_RLMT_RX_PROTOCOL */
334 SK_RLMT_LOOKAHEAD() expects *pNumBytes from
335 packet offset *pOffset (s.a.) at *pLaPacket.
337 If you use SK_RLMT_LOOKAHEAD in a path where you already know if the packet is
338 BC, MC, or UC, you should use constants for IsBc and IsMc, so that your compiler
339 can trash unneeded parts of the if construction.
342 #define SK_RLMT_LOOKAHEAD(pAC,PortNum,pLaPacket,IsBc,IsMc,pForRlmt) { \
347 _PortNum = (SK_U32)(PortNum); \
348 _pLaPacket = (SK_U8 *)(pLaPacket); \
350 if (!SK_ADDR_EQUAL(_pLaPacket, _pAC->Addr.Net[_pAC->Rlmt.Port[ \
351 _PortNum].Net->NetNumber].CurrentMacAddress.a)) { \
352 _pAC->Rlmt.Port[_PortNum].BcTimeStamp = SkOsGetTime(_pAC); \
353 _pAC->Rlmt.CheckSwitch = SK_TRUE; \
355 /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \
356 *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \
359 if (SK_ADDR_EQUAL(_pLaPacket, BridgeMcAddr.a)) { \
360 _pAC->Rlmt.Port[_PortNum].BpduPacketsPerTimeSlot++; \
361 if (_pAC->Rlmt.Port[_PortNum].Net->RlmtMode & SK_RLMT_CHECK_SEG) { \
362 *(pForRlmt) = SK_RLMT_RX_RLMT | SK_RLMT_RX_PROTOCOL; \
365 *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \
368 else if (SK_ADDR_EQUAL(_pLaPacket, SkRlmtMcAddr.a)) { \
369 *(pForRlmt) = SK_RLMT_RX_RLMT; \
372 /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \
373 *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \
379 _pAC->Addr.Port[_PortNum].CurrentMacAddress.a)) { \
380 *(pForRlmt) = SK_RLMT_RX_RLMT; \
383 /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \
384 *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \
389 #ifdef SK_RLMT_FAST_LOOKAHEAD
390 Error: SK_RLMT_FAST_LOOKAHEAD no longer used. Use new macros for lookahead.
391 #endif /* SK_RLMT_FAST_LOOKAHEAD */
392 #ifdef SK_RLMT_SLOW_LOOKAHEAD
393 Error: SK_RLMT_SLOW_LOOKAHEAD no longer used. Use new macros for lookahead.
394 #endif /* SK_RLMT_SLOW_LOOKAHEAD */
396 /* typedefs *******************************************************************/
398 #ifdef SK_RLMT_MBUF_PRIVATE
399 typedef struct s_RlmtMbuf {
402 #endif /* SK_RLMT_MBUF_PRIVATE */
406 typedef struct s_Rlmt_PacketInfo {
407 unsigned PacketLength; /* Length of packet. */
408 unsigned PacketType; /* Directed/Multicast/Broadcast. */
410 #endif /* SK_LA_INFO */
413 typedef struct s_RootId {
414 SK_U8 Id[8]; /* Root Bridge Id. */
418 typedef struct s_port {
419 SK_MAC_ADDR CheckAddr;
424 typedef struct s_RlmtNet SK_RLMT_NET;
427 typedef struct s_RlmtPort {
429 /* ----- Public part (read-only) ----- */
431 SK_U8 PortState; /* Current state of this port. */
438 SK_U32 PortNumber; /* Number of port on adapter. */
439 SK_RLMT_NET * Net; /* Net port belongs to. */
443 SK_U64 TxSpHelloReqCts;
446 /* ----- Private part ----- */
448 /* SK_U64 PacketsRx; */ /* Total packets received. */
449 SK_U32 PacketsPerTimeSlot; /* Packets rxed between TOs. */
450 /* SK_U32 DataPacketsPerTimeSlot; */ /* Data packets ... */
451 SK_U32 BpduPacketsPerTimeSlot; /* BPDU packets rxed in TS. */
452 SK_U64 BcTimeStamp; /* Time of last BC receive. */
453 SK_U64 GuTimeStamp; /* Time of entering GOING_UP. */
455 SK_TIMER UpTimer; /* Timer struct Link/Port up. */
456 SK_TIMER DownRxTimer; /* Timer struct down rx. */
457 SK_TIMER DownTxTimer; /* Timer struct down tx. */
459 SK_U32 CheckingState; /* Checking State. */
461 SK_ADDR_PORT * AddrPort;
463 SK_U8 Random[4]; /* Random value. */
464 unsigned PortsChecked; /* #ports checked. */
465 unsigned PortsSuspect; /* #ports checked that are s. */
466 SK_PORT_CHECK PortCheck[1];
467 /* SK_PORT_CHECK PortCheck[SK_MAX_MACS - 1]; */
469 SK_BOOL PortStarted; /* Port is started. */
470 SK_BOOL PortNoRx; /* NoRx for >= 1 time slot. */
472 SK_RLMT_ROOT_ID Root; /* Root Bridge Id. */
478 /* ----- Public part (read-only) ----- */
480 SK_U32 NetNumber; /* Number of net. */
482 SK_RLMT_PORT * Port[SK_MAX_MACS]; /* Ports that belong to this net. */
483 SK_U32 NumPorts; /* Number of ports. */
484 SK_U32 PrefPort; /* Preferred port. */
488 SK_U32 ChgBcPrio; /* Change Priority of last broadcast received */
489 SK_U32 RlmtMode; /* Check ... */
490 SK_U32 ActivePort; /* Active port. */
491 SK_U32 Preference; /* 0xFFFFFFFF: Automatic. */
493 SK_U8 RlmtState; /* Current RLMT state. */
495 /* ----- Private part ----- */
499 int LinksUp; /* #Links up. */
500 int PortsUp; /* #Ports up. */
501 SK_U32 TimeoutValue; /* RLMT timeout value. */
503 SK_U32 CheckingState; /* Checking State. */
504 SK_RLMT_ROOT_ID Root; /* Root Bridge Id. */
506 SK_TIMER LocTimer; /* Timer struct. */
507 SK_TIMER SegTimer; /* Timer struct. */
511 typedef struct s_Rlmt {
513 /* ----- Public part (read-only) ----- */
515 SK_U32 NumNets; /* Number of nets. */
516 SK_U32 NetsStarted; /* Number of nets started. */
517 SK_RLMT_NET Net[SK_MAX_NETS]; /* Array of available nets. */
518 SK_RLMT_PORT Port[SK_MAX_MACS]; /* Array of available ports. */
520 /* ----- Private part ----- */
522 SK_BOOL RlmtOff; /* set to zero if the Mac addresses
523 are equal or the second one
530 extern SK_MAC_ADDR BridgeMcAddr;
531 extern SK_MAC_ADDR SkRlmtMcAddr;
533 /* function prototypes ********************************************************/
538 /* Functions provided by SkRlmt */
540 /* ANSI/C++ compliant function prototypes */
542 extern void SkRlmtInit(
547 extern int SkRlmtEvent(
553 #else /* defined(SK_KR_PROTO) */
555 /* Non-ANSI/C++ compliant function prototypes */
557 #error KR-style function prototypes are not yet provided.
559 #endif /* defined(SK_KR_PROTO)) */
564 #endif /* __cplusplus */
566 #endif /* __INC_SKRLMT_H */