1 /******************************************************************************
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
5 * Version: $Revision: 1.26 $
6 * Date: $Date: 2002/11/15 07:24:42 $
7 * Purpose: Header file for Address Management (MC, UC, Prom).
9 ******************************************************************************/
11 /******************************************************************************
13 * (C)Copyright 1998-2001 SysKonnect GmbH.
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.
20 * The information in this file is provided "AS IS" without warranty.
22 ******************************************************************************/
24 /******************************************************************************
29 * Revision 1.26 2002/11/15 07:24:42 tschilli
30 * SK_ADDR_EQUAL macro fixed.
32 * Revision 1.25 2002/06/10 13:55:18 tschilli
33 * Changes for handling YUKON.
34 * All changes are internally and not visible to the programmer
37 * Revision 1.24 2001/01/22 13:41:34 rassmann
38 * Supporting two nets on dual-port adapters.
40 * Revision 1.23 2000/08/10 11:27:50 rassmann
42 * Preserving 32-bit alignment in structs for the adapter context.
44 * Revision 1.22 2000/08/07 11:10:40 rassmann
47 * Revision 1.21 2000/05/04 09:39:59 rassmann
49 * Corrected multicast address hashing.
51 * Revision 1.20 1999/11/22 13:46:14 cgoos
52 * Changed license header to GPL.
53 * Allowing overwrite for SK_ADDR_EQUAL.
55 * Revision 1.19 1999/05/28 10:56:07 rassmann
58 * Revision 1.18 1999/04/06 17:22:04 rassmann
59 * Added private "ActivePort".
61 * Revision 1.17 1999/01/14 16:18:19 rassmann
62 * Corrected multicast initialization.
64 * Revision 1.16 1999/01/04 10:30:36 rassmann
65 * SkAddrOverride only possible after SK_INIT_IO phase.
67 * Revision 1.15 1998/12/29 13:13:11 rassmann
68 * An address override is now preserved in the SK_INIT_IO phase.
69 * All functions return an int now.
70 * Extended parameter checking.
72 * Revision 1.14 1998/11/24 12:39:45 rassmann
73 * Reserved multicast entry for BPDU address.
74 * 13 multicast entries left for protocol.
76 * Revision 1.13 1998/11/13 17:24:32 rassmann
77 * Changed return value of SkAddrOverride to int.
79 * Revision 1.12 1998/11/13 16:56:19 rassmann
80 * Added macro SK_ADDR_COMPARE.
81 * Changed return type of SkAddrOverride to SK_BOOL.
83 * Revision 1.11 1998/10/28 18:16:35 rassmann
84 * Avoiding I/Os before SK_INIT_RUN level.
85 * Aligning InexactFilter.
87 * Revision 1.10 1998/10/22 11:39:10 rassmann
88 * Corrected signed/unsigned mismatches.
90 * Revision 1.9 1998/10/15 15:15:49 rassmann
91 * Changed Flags Parameters from SK_U8 to int.
94 * Revision 1.8 1998/09/24 19:15:12 rassmann
97 * Revision 1.7 1998/09/18 20:22:13 rassmann
100 * Revision 1.6 1998/09/04 19:40:20 rassmann
101 * Interface enhancements.
103 * Revision 1.5 1998/09/04 12:40:57 rassmann
106 * Revision 1.4 1998/09/04 12:14:13 rassmann
109 * Revision 1.3 1998/09/02 16:56:40 rassmann
112 * Revision 1.2 1998/08/27 14:26:09 rassmann
115 * Revision 1.1 1998/08/21 08:31:08 rassmann
116 * First public version.
118 ******************************************************************************/
120 /******************************************************************************
124 * This module is intended to manage multicast addresses and promiscuous mode
125 * on GEnesis adapters.
127 * Include File Hierarchy:
137 ******************************************************************************/
139 #ifndef __INC_SKADDR_H
140 #define __INC_SKADDR_H
143 #error C++ is not yet supported.
145 #endif /* cplusplus */
147 /* defines ********************************************************************/
149 #define SK_MAC_ADDR_LEN 6 /* Length of MAC address. */
150 #define SK_MAX_ADDRS 14 /* #Addrs for exact match. */
152 /* ----- Common return values ----- */
154 #define SK_ADDR_SUCCESS 0 /* Function returned successfully. */
155 #define SK_ADDR_ILLEGAL_PORT 100 /* Port number too high. */
156 #define SK_ADDR_TOO_EARLY 101 /* Function called too early. */
158 /* ----- Clear/Add flag bits ----- */
160 #define SK_ADDR_PERMANENT 1 /* RLMT Address */
162 /* ----- Additional Clear flag bits ----- */
164 #define SK_MC_SW_ONLY 2 /* Do not update HW when clearing. */
166 /* ----- Override flag bits ----- */
168 #define SK_ADDR_LOGICAL_ADDRESS 0
169 #define SK_ADDR_VIRTUAL_ADDRESS (SK_ADDR_LOGICAL_ADDRESS) /* old */
170 #define SK_ADDR_PHYSICAL_ADDRESS 1
171 #define SK_ADDR_CLEAR_LOGICAL 2
172 #define SK_ADDR_SET_LOGICAL 4
174 /* ----- Override return values ----- */
176 #define SK_ADDR_OVERRIDE_SUCCESS (SK_ADDR_SUCCESS)
177 #define SK_ADDR_DUPLICATE_ADDRESS 1
178 #define SK_ADDR_MULTICAST_ADDRESS 2
180 /* ----- Partitioning of excact match table ----- */
182 #define SK_ADDR_EXACT_MATCHES 16 /* #Exact match entries. */
184 #define SK_ADDR_FIRST_MATCH_RLMT 1
185 #define SK_ADDR_LAST_MATCH_RLMT 2
186 #define SK_ADDR_FIRST_MATCH_DRV 3
187 #define SK_ADDR_LAST_MATCH_DRV (SK_ADDR_EXACT_MATCHES - 1)
189 /* ----- SkAddrMcAdd/SkAddrMcUpdate return values ----- */
191 #define SK_MC_FILTERING_EXACT 0 /* Exact filtering. */
192 #define SK_MC_FILTERING_INEXACT 1 /* Inexact filtering. */
194 /* ----- Additional SkAddrMcAdd return values ----- */
196 #define SK_MC_ILLEGAL_ADDRESS 2 /* Illegal address. */
197 #define SK_MC_ILLEGAL_PORT 3 /* Illegal port (not the active one). */
198 #define SK_MC_RLMT_OVERFLOW 4 /* Too many RLMT mc addresses. */
200 /* Promiscuous mode bits ----- */
202 #define SK_PROM_MODE_NONE 0 /* Normal receive. */
203 #define SK_PROM_MODE_LLC 1 /* Receive all LLC frames. */
204 #define SK_PROM_MODE_ALL_MC 2 /* Receive all multicast frames. */
205 /* #define SK_PROM_MODE_NON_LLC 4 */ /* Receive all non-LLC frames. */
210 #ifndef SK_ADDR_EQUAL
212 * "&" instead of "&&" allows better optimization on IA-64.
213 * The replacement is safe here, as all bytes exist.
215 #ifndef SK_ADDR_DWORD_COMPARE
216 #define SK_ADDR_EQUAL(A1,A2) ( \
217 (((SK_U8 *)(A1))[5] == ((SK_U8 *)(A2))[5]) & \
218 (((SK_U8 *)(A1))[4] == ((SK_U8 *)(A2))[4]) & \
219 (((SK_U8 *)(A1))[3] == ((SK_U8 *)(A2))[3]) & \
220 (((SK_U8 *)(A1))[2] == ((SK_U8 *)(A2))[2]) & \
221 (((SK_U8 *)(A1))[1] == ((SK_U8 *)(A2))[1]) & \
222 (((SK_U8 *)(A1))[0] == ((SK_U8 *)(A2))[0]))
223 #else /* SK_ADDR_DWORD_COMPARE */
224 #define SK_ADDR_EQUAL(A1,A2) ( \
225 (*(SK_U32 *)&(((SK_U8 *)(A1))[2]) == *(SK_U32 *)&(((SK_U8 *)(A2))[2])) & \
226 (*(SK_U32 *)&(((SK_U8 *)(A1))[0]) == *(SK_U32 *)&(((SK_U8 *)(A2))[0])))
227 #endif /* SK_ADDR_DWORD_COMPARE */
228 #endif /* SK_ADDR_EQUAL */
231 #ifndef SK_ADDR_EQUAL
232 #ifndef SK_ADDR_DWORD_COMPARE
233 #define SK_ADDR_EQUAL(A1,A2) ( \
234 (((SK_U8 *)(A1))[5] == ((SK_U8 *)(A2))[5]) & \
235 (((SK_U8 *)(A1))[4] == ((SK_U8 *)(A2))[4]) & \
236 (((SK_U8 *)(A1))[3] == ((SK_U8 *)(A2))[3]) & \
237 (((SK_U8 *)(A1))[2] == ((SK_U8 *)(A2))[2]) & \
238 (((SK_U8 *)(A1))[1] == ((SK_U8 *)(A2))[1]) & \
239 (((SK_U8 *)(A1))[0] == ((SK_U8 *)(A2))[0]))
240 #else /* SK_ADDR_DWORD_COMPARE */
241 #define SK_ADDR_EQUAL(A1,A2) ( \
242 (*(SK_U16 *)&(((SK_U8 *)(A1))[4]) == *(SK_U16 *)&(((SK_U8 *)(A2))[4])) && \
243 (*(SK_U32 *)&(((SK_U8 *)(A1))[0]) == *(SK_U32 *)&(((SK_U8 *)(A2))[0])))
244 #endif /* SK_ADDR_DWORD_COMPARE */
245 #endif /* SK_ADDR_EQUAL */
247 /* typedefs *******************************************************************/
249 typedef struct s_MacAddr {
250 SK_U8 a[SK_MAC_ADDR_LEN];
254 /* SK_FILTER is used to ensure alignment of the filter. */
255 typedef union s_InexactFilter {
257 SK_U64 Val; /* Dummy entry for alignment only. */
261 typedef struct s_AddrNet SK_ADDR_NET;
264 typedef struct s_AddrPort {
266 /* ----- Public part (read-only) ----- */
268 SK_MAC_ADDR CurrentMacAddress; /* Current physical MAC Address. */
269 SK_MAC_ADDR PermanentMacAddress; /* Permanent physical MAC Address. */
270 int PromMode; /* Promiscuous Mode. */
272 /* ----- Private part ----- */
274 SK_MAC_ADDR PreviousMacAddress; /* Prev. phys. MAC Address. */
275 SK_BOOL CurrentMacAddressSet; /* CurrentMacAddress is set. */
278 SK_U32 FirstExactMatchRlmt;
279 SK_U32 NextExactMatchRlmt;
280 SK_U32 FirstExactMatchDrv;
281 SK_U32 NextExactMatchDrv;
282 SK_MAC_ADDR Exact[SK_ADDR_EXACT_MATCHES];
283 SK_FILTER64 InexactFilter; /* For 64-bit hash register. */
284 SK_FILTER64 InexactRlmtFilter; /* For 64-bit hash register. */
285 SK_FILTER64 InexactDrvFilter; /* For 64-bit hash register. */
290 /* ----- Public part (read-only) ----- */
292 SK_MAC_ADDR CurrentMacAddress; /* Logical MAC Address. */
293 SK_MAC_ADDR PermanentMacAddress; /* Logical MAC Address. */
295 /* ----- Private part ----- */
297 SK_U32 ActivePort; /* View of module ADDR. */
298 SK_BOOL CurrentMacAddressSet; /* CurrentMacAddress is set. */
304 typedef struct s_Addr {
306 /* ----- Public part (read-only) ----- */
308 SK_ADDR_NET Net[SK_MAX_NETS];
309 SK_ADDR_PORT Port[SK_MAX_MACS];
311 /* ----- Private part ----- */
314 /* function prototypes ********************************************************/
318 /* Functions provided by SkAddr */
320 /* ANSI/C++ compliant function prototypes */
322 extern int SkAddrInit(
327 extern int SkAddrMcClear(
333 extern int SkAddrXmacMcClear(
339 extern int SkAddrGmacMcClear(
345 extern int SkAddrMcAdd(
352 extern int SkAddrXmacMcAdd(
359 extern int SkAddrGmacMcAdd(
366 extern int SkAddrMcUpdate(
371 extern int SkAddrXmacMcUpdate(
376 extern int SkAddrGmacMcUpdate(
381 extern int SkAddrOverride(
385 SK_MAC_ADDR *pNewAddr,
388 extern int SkAddrPromiscuousChange(
394 extern int SkAddrXmacPromiscuousChange(
400 extern int SkAddrGmacPromiscuousChange(
406 extern int SkAddrSwap(
409 SK_U32 FromPortNumber,
410 SK_U32 ToPortNumber);
412 #else /* defined(SK_KR_PROTO)) */
414 /* Non-ANSI/C++ compliant function prototypes */
416 #error KR-style prototypes are not yet provided.
418 #endif /* defined(SK_KR_PROTO)) */
423 #endif /* __cplusplus */
425 #endif /* __INC_SKADDR_H */