1 /****************************************************************************** 2 * 3 * Name: skrlmt.h 4 * Project: GEnesis, PCI Gigabit Ethernet Adapter 5 * Purpose: Header file for Redundant Link ManagemenT. 6 * 7 ******************************************************************************/ 8 9 /****************************************************************************** 10 * 11 * (C)Copyright 1998-2002 SysKonnect GmbH. 12 * (C)Copyright 2002-2003 Marvell. 13 * 14 * This program is free software; you can redistribute it and/or modify 15 * it under the terms of the GNU General Public License as published by 16 * the Free Software Foundation; either version 2 of the License, or 17 * (at your option) any later version. 18 * 19 * The information in this file is provided "AS IS" without warranty. 20 * 21 ******************************************************************************/ 22 23 /****************************************************************************** 24 * 25 * Description: 26 * 27 * This is the header file for Redundant Link ManagemenT. 28 * 29 * Include File Hierarchy: 30 * 31 * "skdrv1st.h" 32 * ... 33 * "sktypes.h" 34 * "skqueue.h" 35 * "skaddr.h" 36 * "skrlmt.h" 37 * ... 38 * "skdrv2nd.h" 39 * 40 ******************************************************************************/ 41 42 #ifndef __INC_SKRLMT_H 43 #define __INC_SKRLMT_H 44 45 #ifdef __cplusplus 46 extern "C" { 47 #endif /* cplusplus */ 48 49 /* defines ********************************************************************/ 50 51 #define SK_RLMT_NET_DOWN_TEMP 1 /* NET_DOWN due to last port down. */ 52 #define SK_RLMT_NET_DOWN_FINAL 2 /* NET_DOWN due to RLMT_STOP. */ 53 54 /* ----- Default queue sizes - must be multiples of 8 KB ----- */ 55 56 /* Less than 8 KB free in RX queue => pause frames. */ 57 #define SK_RLMT_STANDBY_QRXSIZE 128 /* Size of rx standby queue in KB. */ 58 #define SK_RLMT_STANDBY_QXASIZE 32 /* Size of async standby queue in KB. */ 59 #define SK_RLMT_STANDBY_QXSSIZE 0 /* Size of sync standby queue in KB. */ 60 61 #define SK_RLMT_MAX_TX_BUF_SIZE 60 /* Maximum RLMT transmit size. */ 62 63 /* ----- PORT states ----- */ 64 65 #define SK_RLMT_PS_INIT 0 /* Port state: Init. */ 66 #define SK_RLMT_PS_LINK_DOWN 1 /* Port state: Link down. */ 67 #define SK_RLMT_PS_DOWN 2 /* Port state: Port down. */ 68 #define SK_RLMT_PS_GOING_UP 3 /* Port state: Going up. */ 69 #define SK_RLMT_PS_UP 4 /* Port state: Up. */ 70 71 /* ----- RLMT states ----- */ 72 73 #define SK_RLMT_RS_INIT 0 /* RLMT state: Init. */ 74 #define SK_RLMT_RS_NET_DOWN 1 /* RLMT state: Net down. */ 75 #define SK_RLMT_RS_NET_UP 2 /* RLMT state: Net up. */ 76 77 /* ----- PORT events ----- */ 78 79 #define SK_RLMT_LINK_UP 1001 /* Link came up. */ 80 #define SK_RLMT_LINK_DOWN 1002 /* Link went down. */ 81 #define SK_RLMT_PORT_ADDR 1003 /* Port address changed. */ 82 83 /* ----- RLMT events ----- */ 84 85 #define SK_RLMT_START 2001 /* Start RLMT. */ 86 #define SK_RLMT_STOP 2002 /* Stop RLMT. */ 87 #define SK_RLMT_PACKET_RECEIVED 2003 /* Packet was received for RLMT. */ 88 #define SK_RLMT_STATS_CLEAR 2004 /* Clear statistics. */ 89 #define SK_RLMT_STATS_UPDATE 2005 /* Update statistics. */ 90 #define SK_RLMT_PREFPORT_CHANGE 2006 /* Change preferred port. */ 91 #define SK_RLMT_MODE_CHANGE 2007 /* New RlmtMode. */ 92 #define SK_RLMT_SET_NETS 2008 /* Number of Nets (1 or 2). */ 93 94 /* ----- RLMT mode bits ----- */ 95 96 /* 97 * CAUTION: These defines are private to RLMT. 98 * Please use the RLMT mode defines below. 99 */ 100 101 #define SK_RLMT_CHECK_LINK 1 /* Check Link. */ 102 #define SK_RLMT_CHECK_LOC_LINK 2 /* Check other link on same adapter. */ 103 #define SK_RLMT_CHECK_SEG 4 /* Check segmentation. */ 104 105 #ifndef RLMT_CHECK_REMOTE 106 #define SK_RLMT_CHECK_OTHERS SK_RLMT_CHECK_LOC_LINK 107 #else /* RLMT_CHECK_REMOTE */ 108 #define SK_RLMT_CHECK_REM_LINK 8 /* Check link(s) on other adapter(s). */ 109 #define SK_RLMT_MAX_REMOTE_PORTS_CHECKED 3 110 #define SK_RLMT_CHECK_OTHERS \ 111 (SK_RLMT_CHECK_LOC_LINK | SK_RLMT_CHECK_REM_LINK) 112 #endif /* RLMT_CHECK_REMOTE */ 113 114 #ifndef SK_RLMT_ENABLE_TRANSPARENT 115 #define SK_RLMT_TRANSPARENT 0 /* RLMT transparent - inactive. */ 116 #else /* SK_RLMT_ENABLE_TRANSPARENT */ 117 #define SK_RLMT_TRANSPARENT 128 /* RLMT transparent. */ 118 #endif /* SK_RLMT_ENABLE_TRANSPARENT */ 119 120 /* ----- RLMT modes ----- */ 121 122 /* Check Link State. */ 123 #define SK_RLMT_MODE_CLS (SK_RLMT_CHECK_LINK) 124 125 /* Check Local Ports: check other links on the same adapter. */ 126 #define SK_RLMT_MODE_CLP (SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK) 127 128 /* Check Local Ports and Segmentation Status. */ 129 #define SK_RLMT_MODE_CLPSS \ 130 (SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK | SK_RLMT_CHECK_SEG) 131 132 #ifdef RLMT_CHECK_REMOTE 133 /* Check Local and Remote Ports: check links (local or remote). */ 134 Name of define TBD! 135 #define SK_RLMT_MODE_CRP \ 136 (SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK | SK_RLMT_CHECK_REM_LINK) 137 138 /* Check Local and Remote Ports and Segmentation Status. */ 139 Name of define TBD! 140 #define SK_RLMT_MODE_CRPSS \ 141 (SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK | \ 142 SK_RLMT_CHECK_REM_LINK | SK_RLMT_CHECK_SEG) 143 #endif /* RLMT_CHECK_REMOTE */ 144 145 /* ----- RLMT lookahead result bits ----- */ 146 147 #define SK_RLMT_RX_RLMT 1 /* Give packet to RLMT. */ 148 #define SK_RLMT_RX_PROTOCOL 2 /* Give packet to protocol. */ 149 150 /* Macros */ 151 152 #if 0 153 SK_AC *pAC /* adapter context */ 154 SK_U32 PortNum /* receiving port */ 155 unsigned PktLen /* received packet's length */ 156 SK_BOOL IsBc /* Flag: packet is broadcast */ 157 unsigned *pOffset /* offs. of bytes to present to SK_RLMT_LOOKAHEAD */ 158 unsigned *pNumBytes /* #Bytes to present to SK_RLMT_LOOKAHEAD */ 159 #endif /* 0 */ 160 161 #define SK_RLMT_PRE_LOOKAHEAD(pAC,PortNum,PktLen,IsBc,pOffset,pNumBytes) { \ 162 SK_AC *_pAC; \ 163 SK_U32 _PortNum; \ 164 _pAC = (pAC); \ 165 _PortNum = (SK_U32)(PortNum); \ 166 /* _pAC->Rlmt.Port[_PortNum].PacketsRx++; */ \ 167 _pAC->Rlmt.Port[_PortNum].PacketsPerTimeSlot++; \ 168 if (_pAC->Rlmt.RlmtOff) { \ 169 *(pNumBytes) = 0; \ 170 } \ 171 else {\ 172 if ((_pAC->Rlmt.Port[_PortNum].Net->RlmtMode & SK_RLMT_TRANSPARENT) != 0) { \ 173 *(pNumBytes) = 0; \ 174 } \ 175 else if (IsBc) { \ 176 if (_pAC->Rlmt.Port[_PortNum].Net->RlmtMode != SK_RLMT_MODE_CLS) { \ 177 *(pNumBytes) = 6; \ 178 *(pOffset) = 6; \ 179 } \ 180 else { \ 181 *(pNumBytes) = 0; \ 182 } \ 183 } \ 184 else { \ 185 if ((PktLen) > SK_RLMT_MAX_TX_BUF_SIZE) { \ 186 /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \ 187 *(pNumBytes) = 0; \ 188 } \ 189 else { \ 190 *(pNumBytes) = 6; \ 191 *(pOffset) = 0; \ 192 } \ 193 } \ 194 } \ 195 } 196 197 #if 0 198 SK_AC *pAC /* adapter context */ 199 SK_U32 PortNum /* receiving port */ 200 SK_U8 *pLaPacket, /* received packet's data (points to pOffset) */ 201 SK_BOOL IsBc /* Flag: packet is broadcast */ 202 SK_BOOL IsMc /* Flag: packet is multicast */ 203 unsigned *pForRlmt /* Result: bits SK_RLMT_RX_RLMT, SK_RLMT_RX_PROTOCOL */ 204 SK_RLMT_LOOKAHEAD() expects *pNumBytes from 205 packet offset *pOffset (s.a.) at *pLaPacket. 206 207 If you use SK_RLMT_LOOKAHEAD in a path where you already know if the packet is 208 BC, MC, or UC, you should use constants for IsBc and IsMc, so that your compiler 209 can trash unneeded parts of the if construction. 210 #endif /* 0 */ 211 212 #define SK_RLMT_LOOKAHEAD(pAC,PortNum,pLaPacket,IsBc,IsMc,pForRlmt) { \ 213 SK_AC *_pAC; \ 214 SK_U32 _PortNum; \ 215 SK_U8 *_pLaPacket; \ 216 _pAC = (pAC); \ 217 _PortNum = (SK_U32)(PortNum); \ 218 _pLaPacket = (SK_U8 *)(pLaPacket); \ 219 if (IsBc) {\ 220 if (!SK_ADDR_EQUAL(_pLaPacket, _pAC->Addr.Net[_pAC->Rlmt.Port[ \ 221 _PortNum].Net->NetNumber].CurrentMacAddress.a)) { \ 222 _pAC->Rlmt.Port[_PortNum].BcTimeStamp = SkOsGetTime(_pAC); \ 223 _pAC->Rlmt.CheckSwitch = SK_TRUE; \ 224 } \ 225 /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \ 226 *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \ 227 } \ 228 else if (IsMc) { \ 229 if (SK_ADDR_EQUAL(_pLaPacket, BridgeMcAddr.a)) { \ 230 _pAC->Rlmt.Port[_PortNum].BpduPacketsPerTimeSlot++; \ 231 if (_pAC->Rlmt.Port[_PortNum].Net->RlmtMode & SK_RLMT_CHECK_SEG) { \ 232 *(pForRlmt) = SK_RLMT_RX_RLMT | SK_RLMT_RX_PROTOCOL; \ 233 } \ 234 else { \ 235 *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \ 236 } \ 237 } \ 238 else if (SK_ADDR_EQUAL(_pLaPacket, SkRlmtMcAddr.a)) { \ 239 *(pForRlmt) = SK_RLMT_RX_RLMT; \ 240 } \ 241 else { \ 242 /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \ 243 *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \ 244 } \ 245 } \ 246 else { \ 247 if (SK_ADDR_EQUAL( \ 248 _pLaPacket, \ 249 _pAC->Addr.Port[_PortNum].CurrentMacAddress.a)) { \ 250 *(pForRlmt) = SK_RLMT_RX_RLMT; \ 251 } \ 252 else { \ 253 /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \ 254 *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \ 255 } \ 256 } \ 257 } 258 259 #ifdef SK_RLMT_FAST_LOOKAHEAD 260 Error: SK_RLMT_FAST_LOOKAHEAD no longer used. Use new macros for lookahead. 261 #endif /* SK_RLMT_FAST_LOOKAHEAD */ 262 #ifdef SK_RLMT_SLOW_LOOKAHEAD 263 Error: SK_RLMT_SLOW_LOOKAHEAD no longer used. Use new macros for lookahead. 264 #endif /* SK_RLMT_SLOW_LOOKAHEAD */ 265 266 /* typedefs *******************************************************************/ 267 268 #ifdef SK_RLMT_MBUF_PRIVATE 269 typedef struct s_RlmtMbuf { 270 some content 271 } SK_RLMT_MBUF; 272 #endif /* SK_RLMT_MBUF_PRIVATE */ 273 274 275 #ifdef SK_LA_INFO 276 typedef struct s_Rlmt_PacketInfo { 277 unsigned PacketLength; /* Length of packet. */ 278 unsigned PacketType; /* Directed/Multicast/Broadcast. */ 279 } SK_RLMT_PINFO; 280 #endif /* SK_LA_INFO */ 281 282 283 typedef struct s_RootId { 284 SK_U8 Id[8]; /* Root Bridge Id. */ 285 } SK_RLMT_ROOT_ID; 286 287 288 typedef struct s_port { 289 SK_MAC_ADDR CheckAddr; 290 SK_BOOL SuspectTx; 291 } SK_PORT_CHECK; 292 293 294 typedef struct s_RlmtNet SK_RLMT_NET; 295 296 297 typedef struct s_RlmtPort { 298 299 /* ----- Public part (read-only) ----- */ 300 301 SK_U8 PortState; /* Current state of this port. */ 302 303 /* For PNMI */ 304 SK_BOOL LinkDown; 305 SK_BOOL PortDown; 306 SK_U8 Align01; 307 308 SK_U32 PortNumber; /* Number of port on adapter. */ 309 SK_RLMT_NET * Net; /* Net port belongs to. */ 310 311 SK_U64 TxHelloCts; 312 SK_U64 RxHelloCts; 313 SK_U64 TxSpHelloReqCts; 314 SK_U64 RxSpHelloCts; 315 316 /* ----- Private part ----- */ 317 318 /* SK_U64 PacketsRx; */ /* Total packets received. */ 319 SK_U32 PacketsPerTimeSlot; /* Packets rxed between TOs. */ 320 /* SK_U32 DataPacketsPerTimeSlot; */ /* Data packets ... */ 321 SK_U32 BpduPacketsPerTimeSlot; /* BPDU packets rxed in TS. */ 322 SK_U64 BcTimeStamp; /* Time of last BC receive. */ 323 SK_U64 GuTimeStamp; /* Time of entering GOING_UP. */ 324 325 SK_TIMER UpTimer; /* Timer struct Link/Port up. */ 326 SK_TIMER DownRxTimer; /* Timer struct down rx. */ 327 SK_TIMER DownTxTimer; /* Timer struct down tx. */ 328 329 SK_U32 CheckingState; /* Checking State. */ 330 331 SK_ADDR_PORT * AddrPort; 332 333 SK_U8 Random[4]; /* Random value. */ 334 unsigned PortsChecked; /* #ports checked. */ 335 unsigned PortsSuspect; /* #ports checked that are s. */ 336 SK_PORT_CHECK PortCheck[1]; 337 /* SK_PORT_CHECK PortCheck[SK_MAX_MACS - 1]; */ 338 339 SK_BOOL PortStarted; /* Port is started. */ 340 SK_BOOL PortNoRx; /* NoRx for >= 1 time slot. */ 341 SK_BOOL RootIdSet; 342 SK_RLMT_ROOT_ID Root; /* Root Bridge Id. */ 343 } SK_RLMT_PORT; 344 345 346 struct s_RlmtNet { 347 348 /* ----- Public part (read-only) ----- */ 349 350 SK_U32 NetNumber; /* Number of net. */ 351 352 SK_RLMT_PORT * Port[SK_MAX_MACS]; /* Ports that belong to this net. */ 353 SK_U32 NumPorts; /* Number of ports. */ 354 SK_U32 PrefPort; /* Preferred port. */ 355 356 /* For PNMI */ 357 358 SK_U32 ChgBcPrio; /* Change Priority of last broadcast received */ 359 SK_U32 RlmtMode; /* Check ... */ 360 SK_U32 ActivePort; /* Active port. */ 361 SK_U32 Preference; /* 0xFFFFFFFF: Automatic. */ 362 363 SK_U8 RlmtState; /* Current RLMT state. */ 364 365 /* ----- Private part ----- */ 366 SK_BOOL RootIdSet; 367 SK_U16 Align01; 368 369 int LinksUp; /* #Links up. */ 370 int PortsUp; /* #Ports up. */ 371 SK_U32 TimeoutValue; /* RLMT timeout value. */ 372 373 SK_U32 CheckingState; /* Checking State. */ 374 SK_RLMT_ROOT_ID Root; /* Root Bridge Id. */ 375 376 SK_TIMER LocTimer; /* Timer struct. */ 377 SK_TIMER SegTimer; /* Timer struct. */ 378 }; 379 380 381 typedef struct s_Rlmt { 382 383 /* ----- Public part (read-only) ----- */ 384 385 SK_U32 NumNets; /* Number of nets. */ 386 SK_U32 NetsStarted; /* Number of nets started. */ 387 SK_RLMT_NET Net[SK_MAX_NETS]; /* Array of available nets. */ 388 SK_RLMT_PORT Port[SK_MAX_MACS]; /* Array of available ports. */ 389 390 /* ----- Private part ----- */ 391 SK_BOOL CheckSwitch; 392 SK_BOOL RlmtOff; /* set to zero if the Mac addresses 393 are equal or the second one 394 is zero */ 395 SK_U16 Align01; 396 397 } SK_RLMT; 398 399 400 extern SK_MAC_ADDR BridgeMcAddr; 401 extern SK_MAC_ADDR SkRlmtMcAddr; 402 403 /* function prototypes ********************************************************/ 404 405 406 #ifndef SK_KR_PROTO 407 408 /* Functions provided by SkRlmt */ 409 410 /* ANSI/C++ compliant function prototypes */ 411 412 extern void SkRlmtInit( 413 SK_AC *pAC, 414 SK_IOC IoC, 415 int Level); 416 417 extern int SkRlmtEvent( 418 SK_AC *pAC, 419 SK_IOC IoC, 420 SK_U32 Event, 421 SK_EVPARA Para); 422 423 #else /* defined(SK_KR_PROTO) */ 424 425 /* Non-ANSI/C++ compliant function prototypes */ 426 427 #error KR-style function prototypes are not yet provided. 428 429 #endif /* defined(SK_KR_PROTO)) */ 430 431 432 #ifdef __cplusplus 433 } 434 #endif /* __cplusplus */ 435 436 #endif /* __INC_SKRLMT_H */ 437