Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 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. |
| 8 | * |
| 9 | ******************************************************************************/ |
| 10 | |
| 11 | /****************************************************************************** |
| 12 | * |
| 13 | * (C)Copyright 1998-2002 SysKonnect GmbH. |
| 14 | * (C)Copyright 2002-2003 Marvell. |
| 15 | * |
| 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. |
| 20 | * |
| 21 | * The information in this file is provided "AS IS" without warranty. |
| 22 | * |
| 23 | ******************************************************************************/ |
| 24 | |
| 25 | /****************************************************************************** |
| 26 | * |
| 27 | * Description: |
| 28 | * |
| 29 | * This is the header file for Redundant Link ManagemenT. |
| 30 | * |
| 31 | * Include File Hierarchy: |
| 32 | * |
| 33 | * "skdrv1st.h" |
| 34 | * ... |
| 35 | * "sktypes.h" |
| 36 | * "skqueue.h" |
| 37 | * "skaddr.h" |
| 38 | * "skrlmt.h" |
| 39 | * ... |
| 40 | * "skdrv2nd.h" |
| 41 | * |
| 42 | ******************************************************************************/ |
| 43 | |
| 44 | #ifndef __INC_SKRLMT_H |
| 45 | #define __INC_SKRLMT_H |
| 46 | |
| 47 | #ifdef __cplusplus |
| 48 | extern "C" { |
| 49 | #endif /* cplusplus */ |
| 50 | |
| 51 | /* defines ********************************************************************/ |
| 52 | |
| 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. */ |
| 55 | |
| 56 | /* ----- Default queue sizes - must be multiples of 8 KB ----- */ |
| 57 | |
| 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. */ |
| 62 | |
| 63 | #define SK_RLMT_MAX_TX_BUF_SIZE 60 /* Maximum RLMT transmit size. */ |
| 64 | |
| 65 | /* ----- PORT states ----- */ |
| 66 | |
| 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. */ |
| 72 | |
| 73 | /* ----- RLMT states ----- */ |
| 74 | |
| 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. */ |
| 78 | |
| 79 | /* ----- PORT events ----- */ |
| 80 | |
| 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. */ |
| 84 | |
| 85 | /* ----- RLMT events ----- */ |
| 86 | |
| 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). */ |
| 95 | |
| 96 | /* ----- RLMT mode bits ----- */ |
| 97 | |
| 98 | /* |
| 99 | * CAUTION: These defines are private to RLMT. |
| 100 | * Please use the RLMT mode defines below. |
| 101 | */ |
| 102 | |
| 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. */ |
| 106 | |
| 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 */ |
| 115 | |
| 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 */ |
| 121 | |
| 122 | /* ----- RLMT modes ----- */ |
| 123 | |
| 124 | /* Check Link State. */ |
| 125 | #define SK_RLMT_MODE_CLS (SK_RLMT_CHECK_LINK) |
| 126 | |
| 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) |
| 129 | |
| 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) |
| 133 | |
| 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) |
| 139 | |
| 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 */ |
| 146 | |
| 147 | /* ----- RLMT lookahead result bits ----- */ |
| 148 | |
| 149 | #define SK_RLMT_RX_RLMT 1 /* Give packet to RLMT. */ |
| 150 | #define SK_RLMT_RX_PROTOCOL 2 /* Give packet to protocol. */ |
| 151 | |
| 152 | /* Macros */ |
| 153 | |
| 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 */ |
| 162 | |
| 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; \ |
| 172 | } \ |
| 173 | else {\ |
| 174 | if ((_pAC->Rlmt.Port[_PortNum].Net->RlmtMode & SK_RLMT_TRANSPARENT) != 0) { \ |
| 175 | *(pNumBytes) = 0; \ |
| 176 | } \ |
| 177 | else if (IsBc) { \ |
| 178 | if (_pAC->Rlmt.Port[_PortNum].Net->RlmtMode != SK_RLMT_MODE_CLS) { \ |
| 179 | *(pNumBytes) = 6; \ |
| 180 | *(pOffset) = 6; \ |
| 181 | } \ |
| 182 | else { \ |
| 183 | *(pNumBytes) = 0; \ |
| 184 | } \ |
| 185 | } \ |
| 186 | else { \ |
| 187 | if ((PktLen) > SK_RLMT_MAX_TX_BUF_SIZE) { \ |
| 188 | /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \ |
| 189 | *(pNumBytes) = 0; \ |
| 190 | } \ |
| 191 | else { \ |
| 192 | *(pNumBytes) = 6; \ |
| 193 | *(pOffset) = 0; \ |
| 194 | } \ |
| 195 | } \ |
| 196 | } \ |
| 197 | } |
| 198 | |
| 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. |
| 208 | |
| 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 */ |
| 213 | |
| 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; \ |
| 226 | } \ |
| 227 | /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \ |
| 228 | *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \ |
| 229 | } \ |
| 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; \ |
| 235 | } \ |
| 236 | else { \ |
| 237 | *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \ |
| 238 | } \ |
| 239 | } \ |
| 240 | else if (SK_ADDR_EQUAL(_pLaPacket, SkRlmtMcAddr.a)) { \ |
| 241 | *(pForRlmt) = SK_RLMT_RX_RLMT; \ |
| 242 | } \ |
| 243 | else { \ |
| 244 | /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \ |
| 245 | *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \ |
| 246 | } \ |
| 247 | } \ |
| 248 | else { \ |
| 249 | if (SK_ADDR_EQUAL( \ |
| 250 | _pLaPacket, \ |
| 251 | _pAC->Addr.Port[_PortNum].CurrentMacAddress.a)) { \ |
| 252 | *(pForRlmt) = SK_RLMT_RX_RLMT; \ |
| 253 | } \ |
| 254 | else { \ |
| 255 | /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \ |
| 256 | *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \ |
| 257 | } \ |
| 258 | } \ |
| 259 | } |
| 260 | |
| 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 */ |
| 267 | |
| 268 | /* typedefs *******************************************************************/ |
| 269 | |
| 270 | #ifdef SK_RLMT_MBUF_PRIVATE |
| 271 | typedef struct s_RlmtMbuf { |
| 272 | some content |
| 273 | } SK_RLMT_MBUF; |
| 274 | #endif /* SK_RLMT_MBUF_PRIVATE */ |
| 275 | |
| 276 | |
| 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 */ |
| 283 | |
| 284 | |
| 285 | typedef struct s_RootId { |
| 286 | SK_U8 Id[8]; /* Root Bridge Id. */ |
| 287 | } SK_RLMT_ROOT_ID; |
| 288 | |
| 289 | |
| 290 | typedef struct s_port { |
| 291 | SK_MAC_ADDR CheckAddr; |
| 292 | SK_BOOL SuspectTx; |
| 293 | } SK_PORT_CHECK; |
| 294 | |
| 295 | |
| 296 | typedef struct s_RlmtNet SK_RLMT_NET; |
| 297 | |
| 298 | |
| 299 | typedef struct s_RlmtPort { |
| 300 | |
| 301 | /* ----- Public part (read-only) ----- */ |
| 302 | |
| 303 | SK_U8 PortState; /* Current state of this port. */ |
| 304 | |
| 305 | /* For PNMI */ |
| 306 | SK_BOOL LinkDown; |
| 307 | SK_BOOL PortDown; |
| 308 | SK_U8 Align01; |
| 309 | |
| 310 | SK_U32 PortNumber; /* Number of port on adapter. */ |
| 311 | SK_RLMT_NET * Net; /* Net port belongs to. */ |
| 312 | |
| 313 | SK_U64 TxHelloCts; |
| 314 | SK_U64 RxHelloCts; |
| 315 | SK_U64 TxSpHelloReqCts; |
| 316 | SK_U64 RxSpHelloCts; |
| 317 | |
| 318 | /* ----- Private part ----- */ |
| 319 | |
| 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. */ |
| 326 | |
| 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. */ |
| 330 | |
| 331 | SK_U32 CheckingState; /* Checking State. */ |
| 332 | |
| 333 | SK_ADDR_PORT * AddrPort; |
| 334 | |
| 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]; */ |
| 340 | |
| 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; |
| 346 | |
| 347 | |
| 348 | struct s_RlmtNet { |
| 349 | |
| 350 | /* ----- Public part (read-only) ----- */ |
| 351 | |
| 352 | SK_U32 NetNumber; /* Number of net. */ |
| 353 | |
| 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. */ |
| 357 | |
| 358 | /* For PNMI */ |
| 359 | |
| 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. */ |
| 364 | |
| 365 | SK_U8 RlmtState; /* Current RLMT state. */ |
| 366 | |
| 367 | /* ----- Private part ----- */ |
| 368 | SK_BOOL RootIdSet; |
| 369 | SK_U16 Align01; |
| 370 | |
| 371 | int LinksUp; /* #Links up. */ |
| 372 | int PortsUp; /* #Ports up. */ |
| 373 | SK_U32 TimeoutValue; /* RLMT timeout value. */ |
| 374 | |
| 375 | SK_U32 CheckingState; /* Checking State. */ |
| 376 | SK_RLMT_ROOT_ID Root; /* Root Bridge Id. */ |
| 377 | |
| 378 | SK_TIMER LocTimer; /* Timer struct. */ |
| 379 | SK_TIMER SegTimer; /* Timer struct. */ |
| 380 | }; |
| 381 | |
| 382 | |
| 383 | typedef struct s_Rlmt { |
| 384 | |
| 385 | /* ----- Public part (read-only) ----- */ |
| 386 | |
| 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. */ |
| 391 | |
| 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; |
| 398 | |
| 399 | } SK_RLMT; |
| 400 | |
| 401 | |
| 402 | extern SK_MAC_ADDR BridgeMcAddr; |
| 403 | extern SK_MAC_ADDR SkRlmtMcAddr; |
| 404 | |
| 405 | /* function prototypes ********************************************************/ |
| 406 | |
| 407 | |
| 408 | #ifndef SK_KR_PROTO |
| 409 | |
| 410 | /* Functions provided by SkRlmt */ |
| 411 | |
| 412 | /* ANSI/C++ compliant function prototypes */ |
| 413 | |
| 414 | extern void SkRlmtInit( |
| 415 | SK_AC *pAC, |
| 416 | SK_IOC IoC, |
| 417 | int Level); |
| 418 | |
| 419 | extern int SkRlmtEvent( |
| 420 | SK_AC *pAC, |
| 421 | SK_IOC IoC, |
| 422 | SK_U32 Event, |
| 423 | SK_EVPARA Para); |
| 424 | |
| 425 | #else /* defined(SK_KR_PROTO) */ |
| 426 | |
| 427 | /* Non-ANSI/C++ compliant function prototypes */ |
| 428 | |
| 429 | #error KR-style function prototypes are not yet provided. |
| 430 | |
| 431 | #endif /* defined(SK_KR_PROTO)) */ |
| 432 | |
| 433 | |
| 434 | #ifdef __cplusplus |
| 435 | } |
| 436 | #endif /* __cplusplus */ |
| 437 | |
| 438 | #endif /* __INC_SKRLMT_H */ |