Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / net / sk98lin / h / skrlmt.h
blobca75dfdcf2d6a4e1e1fd7dd7dbd4e95690836193
1 /******************************************************************************
3 * Name: skrlmt.h
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 /******************************************************************************
27 * Description:
29 * This is the header file for Redundant Link ManagemenT.
31 * Include File Hierarchy:
33 * "skdrv1st.h"
34 * ...
35 * "sktypes.h"
36 * "skqueue.h"
37 * "skaddr.h"
38 * "skrlmt.h"
39 * ...
40 * "skdrv2nd.h"
42 ******************************************************************************/
44 #ifndef __INC_SKRLMT_H
45 #define __INC_SKRLMT_H
47 #ifdef __cplusplus
48 extern "C" {
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). */
136 Name of define TBD!
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. */
141 Name of define TBD!
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. */
152 /* Macros */
154 #if 0
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 */
161 #endif /* 0 */
163 #define SK_RLMT_PRE_LOOKAHEAD(pAC,PortNum,PktLen,IsBc,pOffset,pNumBytes) { \
164 SK_AC *_pAC; \
165 SK_U32 _PortNum; \
166 _pAC = (pAC); \
167 _PortNum = (SK_U32)(PortNum); \
168 /* _pAC->Rlmt.Port[_PortNum].PacketsRx++; */ \
169 _pAC->Rlmt.Port[_PortNum].PacketsPerTimeSlot++; \
170 if (_pAC->Rlmt.RlmtOff) { \
171 *(pNumBytes) = 0; \
173 else {\
174 if ((_pAC->Rlmt.Port[_PortNum].Net->RlmtMode & SK_RLMT_TRANSPARENT) != 0) { \
175 *(pNumBytes) = 0; \
177 else if (IsBc) { \
178 if (_pAC->Rlmt.Port[_PortNum].Net->RlmtMode != SK_RLMT_MODE_CLS) { \
179 *(pNumBytes) = 6; \
180 *(pOffset) = 6; \
182 else { \
183 *(pNumBytes) = 0; \
186 else { \
187 if ((PktLen) > SK_RLMT_MAX_TX_BUF_SIZE) { \
188 /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \
189 *(pNumBytes) = 0; \
191 else { \
192 *(pNumBytes) = 6; \
193 *(pOffset) = 0; \
199 #if 0
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.
212 #endif /* 0 */
214 #define SK_RLMT_LOOKAHEAD(pAC,PortNum,pLaPacket,IsBc,IsMc,pForRlmt) { \
215 SK_AC *_pAC; \
216 SK_U32 _PortNum; \
217 SK_U8 *_pLaPacket; \
218 _pAC = (pAC); \
219 _PortNum = (SK_U32)(PortNum); \
220 _pLaPacket = (SK_U8 *)(pLaPacket); \
221 if (IsBc) {\
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; \
230 else if (IsMc) { \
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; \
236 else { \
237 *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \
240 else if (SK_ADDR_EQUAL(_pLaPacket, SkRlmtMcAddr.a)) { \
241 *(pForRlmt) = SK_RLMT_RX_RLMT; \
243 else { \
244 /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \
245 *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \
248 else { \
249 if (SK_ADDR_EQUAL( \
250 _pLaPacket, \
251 _pAC->Addr.Port[_PortNum].CurrentMacAddress.a)) { \
252 *(pForRlmt) = SK_RLMT_RX_RLMT; \
254 else { \
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 {
272 some content
273 } SK_RLMT_MBUF;
274 #endif /* SK_RLMT_MBUF_PRIVATE */
277 #ifdef SK_LA_INFO
278 typedef struct s_Rlmt_PacketInfo {
279 unsigned PacketLength; /* Length of packet. */
280 unsigned PacketType; /* Directed/Multicast/Broadcast. */
281 } SK_RLMT_PINFO;
282 #endif /* SK_LA_INFO */
285 typedef struct s_RootId {
286 SK_U8 Id[8]; /* Root Bridge Id. */
287 } SK_RLMT_ROOT_ID;
290 typedef struct s_port {
291 SK_MAC_ADDR CheckAddr;
292 SK_BOOL SuspectTx;
293 } SK_PORT_CHECK;
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. */
305 /* For PNMI */
306 SK_BOOL LinkDown;
307 SK_BOOL PortDown;
308 SK_U8 Align01;
310 SK_U32 PortNumber; /* Number of port on adapter. */
311 SK_RLMT_NET * Net; /* Net port belongs to. */
313 SK_U64 TxHelloCts;
314 SK_U64 RxHelloCts;
315 SK_U64 TxSpHelloReqCts;
316 SK_U64 RxSpHelloCts;
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. */
343 SK_BOOL RootIdSet;
344 SK_RLMT_ROOT_ID Root; /* Root Bridge Id. */
345 } SK_RLMT_PORT;
348 struct s_RlmtNet {
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. */
358 /* For PNMI */
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 ----- */
368 SK_BOOL RootIdSet;
369 SK_U16 Align01;
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 ----- */
393 SK_BOOL CheckSwitch;
394 SK_BOOL RlmtOff; /* set to zero if the Mac addresses
395 are equal or the second one
396 is zero */
397 SK_U16 Align01;
399 } SK_RLMT;
402 extern SK_MAC_ADDR BridgeMcAddr;
403 extern SK_MAC_ADDR SkRlmtMcAddr;
405 /* function prototypes ********************************************************/
408 #ifndef SK_KR_PROTO
410 /* Functions provided by SkRlmt */
412 /* ANSI/C++ compliant function prototypes */
414 extern void SkRlmtInit(
415 SK_AC *pAC,
416 SK_IOC IoC,
417 int Level);
419 extern int SkRlmtEvent(
420 SK_AC *pAC,
421 SK_IOC IoC,
422 SK_U32 Event,
423 SK_EVPARA Para);
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)) */
434 #ifdef __cplusplus
436 #endif /* __cplusplus */
438 #endif /* __INC_SKRLMT_H */