1 /******************************************************************************
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
5 * Version: $Revision: 1.37 $
6 * Date: $Date: 2003/04/15 09:43:43 $
7 * Purpose: Header file for Redundant Link ManagemenT.
9 ******************************************************************************/
11 /******************************************************************************
13 * (C)Copyright 1998-2002 SysKonnect GmbH.
14 * (C)Copyright 2002-2003 Marvell.
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * The information in this file is provided "AS IS" without warranty.
23 ******************************************************************************/
25 /******************************************************************************
29 * This is the header file for Redundant Link ManagemenT.
31 * Include File Hierarchy:
42 ******************************************************************************/
44 #ifndef __INC_SKRLMT_H
45 #define __INC_SKRLMT_H
49 #endif /* cplusplus */
51 /* defines ********************************************************************/
53 #define SK_RLMT_NET_DOWN_TEMP 1 /* NET_DOWN due to last port down. */
54 #define SK_RLMT_NET_DOWN_FINAL 2 /* NET_DOWN due to RLMT_STOP. */
56 /* ----- Default queue sizes - must be multiples of 8 KB ----- */
58 /* Less than 8 KB free in RX queue => pause frames. */
59 #define SK_RLMT_STANDBY_QRXSIZE 128 /* Size of rx standby queue in KB. */
60 #define SK_RLMT_STANDBY_QXASIZE 32 /* Size of async standby queue in KB. */
61 #define SK_RLMT_STANDBY_QXSSIZE 0 /* Size of sync standby queue in KB. */
63 #define SK_RLMT_MAX_TX_BUF_SIZE 60 /* Maximum RLMT transmit size. */
65 /* ----- PORT states ----- */
67 #define SK_RLMT_PS_INIT 0 /* Port state: Init. */
68 #define SK_RLMT_PS_LINK_DOWN 1 /* Port state: Link down. */
69 #define SK_RLMT_PS_DOWN 2 /* Port state: Port down. */
70 #define SK_RLMT_PS_GOING_UP 3 /* Port state: Going up. */
71 #define SK_RLMT_PS_UP 4 /* Port state: Up. */
73 /* ----- RLMT states ----- */
75 #define SK_RLMT_RS_INIT 0 /* RLMT state: Init. */
76 #define SK_RLMT_RS_NET_DOWN 1 /* RLMT state: Net down. */
77 #define SK_RLMT_RS_NET_UP 2 /* RLMT state: Net up. */
79 /* ----- PORT events ----- */
81 #define SK_RLMT_LINK_UP 1001 /* Link came up. */
82 #define SK_RLMT_LINK_DOWN 1002 /* Link went down. */
83 #define SK_RLMT_PORT_ADDR 1003 /* Port address changed. */
85 /* ----- RLMT events ----- */
87 #define SK_RLMT_START 2001 /* Start RLMT. */
88 #define SK_RLMT_STOP 2002 /* Stop RLMT. */
89 #define SK_RLMT_PACKET_RECEIVED 2003 /* Packet was received for RLMT. */
90 #define SK_RLMT_STATS_CLEAR 2004 /* Clear statistics. */
91 #define SK_RLMT_STATS_UPDATE 2005 /* Update statistics. */
92 #define SK_RLMT_PREFPORT_CHANGE 2006 /* Change preferred port. */
93 #define SK_RLMT_MODE_CHANGE 2007 /* New RlmtMode. */
94 #define SK_RLMT_SET_NETS 2008 /* Number of Nets (1 or 2). */
96 /* ----- RLMT mode bits ----- */
99 * CAUTION: These defines are private to RLMT.
100 * Please use the RLMT mode defines below.
103 #define SK_RLMT_CHECK_LINK 1 /* Check Link. */
104 #define SK_RLMT_CHECK_LOC_LINK 2 /* Check other link on same adapter. */
105 #define SK_RLMT_CHECK_SEG 4 /* Check segmentation. */
107 #ifndef RLMT_CHECK_REMOTE
108 #define SK_RLMT_CHECK_OTHERS SK_RLMT_CHECK_LOC_LINK
109 #else /* RLMT_CHECK_REMOTE */
110 #define SK_RLMT_CHECK_REM_LINK 8 /* Check link(s) on other adapter(s). */
111 #define SK_RLMT_MAX_REMOTE_PORTS_CHECKED 3
112 #define SK_RLMT_CHECK_OTHERS \
113 (SK_RLMT_CHECK_LOC_LINK | SK_RLMT_CHECK_REM_LINK)
114 #endif /* RLMT_CHECK_REMOTE */
116 #ifndef SK_RLMT_ENABLE_TRANSPARENT
117 #define SK_RLMT_TRANSPARENT 0 /* RLMT transparent - inactive. */
118 #else /* SK_RLMT_ENABLE_TRANSPARENT */
119 #define SK_RLMT_TRANSPARENT 128 /* RLMT transparent. */
120 #endif /* SK_RLMT_ENABLE_TRANSPARENT */
122 /* ----- RLMT modes ----- */
124 /* Check Link State. */
125 #define SK_RLMT_MODE_CLS (SK_RLMT_CHECK_LINK)
127 /* Check Local Ports: check other links on the same adapter. */
128 #define SK_RLMT_MODE_CLP (SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK)
130 /* Check Local Ports and Segmentation Status. */
131 #define SK_RLMT_MODE_CLPSS \
132 (SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK | SK_RLMT_CHECK_SEG)
134 #ifdef RLMT_CHECK_REMOTE
135 /* Check Local and Remote Ports: check links (local or remote). */
137 #define SK_RLMT_MODE_CRP \
138 (SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK | SK_RLMT_CHECK_REM_LINK)
140 /* Check Local and Remote Ports and Segmentation Status. */
142 #define SK_RLMT_MODE_CRPSS \
143 (SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK | \
144 SK_RLMT_CHECK_REM_LINK | SK_RLMT_CHECK_SEG)
145 #endif /* RLMT_CHECK_REMOTE */
147 /* ----- RLMT lookahead result bits ----- */
149 #define SK_RLMT_RX_RLMT 1 /* Give packet to RLMT. */
150 #define SK_RLMT_RX_PROTOCOL 2 /* Give packet to protocol. */
155 SK_AC
*pAC
/* adapter context */
156 SK_U32 PortNum
/* receiving port */
157 unsigned PktLen
/* received packet's length */
158 SK_BOOL IsBc
/* Flag: packet is broadcast */
159 unsigned *pOffset
/* offs. of bytes to present to SK_RLMT_LOOKAHEAD */
160 unsigned *pNumBytes
/* #Bytes to present to SK_RLMT_LOOKAHEAD */
163 #define SK_RLMT_PRE_LOOKAHEAD(pAC,PortNum,PktLen,IsBc,pOffset,pNumBytes) { \
167 _PortNum = (SK_U32)(PortNum); \
168 /* _pAC->Rlmt.Port[_PortNum].PacketsRx++; */ \
169 _pAC->Rlmt.Port[_PortNum].PacketsPerTimeSlot++; \
170 if (_pAC->Rlmt.RlmtOff) { \
174 if ((_pAC->Rlmt.Port[_PortNum].Net->RlmtMode & SK_RLMT_TRANSPARENT) != 0) { \
178 if (_pAC->Rlmt.Port[_PortNum].Net->RlmtMode != SK_RLMT_MODE_CLS) { \
187 if ((PktLen) > SK_RLMT_MAX_TX_BUF_SIZE) { \
188 /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \
200 SK_AC
*pAC
/* adapter context */
201 SK_U32 PortNum
/* receiving port */
202 SK_U8
*pLaPacket
, /* received packet's data (points to pOffset) */
203 SK_BOOL IsBc
/* Flag: packet is broadcast */
204 SK_BOOL IsMc
/* Flag: packet is multicast */
205 unsigned *pForRlmt
/* Result: bits SK_RLMT_RX_RLMT, SK_RLMT_RX_PROTOCOL */
206 SK_RLMT_LOOKAHEAD() expects
*pNumBytes from
207 packet offset
*pOffset (s
.a
.) at
*pLaPacket
.
209 If you use SK_RLMT_LOOKAHEAD in a path where you already know
if the packet is
210 BC
, MC
, or UC
, you should use constants
for IsBc
and IsMc
, so that your compiler
211 can trash unneeded parts of the
if construction
.
214 #define SK_RLMT_LOOKAHEAD(pAC,PortNum,pLaPacket,IsBc,IsMc,pForRlmt) { \
219 _PortNum = (SK_U32)(PortNum); \
220 _pLaPacket = (SK_U8 *)(pLaPacket); \
222 if (!SK_ADDR_EQUAL(_pLaPacket, _pAC->Addr.Net[_pAC->Rlmt.Port[ \
223 _PortNum].Net->NetNumber].CurrentMacAddress.a)) { \
224 _pAC->Rlmt.Port[_PortNum].BcTimeStamp = SkOsGetTime(_pAC); \
225 _pAC->Rlmt.CheckSwitch = SK_TRUE; \
227 /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \
228 *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \
231 if (SK_ADDR_EQUAL(_pLaPacket, BridgeMcAddr.a)) { \
232 _pAC->Rlmt.Port[_PortNum].BpduPacketsPerTimeSlot++; \
233 if (_pAC->Rlmt.Port[_PortNum].Net->RlmtMode & SK_RLMT_CHECK_SEG) { \
234 *(pForRlmt) = SK_RLMT_RX_RLMT | SK_RLMT_RX_PROTOCOL; \
237 *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \
240 else if (SK_ADDR_EQUAL(_pLaPacket, SkRlmtMcAddr.a)) { \
241 *(pForRlmt) = SK_RLMT_RX_RLMT; \
244 /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \
245 *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \
251 _pAC->Addr.Port[_PortNum].CurrentMacAddress.a)) { \
252 *(pForRlmt) = SK_RLMT_RX_RLMT; \
255 /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \
256 *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \
261 #ifdef SK_RLMT_FAST_LOOKAHEAD
262 Error
: SK_RLMT_FAST_LOOKAHEAD no longer used
. Use
new macros
for lookahead
.
263 #endif /* SK_RLMT_FAST_LOOKAHEAD */
264 #ifdef SK_RLMT_SLOW_LOOKAHEAD
265 Error
: SK_RLMT_SLOW_LOOKAHEAD no longer used
. Use
new macros
for lookahead
.
266 #endif /* SK_RLMT_SLOW_LOOKAHEAD */
268 /* typedefs *******************************************************************/
270 #ifdef SK_RLMT_MBUF_PRIVATE
271 typedef struct s_RlmtMbuf
{
274 #endif /* SK_RLMT_MBUF_PRIVATE */
278 typedef struct s_Rlmt_PacketInfo
{
279 unsigned PacketLength
; /* Length of packet. */
280 unsigned PacketType
; /* Directed/Multicast/Broadcast. */
282 #endif /* SK_LA_INFO */
285 typedef struct s_RootId
{
286 SK_U8 Id
[8]; /* Root Bridge Id. */
290 typedef struct s_port
{
291 SK_MAC_ADDR CheckAddr
;
296 typedef struct s_RlmtNet SK_RLMT_NET
;
299 typedef struct s_RlmtPort
{
301 /* ----- Public part (read-only) ----- */
303 SK_U8 PortState
; /* Current state of this port. */
310 SK_U32 PortNumber
; /* Number of port on adapter. */
311 SK_RLMT_NET
* Net
; /* Net port belongs to. */
315 SK_U64 TxSpHelloReqCts
;
318 /* ----- Private part ----- */
320 /* SK_U64 PacketsRx; */ /* Total packets received. */
321 SK_U32 PacketsPerTimeSlot
; /* Packets rxed between TOs. */
322 /* SK_U32 DataPacketsPerTimeSlot; */ /* Data packets ... */
323 SK_U32 BpduPacketsPerTimeSlot
; /* BPDU packets rxed in TS. */
324 SK_U64 BcTimeStamp
; /* Time of last BC receive. */
325 SK_U64 GuTimeStamp
; /* Time of entering GOING_UP. */
327 SK_TIMER UpTimer
; /* Timer struct Link/Port up. */
328 SK_TIMER DownRxTimer
; /* Timer struct down rx. */
329 SK_TIMER DownTxTimer
; /* Timer struct down tx. */
331 SK_U32 CheckingState
; /* Checking State. */
333 SK_ADDR_PORT
* AddrPort
;
335 SK_U8 Random
[4]; /* Random value. */
336 unsigned PortsChecked
; /* #ports checked. */
337 unsigned PortsSuspect
; /* #ports checked that are s. */
338 SK_PORT_CHECK PortCheck
[1];
339 /* SK_PORT_CHECK PortCheck[SK_MAX_MACS - 1]; */
341 SK_BOOL PortStarted
; /* Port is started. */
342 SK_BOOL PortNoRx
; /* NoRx for >= 1 time slot. */
344 SK_RLMT_ROOT_ID Root
; /* Root Bridge Id. */
350 /* ----- Public part (read-only) ----- */
352 SK_U32 NetNumber
; /* Number of net. */
354 SK_RLMT_PORT
* Port
[SK_MAX_MACS
]; /* Ports that belong to this net. */
355 SK_U32 NumPorts
; /* Number of ports. */
356 SK_U32 PrefPort
; /* Preferred port. */
360 SK_U32 ChgBcPrio
; /* Change Priority of last broadcast received */
361 SK_U32 RlmtMode
; /* Check ... */
362 SK_U32 ActivePort
; /* Active port. */
363 SK_U32 Preference
; /* 0xFFFFFFFF: Automatic. */
365 SK_U8 RlmtState
; /* Current RLMT state. */
367 /* ----- Private part ----- */
371 int LinksUp
; /* #Links up. */
372 int PortsUp
; /* #Ports up. */
373 SK_U32 TimeoutValue
; /* RLMT timeout value. */
375 SK_U32 CheckingState
; /* Checking State. */
376 SK_RLMT_ROOT_ID Root
; /* Root Bridge Id. */
378 SK_TIMER LocTimer
; /* Timer struct. */
379 SK_TIMER SegTimer
; /* Timer struct. */
383 typedef struct s_Rlmt
{
385 /* ----- Public part (read-only) ----- */
387 SK_U32 NumNets
; /* Number of nets. */
388 SK_U32 NetsStarted
; /* Number of nets started. */
389 SK_RLMT_NET Net
[SK_MAX_NETS
]; /* Array of available nets. */
390 SK_RLMT_PORT Port
[SK_MAX_MACS
]; /* Array of available ports. */
392 /* ----- Private part ----- */
394 SK_BOOL RlmtOff
; /* set to zero if the Mac addresses
395 are equal or the second one
402 extern SK_MAC_ADDR BridgeMcAddr
;
403 extern SK_MAC_ADDR SkRlmtMcAddr
;
405 /* function prototypes ********************************************************/
410 /* Functions provided by SkRlmt */
412 /* ANSI/C++ compliant function prototypes */
414 extern void SkRlmtInit(
419 extern int SkRlmtEvent(
425 #else /* defined(SK_KR_PROTO) */
427 /* Non-ANSI/C++ compliant function prototypes */
429 #error KR-style function prototypes are not yet provided.
431 #endif /* defined(SK_KR_PROTO)) */
436 #endif /* __cplusplus */
438 #endif /* __INC_SKRLMT_H */