1 /******************************************************************************
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
5 * Version: $Revision: 1.35 $
6 * Date: $Date: 2003/01/31 14:12:41 $
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.35 2003/01/31 14:12:41 mkunz
30 * single port adapter runs now with two identical MAC addresses
32 * Revision 1.34 2002/09/23 15:13:41 rwahl
35 * Revision 1.33 2001/07/03 12:16:48 mkunz
36 * New Flag ChgBcPrio (Change priority of last broadcast received)
38 * Revision 1.32 2001/02/14 14:06:31 rassmann
41 * Revision 1.31 2001/02/05 14:25:26 rassmann
42 * Prepared RLMT for transparent operation.
44 * Revision 1.30 2001/01/22 13:41:39 rassmann
45 * Supporting two nets on dual-port adapters.
47 * Revision 1.29 2000/11/17 08:58:00 rassmann
48 * Moved CheckSwitch from SK_RLMT_PACKET_RECEIVED to SK_RLMT_TIM event.
50 * Revision 1.28 2000/11/09 12:24:34 rassmann
53 * Revision 1.27 1999/11/22 13:59:56 cgoos
54 * Changed license header to GPL.
56 * Revision 1.26 1999/10/04 14:01:19 rassmann
57 * Corrected reaction to reception of BPDU frames (#10441).
59 * Revision 1.25 1999/07/20 12:53:39 rassmann
60 * Fixed documentation errors for lookahead macros.
62 * Revision 1.24 1999/05/28 11:15:56 rassmann
63 * Changed behaviour to reflect Design Spec v1.2.
64 * Controlling Link LED(s).
65 * Introduced RLMT Packet Version field in RLMT Packet.
66 * Newstyle lookahead macros (checking meta-information before looking at
69 * Revision 1.23 1999/01/28 12:50:42 rassmann
70 * Not using broadcast time stamps in CheckLinkState mode.
72 * Revision 1.22 1999/01/27 14:13:04 rassmann
73 * Monitoring broadcast traffic.
74 * Switching more reliably and not too early if switch is
75 * configured for spanning tree.
77 * Revision 1.21 1998/12/08 13:11:25 rassmann
78 * Stopping SegTimer at RlmtStop.
80 * Revision 1.20 1998/11/24 12:37:33 rassmann
81 * Implemented segmentation check.
83 * Revision 1.19 1998/11/17 13:43:06 rassmann
84 * Handling (logical) tx failure.
85 * Sending packet on logical address after PORT_SWITCH.
87 * Revision 1.18 1998/11/13 16:56:56 rassmann
88 * Added macro version of SkRlmtLookaheadPacket.
90 * Revision 1.17 1998/11/06 18:06:05 rassmann
91 * Corrected timing when RLMT checks fail.
92 * Clearing tx counter earlier in periodical checks.
94 * Revision 1.16 1998/11/03 13:53:50 rassmann
95 * RLMT should switch now (at least in mode 3).
97 * Revision 1.15 1998/10/22 11:39:52 rassmann
98 * Corrected signed/unsigned mismatches.
99 * Corrected receive list handling and address recognition.
101 * Revision 1.14 1998/10/15 15:16:36 rassmann
102 * Finished Spanning Tree checking.
105 * Revision 1.13 1998/09/24 19:16:08 rassmann
107 * Introduced Timer for PORT_DOWN due to no RX.
109 * Revision 1.12 1998/09/16 11:09:52 rassmann
110 * Syntax corrections.
112 * Revision 1.11 1998/09/15 11:28:50 rassmann
113 * Syntax corrections.
115 * Revision 1.10 1998/09/14 17:07:38 rassmann
116 * Added code for port checking via LAN.
117 * Changed Mbuf definition.
119 * Revision 1.9 1998/09/07 11:14:15 rassmann
120 * Syntax corrections.
122 * Revision 1.8 1998/09/07 09:06:08 rassmann
123 * Syntax corrections.
125 * Revision 1.7 1998/09/04 19:41:34 rassmann
126 * Syntax corrections.
127 * Started entering code for checking local links.
129 * Revision 1.6 1998/09/04 12:14:28 rassmann
132 * Revision 1.5 1998/09/02 16:55:29 rassmann
133 * Updated to reflect new DRV/HWAC/RLMT interface.
135 * Revision 1.4 1998/09/02 07:26:02 afischer
136 * typedef for SK_RLMT_PORT
138 * Revision 1.3 1998/08/27 14:29:03 rassmann
141 * Revision 1.2 1998/08/27 14:26:25 rassmann
144 * Revision 1.1 1998/08/21 08:29:10 rassmann
145 * First public version.
147 ******************************************************************************/
149 /******************************************************************************
153 * This is the header file for Redundant Link ManagemenT.
155 * Include File Hierarchy:
166 ******************************************************************************/
168 #ifndef __INC_SKRLMT_H
169 #define __INC_SKRLMT_H
172 #error C++ is not yet supported.
174 #endif /* cplusplus */
176 /* defines ********************************************************************/
178 #define SK_RLMT_NET_DOWN_TEMP 1 /* NET_DOWN due to last port down. */
179 #define SK_RLMT_NET_DOWN_FINAL 2 /* NET_DOWN due to RLMT_STOP. */
181 /* ----- Default queue sizes - must be multiples of 8 KB ----- */
183 /* Less than 8 KB free in RX queue => pause frames. */
184 #define SK_RLMT_STANDBY_QRXSIZE 128 /* Size of rx standby queue in KB. */
185 #define SK_RLMT_STANDBY_QXASIZE 32 /* Size of async standby queue in KB. */
186 #define SK_RLMT_STANDBY_QXSSIZE 0 /* Size of sync standby queue in KB. */
188 #define SK_RLMT_MAX_TX_BUF_SIZE 60 /* Maximum RLMT transmit size. */
190 /* ----- PORT states ----- */
192 #define SK_RLMT_PS_INIT 0 /* Port state: Init. */
193 #define SK_RLMT_PS_LINK_DOWN 1 /* Port state: Link down. */
194 #define SK_RLMT_PS_DOWN 2 /* Port state: Port down. */
195 #define SK_RLMT_PS_GOING_UP 3 /* Port state: Going up. */
196 #define SK_RLMT_PS_UP 4 /* Port state: Up. */
198 /* ----- RLMT states ----- */
200 #define SK_RLMT_RS_INIT 0 /* RLMT state: Init. */
201 #define SK_RLMT_RS_NET_DOWN 1 /* RLMT state: Net down. */
202 #define SK_RLMT_RS_NET_UP 2 /* RLMT state: Net up. */
204 /* ----- PORT events ----- */
206 #define SK_RLMT_LINK_UP 1001 /* Link came up. */
207 #define SK_RLMT_LINK_DOWN 1002 /* Link went down. */
208 #define SK_RLMT_PORT_ADDR 1003 /* Port address changed. */
210 /* ----- RLMT events ----- */
212 #define SK_RLMT_START 2001 /* Start RLMT. */
213 #define SK_RLMT_STOP 2002 /* Stop RLMT. */
214 #define SK_RLMT_PACKET_RECEIVED 2003 /* Packet was received for RLMT. */
215 #define SK_RLMT_STATS_CLEAR 2004 /* Clear statistics. */
216 #define SK_RLMT_STATS_UPDATE 2005 /* Update statistics. */
217 #define SK_RLMT_PREFPORT_CHANGE 2006 /* Change preferred port. */
218 #define SK_RLMT_MODE_CHANGE 2007 /* New RlmtMode. */
219 #define SK_RLMT_SET_NETS 2008 /* Number of Nets (1 or 2). */
221 /* ----- RLMT mode bits ----- */
224 * CAUTION: These defines are private to RLMT.
225 * Please use the RLMT mode defines below.
228 #define SK_RLMT_CHECK_LINK 1 /* Check Link. */
229 #define SK_RLMT_CHECK_LOC_LINK 2 /* Check other link on same adapter. */
230 #define SK_RLMT_CHECK_SEG 4 /* Check segmentation. */
232 #ifndef RLMT_CHECK_REMOTE
233 #define SK_RLMT_CHECK_OTHERS SK_RLMT_CHECK_LOC_LINK
234 #else /* RLMT_CHECK_REMOTE */
235 #define SK_RLMT_CHECK_REM_LINK 8 /* Check link(s) on other adapter(s). */
236 #define SK_RLMT_MAX_REMOTE_PORTS_CHECKED 3
237 #define SK_RLMT_CHECK_OTHERS \
238 (SK_RLMT_CHECK_LOC_LINK | SK_RLMT_CHECK_REM_LINK)
239 #endif /* RLMT_CHECK_REMOTE */
241 #ifndef SK_RLMT_ENABLE_TRANSPARENT
242 #define SK_RLMT_TRANSPARENT 0 /* RLMT transparent - inactive. */
243 #else /* SK_RLMT_ENABLE_TRANSPARENT */
244 #define SK_RLMT_TRANSPARENT 128 /* RLMT transparent. */
245 #endif /* SK_RLMT_ENABLE_TRANSPARENT */
247 /* ----- RLMT modes ----- */
249 /* Check Link State. */
250 #define SK_RLMT_MODE_CLS (SK_RLMT_CHECK_LINK)
252 /* Check Local Ports: check other links on the same adapter. */
253 #define SK_RLMT_MODE_CLP (SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK)
255 /* Check Local Ports and Segmentation Status. */
256 #define SK_RLMT_MODE_CLPSS \
257 (SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK | SK_RLMT_CHECK_SEG)
259 #ifdef RLMT_CHECK_REMOTE
260 /* Check Local and Remote Ports: check links (local or remote). */
262 #define SK_RLMT_MODE_CRP \
263 (SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK | SK_RLMT_CHECK_REM_LINK)
265 /* Check Local and Remote Ports and Segmentation Status. */
267 #define SK_RLMT_MODE_CRPSS \
268 (SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK | \
269 SK_RLMT_CHECK_REM_LINK | SK_RLMT_CHECK_SEG)
270 #endif /* RLMT_CHECK_REMOTE */
272 /* ----- RLMT lookahead result bits ----- */
274 #define SK_RLMT_RX_RLMT 1 /* Give packet to RLMT. */
275 #define SK_RLMT_RX_PROTOCOL 2 /* Give packet to protocol. */
280 SK_AC *pAC /* adapter context */
281 SK_U32 PortNum /* receiving port */
282 unsigned PktLen /* received packet's length */
283 SK_BOOL IsBc /* Flag: packet is broadcast */
284 unsigned *pOffset /* offs. of bytes to present to SK_RLMT_LOOKAHEAD */
285 unsigned *pNumBytes /* #Bytes to present to SK_RLMT_LOOKAHEAD */
288 #define SK_RLMT_PRE_LOOKAHEAD(pAC,PortNum,PktLen,IsBc,pOffset,pNumBytes) { \
292 _PortNum = (SK_U32)(PortNum); \
293 /* _pAC->Rlmt.Port[_PortNum].PacketsRx++; */ \
294 _pAC->Rlmt.Port[_PortNum].PacketsPerTimeSlot++; \
295 if (_pAC->Rlmt.RlmtOff) { \
299 if ((_pAC->Rlmt.Port[_PortNum].Net->RlmtMode & SK_RLMT_TRANSPARENT) != 0) { \
303 if (_pAC->Rlmt.Port[_PortNum].Net->RlmtMode != SK_RLMT_MODE_CLS) { \
312 if ((PktLen) > SK_RLMT_MAX_TX_BUF_SIZE) { \
313 /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \
325 SK_AC *pAC /* adapter context */
326 SK_U32 PortNum /* receiving port */
327 SK_U8 *pLaPacket, /* received packet's data (points to pOffset) */
328 SK_BOOL IsBc /* Flag: packet is broadcast */
329 SK_BOOL IsMc /* Flag: packet is multicast */
330 unsigned *pForRlmt /* Result: bits SK_RLMT_RX_RLMT, SK_RLMT_RX_PROTOCOL */
331 SK_RLMT_LOOKAHEAD() expects *pNumBytes from
332 packet offset *pOffset (s.a.) at *pLaPacket.
334 If you use SK_RLMT_LOOKAHEAD in a path where you already know if the packet is
335 BC, MC, or UC, you should use constants for IsBc and IsMc, so that your compiler
336 can trash unneeded parts of the if construction.
339 #define SK_RLMT_LOOKAHEAD(pAC,PortNum,pLaPacket,IsBc,IsMc,pForRlmt) { \
344 _PortNum = (SK_U32)(PortNum); \
345 _pLaPacket = (SK_U8 *)(pLaPacket); \
347 if (!SK_ADDR_EQUAL(_pLaPacket, _pAC->Addr.Net[_pAC->Rlmt.Port[ \
348 _PortNum].Net->NetNumber].CurrentMacAddress.a)) { \
349 _pAC->Rlmt.Port[_PortNum].BcTimeStamp = SkOsGetTime(_pAC); \
350 _pAC->Rlmt.CheckSwitch = SK_TRUE; \
352 /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \
353 *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \
356 if (SK_ADDR_EQUAL(_pLaPacket, BridgeMcAddr.a)) { \
357 _pAC->Rlmt.Port[_PortNum].BpduPacketsPerTimeSlot++; \
358 if (_pAC->Rlmt.Port[_PortNum].Net->RlmtMode & SK_RLMT_CHECK_SEG) { \
359 *(pForRlmt) = SK_RLMT_RX_RLMT | SK_RLMT_RX_PROTOCOL; \
362 *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \
365 else if (SK_ADDR_EQUAL(_pLaPacket, SkRlmtMcAddr.a)) { \
366 *(pForRlmt) = SK_RLMT_RX_RLMT; \
369 /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \
370 *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \
376 _pAC->Addr.Port[_PortNum].CurrentMacAddress.a)) { \
377 *(pForRlmt) = SK_RLMT_RX_RLMT; \
380 /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \
381 *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \
386 #ifdef SK_RLMT_FAST_LOOKAHEAD
387 Error: SK_RLMT_FAST_LOOKAHEAD no longer used. Use new macros for lookahead.
388 #endif /* SK_RLMT_FAST_LOOKAHEAD */
389 #ifdef SK_RLMT_SLOW_LOOKAHEAD
390 Error: SK_RLMT_SLOW_LOOKAHEAD no longer used. Use new macros for lookahead.
391 #endif /* SK_RLMT_SLOW_LOOKAHEAD */
393 /* typedefs *******************************************************************/
395 #ifdef SK_RLMT_MBUF_PRIVATE
396 typedef struct s_RlmtMbuf {
399 #endif /* SK_RLMT_MBUF_PRIVATE */
403 typedef struct s_Rlmt_PacketInfo {
404 unsigned PacketLength; /* Length of packet. */
405 unsigned PacketType; /* Directed/Multicast/Broadcast. */
407 #endif /* SK_LA_INFO */
410 typedef struct s_RootId {
411 SK_U8 Id[8]; /* Root Bridge Id. */
415 typedef struct s_port {
416 SK_MAC_ADDR CheckAddr;
421 typedef struct s_RlmtNet SK_RLMT_NET;
424 typedef struct s_RlmtPort {
426 /* ----- Public part (read-only) ----- */
428 SK_U8 PortState; /* Current state of this port. */
435 SK_U32 PortNumber; /* Number of port on adapter. */
436 SK_RLMT_NET * Net; /* Net port belongs to. */
440 SK_U64 TxSpHelloReqCts;
443 /* ----- Private part ----- */
445 /* SK_U64 PacketsRx; */ /* Total packets received. */
446 SK_U32 PacketsPerTimeSlot; /* Packets rxed between TOs. */
447 /* SK_U32 DataPacketsPerTimeSlot; */ /* Data packets ... */
448 SK_U32 BpduPacketsPerTimeSlot; /* BPDU packets rxed in TS. */
449 SK_U64 BcTimeStamp; /* Time of last BC receive. */
450 SK_U64 GuTimeStamp; /* Time of entering GOING_UP. */
452 SK_TIMER UpTimer; /* Timer struct Link/Port up. */
453 SK_TIMER DownRxTimer; /* Timer struct down rx. */
454 SK_TIMER DownTxTimer; /* Timer struct down tx. */
456 SK_U32 CheckingState; /* Checking State. */
458 SK_ADDR_PORT * AddrPort;
460 SK_U8 Random[4]; /* Random value. */
461 unsigned PortsChecked; /* #ports checked. */
462 unsigned PortsSuspect; /* #ports checked that are s. */
463 SK_PORT_CHECK PortCheck[1];
464 /* SK_PORT_CHECK PortCheck[SK_MAX_MACS - 1]; */
466 SK_BOOL PortStarted; /* Port is started. */
467 SK_BOOL PortNoRx; /* NoRx for >= 1 time slot. */
469 SK_RLMT_ROOT_ID Root; /* Root Bridge Id. */
475 /* ----- Public part (read-only) ----- */
477 SK_U32 NetNumber; /* Number of net. */
479 SK_RLMT_PORT * Port[SK_MAX_MACS]; /* Ports that belong to this net. */
480 SK_U32 NumPorts; /* Number of ports. */
481 SK_U32 PrefPort; /* Preferred port. */
485 SK_U32 ChgBcPrio; /* Change Priority of last broadcast received */
486 SK_U32 RlmtMode; /* Check ... */
487 SK_U32 ActivePort; /* Active port. */
488 SK_U32 Preference; /* 0xFFFFFFFF: Automatic. */
490 SK_U8 RlmtState; /* Current RLMT state. */
492 /* ----- Private part ----- */
496 int LinksUp; /* #Links up. */
497 int PortsUp; /* #Ports up. */
498 SK_U32 TimeoutValue; /* RLMT timeout value. */
500 SK_U32 CheckingState; /* Checking State. */
501 SK_RLMT_ROOT_ID Root; /* Root Bridge Id. */
503 SK_TIMER LocTimer; /* Timer struct. */
504 SK_TIMER SegTimer; /* Timer struct. */
508 typedef struct s_Rlmt {
510 /* ----- Public part (read-only) ----- */
512 SK_U32 NumNets; /* Number of nets. */
513 SK_U32 NetsStarted; /* Number of nets started. */
514 SK_RLMT_NET Net[SK_MAX_NETS]; /* Array of available nets. */
515 SK_RLMT_PORT Port[SK_MAX_MACS]; /* Array of available ports. */
517 /* ----- Private part ----- */
519 SK_BOOL RlmtOff; /* set to zero if the Mac addresses
520 are equal or the second one
527 extern SK_MAC_ADDR BridgeMcAddr;
528 extern SK_MAC_ADDR SkRlmtMcAddr;
530 /* function prototypes ********************************************************/
535 /* Functions provided by SkRlmt */
537 /* ANSI/C++ compliant function prototypes */
539 extern void SkRlmtInit(
544 extern int SkRlmtEvent(
550 #else /* defined(SK_KR_PROTO) */
552 /* Non-ANSI/C++ compliant function prototypes */
554 #error KR-style function prototypes are not yet provided.
556 #endif /* defined(SK_KR_PROTO)) */
561 #endif /* __cplusplus */
563 #endif /* __INC_SKRLMT_H */