wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Name: skrlmt.h |
| 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. |
| 8 | * |
| 9 | ******************************************************************************/ |
| 10 | |
| 11 | /****************************************************************************** |
| 12 | * |
| 13 | * (C)Copyright 1998-2001 SysKonnect GmbH. |
| 14 | * |
| 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. |
| 19 | * |
| 20 | * The information in this file is provided "AS IS" without warranty. |
| 21 | * |
| 22 | ******************************************************************************/ |
| 23 | |
| 24 | /****************************************************************************** |
| 25 | * |
| 26 | * History: |
| 27 | * |
| 28 | * $Log: skrlmt.h,v $ |
| 29 | * Revision 1.35 2003/01/31 14:12:41 mkunz |
| 30 | * single port adapter runs now with two identical MAC addresses |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 31 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 32 | * Revision 1.34 2002/09/23 15:13:41 rwahl |
| 33 | * Editorial changes. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 34 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 35 | * Revision 1.33 2001/07/03 12:16:48 mkunz |
| 36 | * New Flag ChgBcPrio (Change priority of last broadcast received) |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 37 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 38 | * Revision 1.32 2001/02/14 14:06:31 rassmann |
| 39 | * Editorial changes. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 40 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 41 | * Revision 1.31 2001/02/05 14:25:26 rassmann |
| 42 | * Prepared RLMT for transparent operation. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 43 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 44 | * Revision 1.30 2001/01/22 13:41:39 rassmann |
| 45 | * Supporting two nets on dual-port adapters. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 46 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 47 | * Revision 1.29 2000/11/17 08:58:00 rassmann |
| 48 | * Moved CheckSwitch from SK_RLMT_PACKET_RECEIVED to SK_RLMT_TIM event. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 49 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 50 | * Revision 1.28 2000/11/09 12:24:34 rassmann |
| 51 | * Editorial changes. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 52 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 53 | * Revision 1.27 1999/11/22 13:59:56 cgoos |
| 54 | * Changed license header to GPL. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 55 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 56 | * Revision 1.26 1999/10/04 14:01:19 rassmann |
| 57 | * Corrected reaction to reception of BPDU frames (#10441). |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 58 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 59 | * Revision 1.25 1999/07/20 12:53:39 rassmann |
| 60 | * Fixed documentation errors for lookahead macros. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 61 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 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 |
| 67 | * the packet). |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 68 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 69 | * Revision 1.23 1999/01/28 12:50:42 rassmann |
| 70 | * Not using broadcast time stamps in CheckLinkState mode. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 71 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 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. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 76 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 77 | * Revision 1.21 1998/12/08 13:11:25 rassmann |
| 78 | * Stopping SegTimer at RlmtStop. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 79 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 80 | * Revision 1.20 1998/11/24 12:37:33 rassmann |
| 81 | * Implemented segmentation check. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 82 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 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. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 86 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 87 | * Revision 1.18 1998/11/13 16:56:56 rassmann |
| 88 | * Added macro version of SkRlmtLookaheadPacket. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 89 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 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. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 93 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 94 | * Revision 1.16 1998/11/03 13:53:50 rassmann |
| 95 | * RLMT should switch now (at least in mode 3). |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 96 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 97 | * Revision 1.15 1998/10/22 11:39:52 rassmann |
| 98 | * Corrected signed/unsigned mismatches. |
| 99 | * Corrected receive list handling and address recognition. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 100 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 101 | * Revision 1.14 1998/10/15 15:16:36 rassmann |
| 102 | * Finished Spanning Tree checking. |
| 103 | * Checked with lint. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 104 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 105 | * Revision 1.13 1998/09/24 19:16:08 rassmann |
| 106 | * Code cleanup. |
| 107 | * Introduced Timer for PORT_DOWN due to no RX. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 108 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 109 | * Revision 1.12 1998/09/16 11:09:52 rassmann |
| 110 | * Syntax corrections. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 111 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 112 | * Revision 1.11 1998/09/15 11:28:50 rassmann |
| 113 | * Syntax corrections. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 114 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 115 | * Revision 1.10 1998/09/14 17:07:38 rassmann |
| 116 | * Added code for port checking via LAN. |
| 117 | * Changed Mbuf definition. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 118 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 119 | * Revision 1.9 1998/09/07 11:14:15 rassmann |
| 120 | * Syntax corrections. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 121 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 122 | * Revision 1.8 1998/09/07 09:06:08 rassmann |
| 123 | * Syntax corrections. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 124 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 125 | * Revision 1.7 1998/09/04 19:41:34 rassmann |
| 126 | * Syntax corrections. |
| 127 | * Started entering code for checking local links. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 128 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 129 | * Revision 1.6 1998/09/04 12:14:28 rassmann |
| 130 | * Interface cleanup. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 131 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 132 | * Revision 1.5 1998/09/02 16:55:29 rassmann |
| 133 | * Updated to reflect new DRV/HWAC/RLMT interface. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 134 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 135 | * Revision 1.4 1998/09/02 07:26:02 afischer |
| 136 | * typedef for SK_RLMT_PORT |
| 137 | * |
| 138 | * Revision 1.3 1998/08/27 14:29:03 rassmann |
| 139 | * Code cleanup. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 140 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 141 | * Revision 1.2 1998/08/27 14:26:25 rassmann |
| 142 | * Updated interface. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 143 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 144 | * Revision 1.1 1998/08/21 08:29:10 rassmann |
| 145 | * First public version. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 146 | * |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 147 | ******************************************************************************/ |
| 148 | |
| 149 | /****************************************************************************** |
| 150 | * |
| 151 | * Description: |
| 152 | * |
| 153 | * This is the header file for Redundant Link ManagemenT. |
| 154 | * |
| 155 | * Include File Hierarchy: |
| 156 | * |
| 157 | * "skdrv1st.h" |
| 158 | * ... |
| 159 | * "sktypes.h" |
| 160 | * "skqueue.h" |
| 161 | * "skaddr.h" |
| 162 | * "skrlmt.h" |
| 163 | * ... |
| 164 | * "skdrv2nd.h" |
| 165 | * |
| 166 | ******************************************************************************/ |
| 167 | |
| 168 | #ifndef __INC_SKRLMT_H |
| 169 | #define __INC_SKRLMT_H |
| 170 | |
| 171 | #ifdef __cplusplus |
| 172 | #error C++ is not yet supported. |
| 173 | extern "C" { |
| 174 | #endif /* cplusplus */ |
| 175 | |
| 176 | /* defines ********************************************************************/ |
| 177 | |
| 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. */ |
| 180 | |
| 181 | /* ----- Default queue sizes - must be multiples of 8 KB ----- */ |
| 182 | |
| 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. */ |
| 187 | |
| 188 | #define SK_RLMT_MAX_TX_BUF_SIZE 60 /* Maximum RLMT transmit size. */ |
| 189 | |
| 190 | /* ----- PORT states ----- */ |
| 191 | |
| 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. */ |
| 197 | |
| 198 | /* ----- RLMT states ----- */ |
| 199 | |
| 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. */ |
| 203 | |
| 204 | /* ----- PORT events ----- */ |
| 205 | |
| 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. */ |
| 209 | |
| 210 | /* ----- RLMT events ----- */ |
| 211 | |
| 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). */ |
| 220 | |
| 221 | /* ----- RLMT mode bits ----- */ |
| 222 | |
| 223 | /* |
| 224 | * CAUTION: These defines are private to RLMT. |
| 225 | * Please use the RLMT mode defines below. |
| 226 | */ |
| 227 | |
| 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. */ |
| 231 | |
| 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 */ |
| 240 | |
| 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 */ |
| 246 | |
| 247 | /* ----- RLMT modes ----- */ |
| 248 | |
| 249 | /* Check Link State. */ |
| 250 | #define SK_RLMT_MODE_CLS (SK_RLMT_CHECK_LINK) |
| 251 | |
| 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) |
| 254 | |
| 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) |
| 258 | |
| 259 | #ifdef RLMT_CHECK_REMOTE |
| 260 | /* Check Local and Remote Ports: check links (local or remote). */ |
| 261 | Name of define TBD! |
| 262 | #define SK_RLMT_MODE_CRP \ |
| 263 | (SK_RLMT_CHECK_LINK | SK_RLMT_CHECK_LOC_LINK | SK_RLMT_CHECK_REM_LINK) |
| 264 | |
| 265 | /* Check Local and Remote Ports and Segmentation Status. */ |
| 266 | Name of define TBD! |
| 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 */ |
| 271 | |
| 272 | /* ----- RLMT lookahead result bits ----- */ |
| 273 | |
| 274 | #define SK_RLMT_RX_RLMT 1 /* Give packet to RLMT. */ |
| 275 | #define SK_RLMT_RX_PROTOCOL 2 /* Give packet to protocol. */ |
| 276 | |
| 277 | /* Macros */ |
| 278 | |
| 279 | #if 0 |
| 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 */ |
| 286 | #endif /* 0 */ |
| 287 | |
| 288 | #define SK_RLMT_PRE_LOOKAHEAD(pAC,PortNum,PktLen,IsBc,pOffset,pNumBytes) { \ |
| 289 | SK_AC *_pAC; \ |
| 290 | SK_U32 _PortNum; \ |
| 291 | _pAC = (pAC); \ |
| 292 | _PortNum = (SK_U32)(PortNum); \ |
| 293 | /* _pAC->Rlmt.Port[_PortNum].PacketsRx++; */ \ |
| 294 | _pAC->Rlmt.Port[_PortNum].PacketsPerTimeSlot++; \ |
| 295 | if (_pAC->Rlmt.RlmtOff) { \ |
| 296 | *(pNumBytes) = 0; \ |
| 297 | } \ |
| 298 | else {\ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 299 | if ((_pAC->Rlmt.Port[_PortNum].Net->RlmtMode & SK_RLMT_TRANSPARENT) != 0) { \ |
| 300 | *(pNumBytes) = 0; \ |
| 301 | } \ |
| 302 | else if (IsBc) { \ |
| 303 | if (_pAC->Rlmt.Port[_PortNum].Net->RlmtMode != SK_RLMT_MODE_CLS) { \ |
| 304 | *(pNumBytes) = 6; \ |
| 305 | *(pOffset) = 6; \ |
| 306 | } \ |
| 307 | else { \ |
| 308 | *(pNumBytes) = 0; \ |
| 309 | } \ |
| 310 | } \ |
| 311 | else { \ |
| 312 | if ((PktLen) > SK_RLMT_MAX_TX_BUF_SIZE) { \ |
| 313 | /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \ |
| 314 | *(pNumBytes) = 0; \ |
| 315 | } \ |
| 316 | else { \ |
| 317 | *(pNumBytes) = 6; \ |
| 318 | *(pOffset) = 0; \ |
| 319 | } \ |
| 320 | } \ |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 321 | } \ |
| 322 | } |
| 323 | |
| 324 | #if 0 |
| 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. |
| 333 | |
| 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. |
| 337 | #endif /* 0 */ |
| 338 | |
| 339 | #define SK_RLMT_LOOKAHEAD(pAC,PortNum,pLaPacket,IsBc,IsMc,pForRlmt) { \ |
| 340 | SK_AC *_pAC; \ |
| 341 | SK_U32 _PortNum; \ |
| 342 | SK_U8 *_pLaPacket; \ |
| 343 | _pAC = (pAC); \ |
| 344 | _PortNum = (SK_U32)(PortNum); \ |
| 345 | _pLaPacket = (SK_U8 *)(pLaPacket); \ |
| 346 | if (IsBc) {\ |
| 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; \ |
| 351 | } \ |
| 352 | /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \ |
| 353 | *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \ |
| 354 | } \ |
| 355 | else if (IsMc) { \ |
| 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; \ |
| 360 | } \ |
| 361 | else { \ |
| 362 | *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \ |
| 363 | } \ |
| 364 | } \ |
| 365 | else if (SK_ADDR_EQUAL(_pLaPacket, SkRlmtMcAddr.a)) { \ |
| 366 | *(pForRlmt) = SK_RLMT_RX_RLMT; \ |
| 367 | } \ |
| 368 | else { \ |
| 369 | /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \ |
| 370 | *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \ |
| 371 | } \ |
| 372 | } \ |
| 373 | else { \ |
| 374 | if (SK_ADDR_EQUAL( \ |
| 375 | _pLaPacket, \ |
| 376 | _pAC->Addr.Port[_PortNum].CurrentMacAddress.a)) { \ |
| 377 | *(pForRlmt) = SK_RLMT_RX_RLMT; \ |
| 378 | } \ |
| 379 | else { \ |
| 380 | /* _pAC->Rlmt.Port[_PortNum].DataPacketsPerTimeSlot++; */ \ |
| 381 | *(pForRlmt) = SK_RLMT_RX_PROTOCOL; \ |
| 382 | } \ |
| 383 | } \ |
| 384 | } |
| 385 | |
| 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 */ |
| 392 | |
| 393 | /* typedefs *******************************************************************/ |
| 394 | |
| 395 | #ifdef SK_RLMT_MBUF_PRIVATE |
| 396 | typedef struct s_RlmtMbuf { |
| 397 | some content |
| 398 | } SK_RLMT_MBUF; |
| 399 | #endif /* SK_RLMT_MBUF_PRIVATE */ |
| 400 | |
| 401 | |
| 402 | #ifdef SK_LA_INFO |
| 403 | typedef struct s_Rlmt_PacketInfo { |
| 404 | unsigned PacketLength; /* Length of packet. */ |
| 405 | unsigned PacketType; /* Directed/Multicast/Broadcast. */ |
| 406 | } SK_RLMT_PINFO; |
| 407 | #endif /* SK_LA_INFO */ |
| 408 | |
| 409 | |
| 410 | typedef struct s_RootId { |
| 411 | SK_U8 Id[8]; /* Root Bridge Id. */ |
| 412 | } SK_RLMT_ROOT_ID; |
| 413 | |
| 414 | |
| 415 | typedef struct s_port { |
| 416 | SK_MAC_ADDR CheckAddr; |
| 417 | SK_BOOL SuspectTx; |
| 418 | } SK_PORT_CHECK; |
| 419 | |
| 420 | |
| 421 | typedef struct s_RlmtNet SK_RLMT_NET; |
| 422 | |
| 423 | |
| 424 | typedef struct s_RlmtPort { |
| 425 | |
| 426 | /* ----- Public part (read-only) ----- */ |
| 427 | |
| 428 | SK_U8 PortState; /* Current state of this port. */ |
| 429 | |
| 430 | /* For PNMI */ |
| 431 | SK_BOOL LinkDown; |
| 432 | SK_BOOL PortDown; |
| 433 | SK_U8 Align01; |
| 434 | |
| 435 | SK_U32 PortNumber; /* Number of port on adapter. */ |
| 436 | SK_RLMT_NET * Net; /* Net port belongs to. */ |
| 437 | |
| 438 | SK_U64 TxHelloCts; |
| 439 | SK_U64 RxHelloCts; |
| 440 | SK_U64 TxSpHelloReqCts; |
| 441 | SK_U64 RxSpHelloCts; |
| 442 | |
| 443 | /* ----- Private part ----- */ |
| 444 | |
| 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. */ |
| 451 | |
| 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. */ |
| 455 | |
| 456 | SK_U32 CheckingState; /* Checking State. */ |
| 457 | |
| 458 | SK_ADDR_PORT * AddrPort; |
| 459 | |
| 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]; */ |
| 465 | |
| 466 | SK_BOOL PortStarted; /* Port is started. */ |
| 467 | SK_BOOL PortNoRx; /* NoRx for >= 1 time slot. */ |
| 468 | SK_BOOL RootIdSet; |
| 469 | SK_RLMT_ROOT_ID Root; /* Root Bridge Id. */ |
| 470 | } SK_RLMT_PORT; |
| 471 | |
| 472 | |
| 473 | struct s_RlmtNet { |
| 474 | |
| 475 | /* ----- Public part (read-only) ----- */ |
| 476 | |
| 477 | SK_U32 NetNumber; /* Number of net. */ |
| 478 | |
| 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. */ |
| 482 | |
| 483 | /* For PNMI */ |
| 484 | |
| 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. */ |
| 489 | |
| 490 | SK_U8 RlmtState; /* Current RLMT state. */ |
| 491 | |
| 492 | /* ----- Private part ----- */ |
| 493 | SK_BOOL RootIdSet; |
| 494 | SK_U16 Align01; |
| 495 | |
| 496 | int LinksUp; /* #Links up. */ |
| 497 | int PortsUp; /* #Ports up. */ |
| 498 | SK_U32 TimeoutValue; /* RLMT timeout value. */ |
| 499 | |
| 500 | SK_U32 CheckingState; /* Checking State. */ |
| 501 | SK_RLMT_ROOT_ID Root; /* Root Bridge Id. */ |
| 502 | |
| 503 | SK_TIMER LocTimer; /* Timer struct. */ |
| 504 | SK_TIMER SegTimer; /* Timer struct. */ |
| 505 | }; |
| 506 | |
| 507 | |
| 508 | typedef struct s_Rlmt { |
| 509 | |
| 510 | /* ----- Public part (read-only) ----- */ |
| 511 | |
| 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. */ |
| 516 | |
| 517 | /* ----- Private part ----- */ |
| 518 | SK_BOOL CheckSwitch; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame^] | 519 | SK_BOOL RlmtOff; /* set to zero if the Mac addresses |
| 520 | are equal or the second one |
| 521 | is zero */ |
wdenk | eb20ad3 | 2003-09-05 23:19:14 +0000 | [diff] [blame] | 522 | SK_U16 Align01; |
| 523 | |
| 524 | } SK_RLMT; |
| 525 | |
| 526 | |
| 527 | extern SK_MAC_ADDR BridgeMcAddr; |
| 528 | extern SK_MAC_ADDR SkRlmtMcAddr; |
| 529 | |
| 530 | /* function prototypes ********************************************************/ |
| 531 | |
| 532 | |
| 533 | #ifndef SK_KR_PROTO |
| 534 | |
| 535 | /* Functions provided by SkRlmt */ |
| 536 | |
| 537 | /* ANSI/C++ compliant function prototypes */ |
| 538 | |
| 539 | extern void SkRlmtInit( |
| 540 | SK_AC *pAC, |
| 541 | SK_IOC IoC, |
| 542 | int Level); |
| 543 | |
| 544 | extern int SkRlmtEvent( |
| 545 | SK_AC *pAC, |
| 546 | SK_IOC IoC, |
| 547 | SK_U32 Event, |
| 548 | SK_EVPARA Para); |
| 549 | |
| 550 | #else /* defined(SK_KR_PROTO) */ |
| 551 | |
| 552 | /* Non-ANSI/C++ compliant function prototypes */ |
| 553 | |
| 554 | #error KR-style function prototypes are not yet provided. |
| 555 | |
| 556 | #endif /* defined(SK_KR_PROTO)) */ |
| 557 | |
| 558 | |
| 559 | #ifdef __cplusplus |
| 560 | } |
| 561 | #endif /* __cplusplus */ |
| 562 | |
| 563 | #endif /* __INC_SKRLMT_H */ |