1 /******************************************************************************
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
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.1 2011-02-28 14:37:53 lothar
32 * Revision 1.26 2002/11/15 07:24:42 tschilli
33 * SK_ADDR_EQUAL macro fixed.
35 * Revision 1.25 2002/06/10 13:55:18 tschilli
36 * Changes for handling YUKON.
37 * All changes are internally and not visible to the programmer
40 * Revision 1.24 2001/01/22 13:41:34 rassmann
41 * Supporting two nets on dual-port adapters.
43 * Revision 1.23 2000/08/10 11:27:50 rassmann
45 * Preserving 32-bit alignment in structs for the adapter context.
47 * Revision 1.22 2000/08/07 11:10:40 rassmann
50 * Revision 1.21 2000/05/04 09:39:59 rassmann
52 * Corrected multicast address hashing.
54 * Revision 1.20 1999/11/22 13:46:14 cgoos
55 * Changed license header to GPL.
56 * Allowing overwrite for SK_ADDR_EQUAL.
58 * Revision 1.19 1999/05/28 10:56:07 rassmann
61 * Revision 1.18 1999/04/06 17:22:04 rassmann
62 * Added private "ActivePort".
64 * Revision 1.17 1999/01/14 16:18:19 rassmann
65 * Corrected multicast initialization.
67 * Revision 1.16 1999/01/04 10:30:36 rassmann
68 * SkAddrOverride only possible after SK_INIT_IO phase.
70 * Revision 1.15 1998/12/29 13:13:11 rassmann
71 * An address override is now preserved in the SK_INIT_IO phase.
72 * All functions return an int now.
73 * Extended parameter checking.
75 * Revision 1.14 1998/11/24 12:39:45 rassmann
76 * Reserved multicast entry for BPDU address.
77 * 13 multicast entries left for protocol.
79 * Revision 1.13 1998/11/13 17:24:32 rassmann
80 * Changed return value of SkAddrOverride to int.
82 * Revision 1.12 1998/11/13 16:56:19 rassmann
83 * Added macro SK_ADDR_COMPARE.
84 * Changed return type of SkAddrOverride to SK_BOOL.
86 * Revision 1.11 1998/10/28 18:16:35 rassmann
87 * Avoiding I/Os before SK_INIT_RUN level.
88 * Aligning InexactFilter.
90 * Revision 1.10 1998/10/22 11:39:10 rassmann
91 * Corrected signed/unsigned mismatches.
93 * Revision 1.9 1998/10/15 15:15:49 rassmann
94 * Changed Flags Parameters from SK_U8 to int.
97 * Revision 1.8 1998/09/24 19:15:12 rassmann
100 * Revision 1.7 1998/09/18 20:22:13 rassmann
103 * Revision 1.6 1998/09/04 19:40:20 rassmann
104 * Interface enhancements.
106 * Revision 1.5 1998/09/04 12:40:57 rassmann
109 * Revision 1.4 1998/09/04 12:14:13 rassmann
112 * Revision 1.3 1998/09/02 16:56:40 rassmann
115 * Revision 1.2 1998/08/27 14:26:09 rassmann
118 * Revision 1.1 1998/08/21 08:31:08 rassmann
119 * First public version.
121 ******************************************************************************/
123 /******************************************************************************
127 * This module is intended to manage multicast addresses and promiscuous mode
128 * on GEnesis adapters.
130 * Include File Hierarchy:
140 ******************************************************************************/
142 #ifndef __INC_SKADDR_H
143 #define __INC_SKADDR_H
146 #error C++ is not yet supported.
148 #endif /* cplusplus */
150 /* defines ********************************************************************/
152 #define SK_MAC_ADDR_LEN 6 /* Length of MAC address. */
153 #define SK_MAX_ADDRS 14 /* #Addrs for exact match. */
155 /* ----- Common return values ----- */
157 #define SK_ADDR_SUCCESS 0 /* Function returned successfully. */
158 #define SK_ADDR_ILLEGAL_PORT 100 /* Port number too high. */
159 #define SK_ADDR_TOO_EARLY 101 /* Function called too early. */
161 /* ----- Clear/Add flag bits ----- */
163 #define SK_ADDR_PERMANENT 1 /* RLMT Address */
165 /* ----- Additional Clear flag bits ----- */
167 #define SK_MC_SW_ONLY 2 /* Do not update HW when clearing. */
169 /* ----- Override flag bits ----- */
171 #define SK_ADDR_LOGICAL_ADDRESS 0
172 #define SK_ADDR_VIRTUAL_ADDRESS (SK_ADDR_LOGICAL_ADDRESS) /* old */
173 #define SK_ADDR_PHYSICAL_ADDRESS 1
174 #define SK_ADDR_CLEAR_LOGICAL 2
175 #define SK_ADDR_SET_LOGICAL 4
177 /* ----- Override return values ----- */
179 #define SK_ADDR_OVERRIDE_SUCCESS (SK_ADDR_SUCCESS)
180 #define SK_ADDR_DUPLICATE_ADDRESS 1
181 #define SK_ADDR_MULTICAST_ADDRESS 2
183 /* ----- Partitioning of excact match table ----- */
185 #define SK_ADDR_EXACT_MATCHES 16 /* #Exact match entries. */
187 #define SK_ADDR_FIRST_MATCH_RLMT 1
188 #define SK_ADDR_LAST_MATCH_RLMT 2
189 #define SK_ADDR_FIRST_MATCH_DRV 3
190 #define SK_ADDR_LAST_MATCH_DRV (SK_ADDR_EXACT_MATCHES - 1)
192 /* ----- SkAddrMcAdd/SkAddrMcUpdate return values ----- */
194 #define SK_MC_FILTERING_EXACT 0 /* Exact filtering. */
195 #define SK_MC_FILTERING_INEXACT 1 /* Inexact filtering. */
197 /* ----- Additional SkAddrMcAdd return values ----- */
199 #define SK_MC_ILLEGAL_ADDRESS 2 /* Illegal address. */
200 #define SK_MC_ILLEGAL_PORT 3 /* Illegal port (not the active one). */
201 #define SK_MC_RLMT_OVERFLOW 4 /* Too many RLMT mc addresses. */
203 /* Promiscuous mode bits ----- */
205 #define SK_PROM_MODE_NONE 0 /* Normal receive. */
206 #define SK_PROM_MODE_LLC 1 /* Receive all LLC frames. */
207 #define SK_PROM_MODE_ALL_MC 2 /* Receive all multicast frames. */
208 /* #define SK_PROM_MODE_NON_LLC 4 */ /* Receive all non-LLC frames. */
213 #ifndef SK_ADDR_EQUAL
215 * "&" instead of "&&" allows better optimization on IA-64.
216 * The replacement is safe here, as all bytes exist.
218 #ifndef SK_ADDR_DWORD_COMPARE
219 #define SK_ADDR_EQUAL(A1,A2) ( \
220 (((SK_U8 *)(A1))[5] == ((SK_U8 *)(A2))[5]) & \
221 (((SK_U8 *)(A1))[4] == ((SK_U8 *)(A2))[4]) & \
222 (((SK_U8 *)(A1))[3] == ((SK_U8 *)(A2))[3]) & \
223 (((SK_U8 *)(A1))[2] == ((SK_U8 *)(A2))[2]) & \
224 (((SK_U8 *)(A1))[1] == ((SK_U8 *)(A2))[1]) & \
225 (((SK_U8 *)(A1))[0] == ((SK_U8 *)(A2))[0]))
226 #else /* SK_ADDR_DWORD_COMPARE */
227 #define SK_ADDR_EQUAL(A1,A2) ( \
228 (*(SK_U32 *)&(((SK_U8 *)(A1))[2]) == *(SK_U32 *)&(((SK_U8 *)(A2))[2])) & \
229 (*(SK_U32 *)&(((SK_U8 *)(A1))[0]) == *(SK_U32 *)&(((SK_U8 *)(A2))[0])))
230 #endif /* SK_ADDR_DWORD_COMPARE */
231 #endif /* SK_ADDR_EQUAL */
234 #ifndef SK_ADDR_EQUAL
235 #ifndef SK_ADDR_DWORD_COMPARE
236 #define SK_ADDR_EQUAL(A1,A2) ( \
237 (((SK_U8 *)(A1))[5] == ((SK_U8 *)(A2))[5]) & \
238 (((SK_U8 *)(A1))[4] == ((SK_U8 *)(A2))[4]) & \
239 (((SK_U8 *)(A1))[3] == ((SK_U8 *)(A2))[3]) & \
240 (((SK_U8 *)(A1))[2] == ((SK_U8 *)(A2))[2]) & \
241 (((SK_U8 *)(A1))[1] == ((SK_U8 *)(A2))[1]) & \
242 (((SK_U8 *)(A1))[0] == ((SK_U8 *)(A2))[0]))
243 #else /* SK_ADDR_DWORD_COMPARE */
244 #define SK_ADDR_EQUAL(A1,A2) ( \
245 (*(SK_U16 *)&(((SK_U8 *)(A1))[4]) == *(SK_U16 *)&(((SK_U8 *)(A2))[4])) && \
246 (*(SK_U32 *)&(((SK_U8 *)(A1))[0]) == *(SK_U32 *)&(((SK_U8 *)(A2))[0])))
247 #endif /* SK_ADDR_DWORD_COMPARE */
248 #endif /* SK_ADDR_EQUAL */
250 /* typedefs *******************************************************************/
252 typedef struct s_MacAddr {
253 SK_U8 a[SK_MAC_ADDR_LEN];
257 /* SK_FILTER is used to ensure alignment of the filter. */
258 typedef union s_InexactFilter {
260 SK_U64 Val; /* Dummy entry for alignment only. */
264 typedef struct s_AddrNet SK_ADDR_NET;
267 typedef struct s_AddrPort {
269 /* ----- Public part (read-only) ----- */
271 SK_MAC_ADDR CurrentMacAddress; /* Current physical MAC Address. */
272 SK_MAC_ADDR PermanentMacAddress; /* Permanent physical MAC Address. */
273 int PromMode; /* Promiscuous Mode. */
275 /* ----- Private part ----- */
277 SK_MAC_ADDR PreviousMacAddress; /* Prev. phys. MAC Address. */
278 SK_BOOL CurrentMacAddressSet; /* CurrentMacAddress is set. */
281 SK_U32 FirstExactMatchRlmt;
282 SK_U32 NextExactMatchRlmt;
283 SK_U32 FirstExactMatchDrv;
284 SK_U32 NextExactMatchDrv;
285 SK_MAC_ADDR Exact[SK_ADDR_EXACT_MATCHES];
286 SK_FILTER64 InexactFilter; /* For 64-bit hash register. */
287 SK_FILTER64 InexactRlmtFilter; /* For 64-bit hash register. */
288 SK_FILTER64 InexactDrvFilter; /* For 64-bit hash register. */
293 /* ----- Public part (read-only) ----- */
295 SK_MAC_ADDR CurrentMacAddress; /* Logical MAC Address. */
296 SK_MAC_ADDR PermanentMacAddress; /* Logical MAC Address. */
298 /* ----- Private part ----- */
300 SK_U32 ActivePort; /* View of module ADDR. */
301 SK_BOOL CurrentMacAddressSet; /* CurrentMacAddress is set. */
307 typedef struct s_Addr {
309 /* ----- Public part (read-only) ----- */
311 SK_ADDR_NET Net[SK_MAX_NETS];
312 SK_ADDR_PORT Port[SK_MAX_MACS];
314 /* ----- Private part ----- */
317 /* function prototypes ********************************************************/
321 /* Functions provided by SkAddr */
323 /* ANSI/C++ compliant function prototypes */
325 extern int SkAddrInit(
330 extern int SkAddrMcClear(
336 extern int SkAddrXmacMcClear(
342 extern int SkAddrGmacMcClear(
348 extern int SkAddrMcAdd(
355 extern int SkAddrXmacMcAdd(
362 extern int SkAddrGmacMcAdd(
369 extern int SkAddrMcUpdate(
374 extern int SkAddrXmacMcUpdate(
379 extern int SkAddrGmacMcUpdate(
384 extern int SkAddrOverride(
388 SK_MAC_ADDR *pNewAddr,
391 extern int SkAddrPromiscuousChange(
397 extern int SkAddrXmacPromiscuousChange(
403 extern int SkAddrGmacPromiscuousChange(
409 extern int SkAddrSwap(
412 SK_U32 FromPortNumber,
413 SK_U32 ToPortNumber);
415 #else /* defined(SK_KR_PROTO)) */
417 /* Non-ANSI/C++ compliant function prototypes */
419 #error KR-style prototypes are not yet provided.
421 #endif /* defined(SK_KR_PROTO)) */
426 #endif /* __cplusplus */
428 #endif /* __INC_SKADDR_H */