1 /******************************************************************************
4 * Project: Gigabit Ethernet Adapters, ADDR-Modul
5 * Version: $Revision: 1.29 $
6 * Date: $Date: 2003/05/13 16:57:24 $
7 * Purpose: Header file for Address Management (MC, UC, Prom).
9 ******************************************************************************/
11 /******************************************************************************
13 * (C)Copyright 1998-2002 SysKonnect GmbH.
14 * (C)Copyright 2002-2003 Marvell.
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * The information in this file is provided "AS IS" without warranty.
23 ******************************************************************************/
25 /******************************************************************************
29 * This module is intended to manage multicast addresses and promiscuous mode
30 * on GEnesis adapters.
32 * Include File Hierarchy:
42 ******************************************************************************/
44 #ifndef __INC_SKADDR_H
45 #define __INC_SKADDR_H
49 #endif /* cplusplus */
51 /* defines ********************************************************************/
53 #define SK_MAC_ADDR_LEN 6 /* Length of MAC address. */
54 #define SK_MAX_ADDRS 14 /* #Addrs for exact match. */
56 /* ----- Common return values ----- */
58 #define SK_ADDR_SUCCESS 0 /* Function returned successfully. */
59 #define SK_ADDR_ILLEGAL_PORT 100 /* Port number too high. */
60 #define SK_ADDR_TOO_EARLY 101 /* Function called too early. */
62 /* ----- Clear/Add flag bits ----- */
64 #define SK_ADDR_PERMANENT 1 /* RLMT Address */
66 /* ----- Additional Clear flag bits ----- */
68 #define SK_MC_SW_ONLY 2 /* Do not update HW when clearing. */
70 /* ----- Override flag bits ----- */
72 #define SK_ADDR_LOGICAL_ADDRESS 0
73 #define SK_ADDR_VIRTUAL_ADDRESS (SK_ADDR_LOGICAL_ADDRESS) /* old */
74 #define SK_ADDR_PHYSICAL_ADDRESS 1
75 #define SK_ADDR_CLEAR_LOGICAL 2
76 #define SK_ADDR_SET_LOGICAL 4
78 /* ----- Override return values ----- */
80 #define SK_ADDR_OVERRIDE_SUCCESS (SK_ADDR_SUCCESS)
81 #define SK_ADDR_DUPLICATE_ADDRESS 1
82 #define SK_ADDR_MULTICAST_ADDRESS 2
84 /* ----- Partitioning of excact match table ----- */
86 #define SK_ADDR_EXACT_MATCHES 16 /* #Exact match entries. */
88 #define SK_ADDR_FIRST_MATCH_RLMT 1
89 #define SK_ADDR_LAST_MATCH_RLMT 2
90 #define SK_ADDR_FIRST_MATCH_DRV 3
91 #define SK_ADDR_LAST_MATCH_DRV (SK_ADDR_EXACT_MATCHES - 1)
93 /* ----- SkAddrMcAdd/SkAddrMcUpdate return values ----- */
95 #define SK_MC_FILTERING_EXACT 0 /* Exact filtering. */
96 #define SK_MC_FILTERING_INEXACT 1 /* Inexact filtering. */
98 /* ----- Additional SkAddrMcAdd return values ----- */
100 #define SK_MC_ILLEGAL_ADDRESS 2 /* Illegal address. */
101 #define SK_MC_ILLEGAL_PORT 3 /* Illegal port (not the active one). */
102 #define SK_MC_RLMT_OVERFLOW 4 /* Too many RLMT mc addresses. */
104 /* Promiscuous mode bits ----- */
106 #define SK_PROM_MODE_NONE 0 /* Normal receive. */
107 #define SK_PROM_MODE_LLC 1 /* Receive all LLC frames. */
108 #define SK_PROM_MODE_ALL_MC 2 /* Receive all multicast frames. */
109 /* #define SK_PROM_MODE_NON_LLC 4 */ /* Receive all non-LLC frames. */
114 #ifndef SK_ADDR_EQUAL
116 * "&" instead of "&&" allows better optimization on IA-64.
117 * The replacement is safe here, as all bytes exist.
119 #ifndef SK_ADDR_DWORD_COMPARE
120 #define SK_ADDR_EQUAL(A1,A2) ( \
121 (((SK_U8 *)(A1))[5] == ((SK_U8 *)(A2))[5]) & \
122 (((SK_U8 *)(A1))[4] == ((SK_U8 *)(A2))[4]) & \
123 (((SK_U8 *)(A1))[3] == ((SK_U8 *)(A2))[3]) & \
124 (((SK_U8 *)(A1))[2] == ((SK_U8 *)(A2))[2]) & \
125 (((SK_U8 *)(A1))[1] == ((SK_U8 *)(A2))[1]) & \
126 (((SK_U8 *)(A1))[0] == ((SK_U8 *)(A2))[0]))
127 #else /* SK_ADDR_DWORD_COMPARE */
128 #define SK_ADDR_EQUAL(A1,A2) ( \
129 (*(SK_U32 *)&(((SK_U8 *)(A1))[2]) == *(SK_U32 *)&(((SK_U8 *)(A2))[2])) & \
130 (*(SK_U32 *)&(((SK_U8 *)(A1))[0]) == *(SK_U32 *)&(((SK_U8 *)(A2))[0])))
131 #endif /* SK_ADDR_DWORD_COMPARE */
132 #endif /* SK_ADDR_EQUAL */
135 #ifndef SK_ADDR_EQUAL
136 #ifndef SK_ADDR_DWORD_COMPARE
137 #define SK_ADDR_EQUAL(A1,A2) ( \
138 (((SK_U8 SK_FAR *)(A1))[5] == ((SK_U8 SK_FAR *)(A2))[5]) & \
139 (((SK_U8 SK_FAR *)(A1))[4] == ((SK_U8 SK_FAR *)(A2))[4]) & \
140 (((SK_U8 SK_FAR *)(A1))[3] == ((SK_U8 SK_FAR *)(A2))[3]) & \
141 (((SK_U8 SK_FAR *)(A1))[2] == ((SK_U8 SK_FAR *)(A2))[2]) & \
142 (((SK_U8 SK_FAR *)(A1))[1] == ((SK_U8 SK_FAR *)(A2))[1]) & \
143 (((SK_U8 SK_FAR *)(A1))[0] == ((SK_U8 SK_FAR *)(A2))[0]))
144 #else /* SK_ADDR_DWORD_COMPARE */
145 #define SK_ADDR_EQUAL(A1,A2) ( \
146 (*(SK_U16 SK_FAR *)&(((SK_U8 SK_FAR *)(A1))[4]) == \
147 *(SK_U16 SK_FAR *)&(((SK_U8 SK_FAR *)(A2))[4])) && \
148 (*(SK_U32 SK_FAR *)&(((SK_U8 SK_FAR *)(A1))[0]) == \
149 *(SK_U32 SK_FAR *)&(((SK_U8 SK_FAR *)(A2))[0])))
150 #endif /* SK_ADDR_DWORD_COMPARE */
151 #endif /* SK_ADDR_EQUAL */
153 /* typedefs *******************************************************************/
155 typedef struct s_MacAddr
{
156 SK_U8 a
[SK_MAC_ADDR_LEN
];
160 /* SK_FILTER is used to ensure alignment of the filter. */
161 typedef union s_InexactFilter
{
163 SK_U64 Val
; /* Dummy entry for alignment only. */
167 typedef struct s_AddrNet SK_ADDR_NET
;
170 typedef struct s_AddrPort
{
172 /* ----- Public part (read-only) ----- */
174 SK_MAC_ADDR CurrentMacAddress
; /* Current physical MAC Address. */
175 SK_MAC_ADDR PermanentMacAddress
; /* Permanent physical MAC Address. */
176 int PromMode
; /* Promiscuous Mode. */
178 /* ----- Private part ----- */
180 SK_MAC_ADDR PreviousMacAddress
; /* Prev. phys. MAC Address. */
181 SK_BOOL CurrentMacAddressSet
; /* CurrentMacAddress is set. */
184 SK_U32 FirstExactMatchRlmt
;
185 SK_U32 NextExactMatchRlmt
;
186 SK_U32 FirstExactMatchDrv
;
187 SK_U32 NextExactMatchDrv
;
188 SK_MAC_ADDR Exact
[SK_ADDR_EXACT_MATCHES
];
189 SK_FILTER64 InexactFilter
; /* For 64-bit hash register. */
190 SK_FILTER64 InexactRlmtFilter
; /* For 64-bit hash register. */
191 SK_FILTER64 InexactDrvFilter
; /* For 64-bit hash register. */
196 /* ----- Public part (read-only) ----- */
198 SK_MAC_ADDR CurrentMacAddress
; /* Logical MAC Address. */
199 SK_MAC_ADDR PermanentMacAddress
; /* Logical MAC Address. */
201 /* ----- Private part ----- */
203 SK_U32 ActivePort
; /* View of module ADDR. */
204 SK_BOOL CurrentMacAddressSet
; /* CurrentMacAddress is set. */
210 typedef struct s_Addr
{
212 /* ----- Public part (read-only) ----- */
214 SK_ADDR_NET Net
[SK_MAX_NETS
];
215 SK_ADDR_PORT Port
[SK_MAX_MACS
];
217 /* ----- Private part ----- */
220 /* function prototypes ********************************************************/
224 /* Functions provided by SkAddr */
226 /* ANSI/C++ compliant function prototypes */
228 extern int SkAddrInit(
233 extern int SkAddrMcClear(
239 extern int SkAddrXmacMcClear(
245 extern int SkAddrGmacMcClear(
251 extern int SkAddrMcAdd(
258 extern int SkAddrXmacMcAdd(
265 extern int SkAddrGmacMcAdd(
272 extern int SkAddrMcUpdate(
277 extern int SkAddrXmacMcUpdate(
282 extern int SkAddrGmacMcUpdate(
287 extern int SkAddrOverride(
291 SK_MAC_ADDR SK_FAR
*pNewAddr
,
294 extern int SkAddrPromiscuousChange(
300 extern int SkAddrXmacPromiscuousChange(
306 extern int SkAddrGmacPromiscuousChange(
313 extern int SkAddrSwap(
316 SK_U32 FromPortNumber
,
317 SK_U32 ToPortNumber
);
320 #else /* defined(SK_KR_PROTO)) */
322 /* Non-ANSI/C++ compliant function prototypes */
324 #error KR-style prototypes are not yet provided.
326 #endif /* defined(SK_KR_PROTO)) */
331 #endif /* __cplusplus */
333 #endif /* __INC_SKADDR_H */