]> git.karo-electronics.de Git - karo-tx-uboot.git/blob - drivers/net/sk98lin/h/skaddr.h
5e87d416fd603de9d7aa57dbea05cb38f2f39845
[karo-tx-uboot.git] / drivers / net / sk98lin / h / skaddr.h
1 /******************************************************************************
2  *
3  * Name:        skaddr.h
4  * Project:     GEnesis, PCI Gigabit Ethernet Adapter
5  * Version:     $Revision$
6  * Date:        $Date$
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$
29  *      Revision 1.1  2011-02-28 14:37:53  lothar
30  *      Initial revision
31  *
32  *      Revision 1.26  2002/11/15 07:24:42  tschilli
33  *      SK_ADDR_EQUAL macro fixed.
34  *
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
38  *      using this module.
39  *
40  *      Revision 1.24  2001/01/22 13:41:34  rassmann
41  *      Supporting two nets on dual-port adapters.
42  *
43  *      Revision 1.23  2000/08/10 11:27:50  rassmann
44  *      Editorial changes.
45  *      Preserving 32-bit alignment in structs for the adapter context.
46  *
47  *      Revision 1.22  2000/08/07 11:10:40  rassmann
48  *      Editorial changes.
49  *
50  *      Revision 1.21  2000/05/04 09:39:59  rassmann
51  *      Editorial changes.
52  *      Corrected multicast address hashing.
53  *
54  *      Revision 1.20  1999/11/22 13:46:14  cgoos
55  *      Changed license header to GPL.
56  *      Allowing overwrite for SK_ADDR_EQUAL.
57  *
58  *      Revision 1.19  1999/05/28 10:56:07  rassmann
59  *      Editorial changes.
60  *
61  *      Revision 1.18  1999/04/06 17:22:04  rassmann
62  *      Added private "ActivePort".
63  *
64  *      Revision 1.17  1999/01/14 16:18:19  rassmann
65  *      Corrected multicast initialization.
66  *
67  *      Revision 1.16  1999/01/04 10:30:36  rassmann
68  *      SkAddrOverride only possible after SK_INIT_IO phase.
69  *
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.
74  *
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.
78  *
79  *      Revision 1.13  1998/11/13 17:24:32  rassmann
80  *      Changed return value of SkAddrOverride to int.
81  *
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.
85  *
86  *      Revision 1.11  1998/10/28 18:16:35  rassmann
87  *      Avoiding I/Os before SK_INIT_RUN level.
88  *      Aligning InexactFilter.
89  *
90  *      Revision 1.10  1998/10/22 11:39:10  rassmann
91  *      Corrected signed/unsigned mismatches.
92  *
93  *      Revision 1.9  1998/10/15 15:15:49  rassmann
94  *      Changed Flags Parameters from SK_U8 to int.
95  *      Checked with lint.
96  *
97  *      Revision 1.8  1998/09/24 19:15:12  rassmann
98  *      Code cleanup.
99  *
100  *      Revision 1.7  1998/09/18 20:22:13  rassmann
101  *      Added HW access.
102  *
103  *      Revision 1.6  1998/09/04 19:40:20  rassmann
104  *      Interface enhancements.
105  *
106  *      Revision 1.5  1998/09/04 12:40:57  rassmann
107  *      Interface cleanup.
108  *
109  *      Revision 1.4  1998/09/04 12:14:13  rassmann
110  *      Interface cleanup.
111  *
112  *      Revision 1.3  1998/09/02 16:56:40  rassmann
113  *      Updated interface.
114  *
115  *      Revision 1.2  1998/08/27 14:26:09  rassmann
116  *      Updated interface.
117  *
118  *      Revision 1.1  1998/08/21 08:31:08  rassmann
119  *      First public version.
120  *
121  ******************************************************************************/
122
123 /******************************************************************************
124  *
125  * Description:
126  *
127  * This module is intended to manage multicast addresses and promiscuous mode
128  * on GEnesis adapters.
129  *
130  * Include File Hierarchy:
131  *
132  *      "skdrv1st.h"
133  *      ...
134  *      "sktypes.h"
135  *      "skqueue.h"
136  *      "skaddr.h"
137  *      ...
138  *      "skdrv2nd.h"
139  *
140  ******************************************************************************/
141
142 #ifndef __INC_SKADDR_H
143 #define __INC_SKADDR_H
144
145 #ifdef __cplusplus
146 #error C++ is not yet supported.
147 extern "C" {
148 #endif  /* cplusplus */
149
150 /* defines ********************************************************************/
151
152 #define SK_MAC_ADDR_LEN                         6       /* Length of MAC address. */
153 #define SK_MAX_ADDRS                            14      /* #Addrs for exact match. */
154
155 /* ----- Common return values ----- */
156
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. */
160
161 /* ----- Clear/Add flag bits ----- */
162
163 #define SK_ADDR_PERMANENT                       1       /* RLMT Address */
164
165 /* ----- Additional Clear flag bits ----- */
166
167 #define SK_MC_SW_ONLY                           2       /* Do not update HW when clearing. */
168
169 /* ----- Override flag bits ----- */
170
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
176
177 /* ----- Override return values ----- */
178
179 #define SK_ADDR_OVERRIDE_SUCCESS        (SK_ADDR_SUCCESS)
180 #define SK_ADDR_DUPLICATE_ADDRESS       1
181 #define SK_ADDR_MULTICAST_ADDRESS       2
182
183 /* ----- Partitioning of excact match table ----- */
184
185 #define SK_ADDR_EXACT_MATCHES           16      /* #Exact match entries. */
186
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)
191
192 /* ----- SkAddrMcAdd/SkAddrMcUpdate return values ----- */
193
194 #define SK_MC_FILTERING_EXACT           0       /* Exact filtering. */
195 #define SK_MC_FILTERING_INEXACT         1       /* Inexact filtering. */
196
197 /* ----- Additional SkAddrMcAdd return values ----- */
198
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. */
202
203 /* Promiscuous mode bits ----- */
204
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. */
209
210 /* Macros */
211
212 #if 0
213 #ifndef SK_ADDR_EQUAL
214 /*
215  * "&" instead of "&&" allows better optimization on IA-64.
216  * The replacement is safe here, as all bytes exist.
217  */
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 */
232 #endif /* 0 */
233
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 */
249
250 /* typedefs *******************************************************************/
251
252 typedef struct s_MacAddr {
253         SK_U8   a[SK_MAC_ADDR_LEN];
254 } SK_MAC_ADDR;
255
256
257 /* SK_FILTER is used to ensure alignment of the filter. */
258 typedef union s_InexactFilter {
259         SK_U8   Bytes[8];
260         SK_U64  Val;    /* Dummy entry for alignment only. */
261 } SK_FILTER64;
262
263
264 typedef struct s_AddrNet SK_ADDR_NET;
265
266
267 typedef struct s_AddrPort {
268
269 /* ----- Public part (read-only) ----- */
270
271         SK_MAC_ADDR     CurrentMacAddress;      /* Current physical MAC Address. */
272         SK_MAC_ADDR     PermanentMacAddress;    /* Permanent physical MAC Address. */
273         int             PromMode;               /* Promiscuous Mode. */
274
275 /* ----- Private part ----- */
276
277         SK_MAC_ADDR     PreviousMacAddress;     /* Prev. phys. MAC Address. */
278         SK_BOOL         CurrentMacAddressSet;   /* CurrentMacAddress is set. */
279         SK_U8           Align01;
280
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. */
289 } SK_ADDR_PORT;
290
291
292 struct s_AddrNet {
293 /* ----- Public part (read-only) ----- */
294
295         SK_MAC_ADDR             CurrentMacAddress;      /* Logical MAC Address. */
296         SK_MAC_ADDR             PermanentMacAddress;    /* Logical MAC Address. */
297
298 /* ----- Private part ----- */
299
300         SK_U32                  ActivePort;             /* View of module ADDR. */
301         SK_BOOL                 CurrentMacAddressSet;   /* CurrentMacAddress is set. */
302         SK_U8                   Align01;
303         SK_U16                  Align02;
304 };
305
306
307 typedef struct s_Addr {
308
309 /* ----- Public part (read-only) ----- */
310
311         SK_ADDR_NET             Net[SK_MAX_NETS];
312         SK_ADDR_PORT    Port[SK_MAX_MACS];
313
314 /* ----- Private part ----- */
315 } SK_ADDR;
316
317 /* function prototypes ********************************************************/
318
319 #ifndef SK_KR_PROTO
320
321 /* Functions provided by SkAddr */
322
323 /* ANSI/C++ compliant function prototypes */
324
325 extern  int     SkAddrInit(
326         SK_AC   *pAC,
327         SK_IOC  IoC,
328         int     Level);
329
330 extern  int     SkAddrMcClear(
331         SK_AC   *pAC,
332         SK_IOC  IoC,
333         SK_U32  PortNumber,
334         int     Flags);
335
336 extern  int     SkAddrXmacMcClear(
337         SK_AC   *pAC,
338         SK_IOC  IoC,
339         SK_U32  PortNumber,
340         int     Flags);
341
342 extern  int     SkAddrGmacMcClear(
343         SK_AC   *pAC,
344         SK_IOC  IoC,
345         SK_U32  PortNumber,
346         int     Flags);
347
348 extern  int     SkAddrMcAdd(
349         SK_AC           *pAC,
350         SK_IOC          IoC,
351         SK_U32          PortNumber,
352         SK_MAC_ADDR     *pMc,
353         int             Flags);
354
355 extern  int     SkAddrXmacMcAdd(
356         SK_AC           *pAC,
357         SK_IOC          IoC,
358         SK_U32          PortNumber,
359         SK_MAC_ADDR     *pMc,
360         int             Flags);
361
362 extern  int     SkAddrGmacMcAdd(
363         SK_AC           *pAC,
364         SK_IOC          IoC,
365         SK_U32          PortNumber,
366         SK_MAC_ADDR     *pMc,
367         int             Flags);
368
369 extern  int     SkAddrMcUpdate(
370         SK_AC   *pAC,
371         SK_IOC  IoC,
372         SK_U32  PortNumber);
373
374 extern  int     SkAddrXmacMcUpdate(
375         SK_AC   *pAC,
376         SK_IOC  IoC,
377         SK_U32  PortNumber);
378
379 extern  int     SkAddrGmacMcUpdate(
380         SK_AC   *pAC,
381         SK_IOC  IoC,
382         SK_U32  PortNumber);
383
384 extern  int     SkAddrOverride(
385         SK_AC           *pAC,
386         SK_IOC          IoC,
387         SK_U32          PortNumber,
388         SK_MAC_ADDR     *pNewAddr,
389         int             Flags);
390
391 extern  int     SkAddrPromiscuousChange(
392         SK_AC   *pAC,
393         SK_IOC  IoC,
394         SK_U32  PortNumber,
395         int     NewPromMode);
396
397 extern  int     SkAddrXmacPromiscuousChange(
398         SK_AC   *pAC,
399         SK_IOC  IoC,
400         SK_U32  PortNumber,
401         int     NewPromMode);
402
403 extern  int     SkAddrGmacPromiscuousChange(
404         SK_AC   *pAC,
405         SK_IOC  IoC,
406         SK_U32  PortNumber,
407         int     NewPromMode);
408
409 extern  int     SkAddrSwap(
410         SK_AC   *pAC,
411         SK_IOC  IoC,
412         SK_U32  FromPortNumber,
413         SK_U32  ToPortNumber);
414
415 #else   /* defined(SK_KR_PROTO)) */
416
417 /* Non-ANSI/C++ compliant function prototypes */
418
419 #error KR-style prototypes are not yet provided.
420
421 #endif  /* defined(SK_KR_PROTO)) */
422
423
424 #ifdef __cplusplus
425 }
426 #endif  /* __cplusplus */
427
428 #endif  /* __INC_SKADDR_H */