blob: 711f873e7f0190f572f900518a0a0211b8ae2a75 [file] [log] [blame]
wdenk7152b1d2003-09-05 23:19:14 +00001/******************************************************************************
2 *
3 * Name: skaddr.h
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).
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: skaddr.h,v $
29 * Revision 1.26 2002/11/15 07:24:42 tschilli
30 * SK_ADDR_EQUAL macro fixed.
wdenk42d1f032003-10-15 23:53:47 +000031 *
wdenk7152b1d2003-09-05 23:19:14 +000032 * 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
35 * using this module.
wdenk42d1f032003-10-15 23:53:47 +000036 *
wdenk7152b1d2003-09-05 23:19:14 +000037 * Revision 1.24 2001/01/22 13:41:34 rassmann
38 * Supporting two nets on dual-port adapters.
wdenk42d1f032003-10-15 23:53:47 +000039 *
wdenk7152b1d2003-09-05 23:19:14 +000040 * Revision 1.23 2000/08/10 11:27:50 rassmann
41 * Editorial changes.
42 * Preserving 32-bit alignment in structs for the adapter context.
wdenk42d1f032003-10-15 23:53:47 +000043 *
wdenk7152b1d2003-09-05 23:19:14 +000044 * Revision 1.22 2000/08/07 11:10:40 rassmann
45 * Editorial changes.
wdenk42d1f032003-10-15 23:53:47 +000046 *
wdenk7152b1d2003-09-05 23:19:14 +000047 * Revision 1.21 2000/05/04 09:39:59 rassmann
48 * Editorial changes.
49 * Corrected multicast address hashing.
wdenk42d1f032003-10-15 23:53:47 +000050 *
wdenk7152b1d2003-09-05 23:19:14 +000051 * Revision 1.20 1999/11/22 13:46:14 cgoos
52 * Changed license header to GPL.
53 * Allowing overwrite for SK_ADDR_EQUAL.
wdenk42d1f032003-10-15 23:53:47 +000054 *
wdenk7152b1d2003-09-05 23:19:14 +000055 * Revision 1.19 1999/05/28 10:56:07 rassmann
56 * Editorial changes.
wdenk42d1f032003-10-15 23:53:47 +000057 *
wdenk7152b1d2003-09-05 23:19:14 +000058 * Revision 1.18 1999/04/06 17:22:04 rassmann
59 * Added private "ActivePort".
wdenk42d1f032003-10-15 23:53:47 +000060 *
wdenk7152b1d2003-09-05 23:19:14 +000061 * Revision 1.17 1999/01/14 16:18:19 rassmann
62 * Corrected multicast initialization.
wdenk42d1f032003-10-15 23:53:47 +000063 *
wdenk7152b1d2003-09-05 23:19:14 +000064 * Revision 1.16 1999/01/04 10:30:36 rassmann
65 * SkAddrOverride only possible after SK_INIT_IO phase.
wdenk42d1f032003-10-15 23:53:47 +000066 *
wdenk7152b1d2003-09-05 23:19:14 +000067 * 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.
wdenk42d1f032003-10-15 23:53:47 +000071 *
wdenk7152b1d2003-09-05 23:19:14 +000072 * Revision 1.14 1998/11/24 12:39:45 rassmann
73 * Reserved multicast entry for BPDU address.
74 * 13 multicast entries left for protocol.
wdenk42d1f032003-10-15 23:53:47 +000075 *
wdenk7152b1d2003-09-05 23:19:14 +000076 * Revision 1.13 1998/11/13 17:24:32 rassmann
77 * Changed return value of SkAddrOverride to int.
wdenk42d1f032003-10-15 23:53:47 +000078 *
wdenk7152b1d2003-09-05 23:19:14 +000079 * 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.
wdenk42d1f032003-10-15 23:53:47 +000082 *
wdenk7152b1d2003-09-05 23:19:14 +000083 * Revision 1.11 1998/10/28 18:16:35 rassmann
84 * Avoiding I/Os before SK_INIT_RUN level.
85 * Aligning InexactFilter.
wdenk42d1f032003-10-15 23:53:47 +000086 *
wdenk7152b1d2003-09-05 23:19:14 +000087 * Revision 1.10 1998/10/22 11:39:10 rassmann
88 * Corrected signed/unsigned mismatches.
wdenk42d1f032003-10-15 23:53:47 +000089 *
wdenk7152b1d2003-09-05 23:19:14 +000090 * Revision 1.9 1998/10/15 15:15:49 rassmann
91 * Changed Flags Parameters from SK_U8 to int.
92 * Checked with lint.
wdenk42d1f032003-10-15 23:53:47 +000093 *
wdenk7152b1d2003-09-05 23:19:14 +000094 * Revision 1.8 1998/09/24 19:15:12 rassmann
95 * Code cleanup.
wdenk42d1f032003-10-15 23:53:47 +000096 *
wdenk7152b1d2003-09-05 23:19:14 +000097 * Revision 1.7 1998/09/18 20:22:13 rassmann
98 * Added HW access.
wdenk42d1f032003-10-15 23:53:47 +000099 *
wdenk7152b1d2003-09-05 23:19:14 +0000100 * Revision 1.6 1998/09/04 19:40:20 rassmann
101 * Interface enhancements.
wdenk42d1f032003-10-15 23:53:47 +0000102 *
wdenk7152b1d2003-09-05 23:19:14 +0000103 * Revision 1.5 1998/09/04 12:40:57 rassmann
104 * Interface cleanup.
wdenk42d1f032003-10-15 23:53:47 +0000105 *
wdenk7152b1d2003-09-05 23:19:14 +0000106 * Revision 1.4 1998/09/04 12:14:13 rassmann
107 * Interface cleanup.
wdenk42d1f032003-10-15 23:53:47 +0000108 *
wdenk7152b1d2003-09-05 23:19:14 +0000109 * Revision 1.3 1998/09/02 16:56:40 rassmann
110 * Updated interface.
wdenk42d1f032003-10-15 23:53:47 +0000111 *
wdenk7152b1d2003-09-05 23:19:14 +0000112 * Revision 1.2 1998/08/27 14:26:09 rassmann
113 * Updated interface.
wdenk42d1f032003-10-15 23:53:47 +0000114 *
wdenk7152b1d2003-09-05 23:19:14 +0000115 * Revision 1.1 1998/08/21 08:31:08 rassmann
116 * First public version.
117 *
118 ******************************************************************************/
119
120/******************************************************************************
121 *
122 * Description:
123 *
124 * This module is intended to manage multicast addresses and promiscuous mode
125 * on GEnesis adapters.
126 *
127 * Include File Hierarchy:
128 *
129 * "skdrv1st.h"
130 * ...
131 * "sktypes.h"
132 * "skqueue.h"
133 * "skaddr.h"
134 * ...
135 * "skdrv2nd.h"
136 *
137 ******************************************************************************/
138
139#ifndef __INC_SKADDR_H
140#define __INC_SKADDR_H
141
142#ifdef __cplusplus
143#error C++ is not yet supported.
144extern "C" {
145#endif /* cplusplus */
146
147/* defines ********************************************************************/
148
149#define SK_MAC_ADDR_LEN 6 /* Length of MAC address. */
150#define SK_MAX_ADDRS 14 /* #Addrs for exact match. */
151
152/* ----- Common return values ----- */
153
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. */
157
158/* ----- Clear/Add flag bits ----- */
159
160#define SK_ADDR_PERMANENT 1 /* RLMT Address */
161
162/* ----- Additional Clear flag bits ----- */
163
164#define SK_MC_SW_ONLY 2 /* Do not update HW when clearing. */
165
166/* ----- Override flag bits ----- */
167
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
173
174/* ----- Override return values ----- */
175
176#define SK_ADDR_OVERRIDE_SUCCESS (SK_ADDR_SUCCESS)
177#define SK_ADDR_DUPLICATE_ADDRESS 1
178#define SK_ADDR_MULTICAST_ADDRESS 2
179
180/* ----- Partitioning of excact match table ----- */
181
182#define SK_ADDR_EXACT_MATCHES 16 /* #Exact match entries. */
183
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)
188
189/* ----- SkAddrMcAdd/SkAddrMcUpdate return values ----- */
190
191#define SK_MC_FILTERING_EXACT 0 /* Exact filtering. */
192#define SK_MC_FILTERING_INEXACT 1 /* Inexact filtering. */
193
194/* ----- Additional SkAddrMcAdd return values ----- */
195
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. */
199
200/* Promiscuous mode bits ----- */
201
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. */
206
207/* Macros */
208
209#if 0
210#ifndef SK_ADDR_EQUAL
211/*
212 * "&" instead of "&&" allows better optimization on IA-64.
213 * The replacement is safe here, as all bytes exist.
214 */
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 */
229#endif /* 0 */
230
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 */
246
247/* typedefs *******************************************************************/
248
249typedef struct s_MacAddr {
250 SK_U8 a[SK_MAC_ADDR_LEN];
251} SK_MAC_ADDR;
252
253
254/* SK_FILTER is used to ensure alignment of the filter. */
255typedef union s_InexactFilter {
256 SK_U8 Bytes[8];
257 SK_U64 Val; /* Dummy entry for alignment only. */
258} SK_FILTER64;
259
260
261typedef struct s_AddrNet SK_ADDR_NET;
262
263
264typedef struct s_AddrPort {
265
266/* ----- Public part (read-only) ----- */
267
268 SK_MAC_ADDR CurrentMacAddress; /* Current physical MAC Address. */
269 SK_MAC_ADDR PermanentMacAddress; /* Permanent physical MAC Address. */
270 int PromMode; /* Promiscuous Mode. */
271
272/* ----- Private part ----- */
273
274 SK_MAC_ADDR PreviousMacAddress; /* Prev. phys. MAC Address. */
275 SK_BOOL CurrentMacAddressSet; /* CurrentMacAddress is set. */
276 SK_U8 Align01;
277
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. */
286} SK_ADDR_PORT;
287
288
289struct s_AddrNet {
290/* ----- Public part (read-only) ----- */
291
292 SK_MAC_ADDR CurrentMacAddress; /* Logical MAC Address. */
293 SK_MAC_ADDR PermanentMacAddress; /* Logical MAC Address. */
294
295/* ----- Private part ----- */
296
297 SK_U32 ActivePort; /* View of module ADDR. */
298 SK_BOOL CurrentMacAddressSet; /* CurrentMacAddress is set. */
299 SK_U8 Align01;
300 SK_U16 Align02;
301};
302
303
304typedef struct s_Addr {
305
306/* ----- Public part (read-only) ----- */
307
308 SK_ADDR_NET Net[SK_MAX_NETS];
309 SK_ADDR_PORT Port[SK_MAX_MACS];
310
311/* ----- Private part ----- */
312} SK_ADDR;
313
314/* function prototypes ********************************************************/
315
316#ifndef SK_KR_PROTO
317
318/* Functions provided by SkAddr */
319
320/* ANSI/C++ compliant function prototypes */
321
322extern int SkAddrInit(
323 SK_AC *pAC,
324 SK_IOC IoC,
325 int Level);
326
327extern int SkAddrMcClear(
328 SK_AC *pAC,
329 SK_IOC IoC,
330 SK_U32 PortNumber,
331 int Flags);
332
333extern int SkAddrXmacMcClear(
334 SK_AC *pAC,
335 SK_IOC IoC,
336 SK_U32 PortNumber,
337 int Flags);
338
339extern int SkAddrGmacMcClear(
340 SK_AC *pAC,
341 SK_IOC IoC,
342 SK_U32 PortNumber,
343 int Flags);
344
345extern int SkAddrMcAdd(
346 SK_AC *pAC,
347 SK_IOC IoC,
348 SK_U32 PortNumber,
349 SK_MAC_ADDR *pMc,
350 int Flags);
351
352extern int SkAddrXmacMcAdd(
353 SK_AC *pAC,
354 SK_IOC IoC,
355 SK_U32 PortNumber,
356 SK_MAC_ADDR *pMc,
357 int Flags);
358
359extern int SkAddrGmacMcAdd(
360 SK_AC *pAC,
361 SK_IOC IoC,
362 SK_U32 PortNumber,
363 SK_MAC_ADDR *pMc,
364 int Flags);
365
366extern int SkAddrMcUpdate(
367 SK_AC *pAC,
368 SK_IOC IoC,
369 SK_U32 PortNumber);
370
371extern int SkAddrXmacMcUpdate(
372 SK_AC *pAC,
373 SK_IOC IoC,
374 SK_U32 PortNumber);
375
376extern int SkAddrGmacMcUpdate(
377 SK_AC *pAC,
378 SK_IOC IoC,
379 SK_U32 PortNumber);
380
381extern int SkAddrOverride(
382 SK_AC *pAC,
383 SK_IOC IoC,
384 SK_U32 PortNumber,
385 SK_MAC_ADDR *pNewAddr,
386 int Flags);
387
388extern int SkAddrPromiscuousChange(
389 SK_AC *pAC,
390 SK_IOC IoC,
391 SK_U32 PortNumber,
392 int NewPromMode);
393
394extern int SkAddrXmacPromiscuousChange(
395 SK_AC *pAC,
396 SK_IOC IoC,
397 SK_U32 PortNumber,
398 int NewPromMode);
399
400extern int SkAddrGmacPromiscuousChange(
401 SK_AC *pAC,
402 SK_IOC IoC,
403 SK_U32 PortNumber,
wdenk42d1f032003-10-15 23:53:47 +0000404 int NewPromMode);
wdenk7152b1d2003-09-05 23:19:14 +0000405
406extern int SkAddrSwap(
407 SK_AC *pAC,
408 SK_IOC IoC,
409 SK_U32 FromPortNumber,
410 SK_U32 ToPortNumber);
411
412#else /* defined(SK_KR_PROTO)) */
413
414/* Non-ANSI/C++ compliant function prototypes */
415
416#error KR-style prototypes are not yet provided.
417
418#endif /* defined(SK_KR_PROTO)) */
419
420
421#ifdef __cplusplus
422}
423#endif /* __cplusplus */
424
425#endif /* __INC_SKADDR_H */