1 /******************************************************************************
2  *
3  * Name:	skaddr.h
4  * Project:	Gigabit Ethernet Adapters, ADDR-Modul
5  * Purpose:	Header file for Address Management (MC, UC, Prom).
6  *
7  ******************************************************************************/
8 
9 /******************************************************************************
10  *
11  *	(C)Copyright 1998-2002 SysKonnect GmbH.
12  *	(C)Copyright 2002-2003 Marvell.
13  *
14  *	This program is free software; you can redistribute it and/or modify
15  *	it under the terms of the GNU General Public License as published by
16  *	the Free Software Foundation; either version 2 of the License, or
17  *	(at your option) any later version.
18  *
19  *	The information in this file is provided "AS IS" without warranty.
20  *
21  ******************************************************************************/
22 
23 /******************************************************************************
24  *
25  * Description:
26  *
27  * This module is intended to manage multicast addresses and promiscuous mode
28  * on GEnesis adapters.
29  *
30  * Include File Hierarchy:
31  *
32  *	"skdrv1st.h"
33  *	...
34  *	"sktypes.h"
35  *	"skqueue.h"
36  *	"skaddr.h"
37  *	...
38  *	"skdrv2nd.h"
39  *
40  ******************************************************************************/
41 
42 #ifndef __INC_SKADDR_H
43 #define __INC_SKADDR_H
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif	/* cplusplus */
48 
49 /* defines ********************************************************************/
50 
51 #define SK_MAC_ADDR_LEN				6	/* Length of MAC address. */
52 #define	SK_MAX_ADDRS				14	/* #Addrs for exact match. */
53 
54 /* ----- Common return values ----- */
55 
56 #define SK_ADDR_SUCCESS				0	/* Function returned successfully. */
57 #define SK_ADDR_ILLEGAL_PORT			100	/* Port number too high. */
58 #define SK_ADDR_TOO_EARLY			101	/* Function called too early. */
59 
60 /* ----- Clear/Add flag bits ----- */
61 
62 #define SK_ADDR_PERMANENT			1	/* RLMT Address */
63 
64 /* ----- Additional Clear flag bits ----- */
65 
66 #define SK_MC_SW_ONLY				2	/* Do not update HW when clearing. */
67 
68 /* ----- Override flag bits ----- */
69 
70 #define SK_ADDR_LOGICAL_ADDRESS		0
71 #define SK_ADDR_VIRTUAL_ADDRESS		(SK_ADDR_LOGICAL_ADDRESS)	/* old */
72 #define SK_ADDR_PHYSICAL_ADDRESS	1
73 #define SK_ADDR_CLEAR_LOGICAL		2
74 #define SK_ADDR_SET_LOGICAL			4
75 
76 /* ----- Override return values ----- */
77 
78 #define SK_ADDR_OVERRIDE_SUCCESS	(SK_ADDR_SUCCESS)
79 #define SK_ADDR_DUPLICATE_ADDRESS	1
80 #define SK_ADDR_MULTICAST_ADDRESS	2
81 
82 /* ----- Partitioning of excact match table ----- */
83 
84 #define SK_ADDR_EXACT_MATCHES		16	/* #Exact match entries. */
85 
86 #define SK_ADDR_FIRST_MATCH_RLMT	1
87 #define SK_ADDR_LAST_MATCH_RLMT		2
88 #define SK_ADDR_FIRST_MATCH_DRV		3
89 #define SK_ADDR_LAST_MATCH_DRV		(SK_ADDR_EXACT_MATCHES - 1)
90 
91 /* ----- SkAddrMcAdd/SkAddrMcUpdate return values ----- */
92 
93 #define SK_MC_FILTERING_EXACT		0	/* Exact filtering. */
94 #define SK_MC_FILTERING_INEXACT		1	/* Inexact filtering. */
95 
96 /* ----- Additional SkAddrMcAdd return values ----- */
97 
98 #define SK_MC_ILLEGAL_ADDRESS		2	/* Illegal address. */
99 #define SK_MC_ILLEGAL_PORT			3	/* Illegal port (not the active one). */
100 #define SK_MC_RLMT_OVERFLOW			4	/* Too many RLMT mc addresses. */
101 
102 /* Promiscuous mode bits ----- */
103 
104 #define SK_PROM_MODE_NONE			0	/* Normal receive. */
105 #define SK_PROM_MODE_LLC			1	/* Receive all LLC frames. */
106 #define SK_PROM_MODE_ALL_MC			2	/* Receive all multicast frames. */
107 /* #define SK_PROM_MODE_NON_LLC		4 */	/* Receive all non-LLC frames. */
108 
109 /* Macros */
110 
111 #ifdef OLD_STUFF
112 #ifndef SK_ADDR_EQUAL
113 /*
114  * "&" instead of "&&" allows better optimization on IA-64.
115  * The replacement is safe here, as all bytes exist.
116  */
117 #ifndef SK_ADDR_DWORD_COMPARE
118 #define SK_ADDR_EQUAL(A1,A2)	( \
119 	(((SK_U8 *)(A1))[5] == ((SK_U8 *)(A2))[5]) & \
120 	(((SK_U8 *)(A1))[4] == ((SK_U8 *)(A2))[4]) & \
121 	(((SK_U8 *)(A1))[3] == ((SK_U8 *)(A2))[3]) & \
122 	(((SK_U8 *)(A1))[2] == ((SK_U8 *)(A2))[2]) & \
123 	(((SK_U8 *)(A1))[1] == ((SK_U8 *)(A2))[1]) & \
124 	(((SK_U8 *)(A1))[0] == ((SK_U8 *)(A2))[0]))
125 #else	/* SK_ADDR_DWORD_COMPARE */
126 #define SK_ADDR_EQUAL(A1,A2)	( \
127 	(*(SK_U32 *)&(((SK_U8 *)(A1))[2]) == *(SK_U32 *)&(((SK_U8 *)(A2))[2])) & \
128 	(*(SK_U32 *)&(((SK_U8 *)(A1))[0]) == *(SK_U32 *)&(((SK_U8 *)(A2))[0])))
129 #endif	/* SK_ADDR_DWORD_COMPARE */
130 #endif	/* SK_ADDR_EQUAL */
131 #endif /* 0 */
132 
133 #ifndef SK_ADDR_EQUAL
134 #ifndef SK_ADDR_DWORD_COMPARE
135 #define SK_ADDR_EQUAL(A1,A2)	( \
136 	(((SK_U8 SK_FAR *)(A1))[5] == ((SK_U8 SK_FAR *)(A2))[5]) & \
137 	(((SK_U8 SK_FAR *)(A1))[4] == ((SK_U8 SK_FAR *)(A2))[4]) & \
138 	(((SK_U8 SK_FAR *)(A1))[3] == ((SK_U8 SK_FAR *)(A2))[3]) & \
139 	(((SK_U8 SK_FAR *)(A1))[2] == ((SK_U8 SK_FAR *)(A2))[2]) & \
140 	(((SK_U8 SK_FAR *)(A1))[1] == ((SK_U8 SK_FAR *)(A2))[1]) & \
141 	(((SK_U8 SK_FAR *)(A1))[0] == ((SK_U8 SK_FAR *)(A2))[0]))
142 #else	/* SK_ADDR_DWORD_COMPARE */
143 #define SK_ADDR_EQUAL(A1,A2)	( \
144 	(*(SK_U16 SK_FAR *)&(((SK_U8 SK_FAR *)(A1))[4]) == \
145 	*(SK_U16 SK_FAR *)&(((SK_U8 SK_FAR *)(A2))[4])) && \
146 	(*(SK_U32 SK_FAR *)&(((SK_U8 SK_FAR *)(A1))[0]) == \
147 	*(SK_U32 SK_FAR *)&(((SK_U8 SK_FAR *)(A2))[0])))
148 #endif	/* SK_ADDR_DWORD_COMPARE */
149 #endif	/* SK_ADDR_EQUAL */
150 
151 /* typedefs *******************************************************************/
152 
153 typedef struct s_MacAddr {
154 	SK_U8	a[SK_MAC_ADDR_LEN];
155 } SK_MAC_ADDR;
156 
157 
158 /* SK_FILTER is used to ensure alignment of the filter. */
159 typedef union s_InexactFilter {
160 	SK_U8	Bytes[8];
161 	SK_U64	Val;	/* Dummy entry for alignment only. */
162 } SK_FILTER64;
163 
164 
165 typedef struct s_AddrNet SK_ADDR_NET;
166 
167 
168 typedef struct s_AddrPort {
169 
170 /* ----- Public part (read-only) ----- */
171 
172 	SK_MAC_ADDR	CurrentMacAddress;	/* Current physical MAC Address. */
173 	SK_MAC_ADDR	PermanentMacAddress;	/* Permanent physical MAC Address. */
174 	int		PromMode;		/* Promiscuous Mode. */
175 
176 /* ----- Private part ----- */
177 
178 	SK_MAC_ADDR	PreviousMacAddress;	/* Prev. phys. MAC Address. */
179 	SK_BOOL		CurrentMacAddressSet;	/* CurrentMacAddress is set. */
180 	SK_U8		Align01;
181 
182 	SK_U32		FirstExactMatchRlmt;
183 	SK_U32		NextExactMatchRlmt;
184 	SK_U32		FirstExactMatchDrv;
185 	SK_U32		NextExactMatchDrv;
186 	SK_MAC_ADDR	Exact[SK_ADDR_EXACT_MATCHES];
187 	SK_FILTER64	InexactFilter;			/* For 64-bit hash register. */
188 	SK_FILTER64	InexactRlmtFilter;		/* For 64-bit hash register. */
189 	SK_FILTER64	InexactDrvFilter;		/* For 64-bit hash register. */
190 } SK_ADDR_PORT;
191 
192 
193 struct s_AddrNet {
194 /* ----- Public part (read-only) ----- */
195 
196 	SK_MAC_ADDR		CurrentMacAddress;	/* Logical MAC Address. */
197 	SK_MAC_ADDR		PermanentMacAddress;	/* Logical MAC Address. */
198 
199 /* ----- Private part ----- */
200 
201 	SK_U32			ActivePort;		/* View of module ADDR. */
202 	SK_BOOL			CurrentMacAddressSet;	/* CurrentMacAddress is set. */
203 	SK_U8			Align01;
204 	SK_U16			Align02;
205 };
206 
207 
208 typedef struct s_Addr {
209 
210 /* ----- Public part (read-only) ----- */
211 
212 	SK_ADDR_NET		Net[SK_MAX_NETS];
213 	SK_ADDR_PORT	Port[SK_MAX_MACS];
214 
215 /* ----- Private part ----- */
216 } SK_ADDR;
217 
218 /* function prototypes ********************************************************/
219 
220 #ifndef SK_KR_PROTO
221 
222 /* Functions provided by SkAddr */
223 
224 /* ANSI/C++ compliant function prototypes */
225 
226 extern	int	SkAddrInit(
227 	SK_AC	*pAC,
228 	SK_IOC	IoC,
229 	int	Level);
230 
231 extern	int	SkAddrMcClear(
232 	SK_AC	*pAC,
233 	SK_IOC	IoC,
234 	SK_U32	PortNumber,
235 	int	Flags);
236 
237 extern	int	SkAddrXmacMcClear(
238 	SK_AC	*pAC,
239 	SK_IOC	IoC,
240 	SK_U32	PortNumber,
241 	int	Flags);
242 
243 extern	int	SkAddrGmacMcClear(
244 	SK_AC	*pAC,
245 	SK_IOC	IoC,
246 	SK_U32	PortNumber,
247 	int	Flags);
248 
249 extern	int	SkAddrMcAdd(
250 	SK_AC		*pAC,
251 	SK_IOC		IoC,
252 	SK_U32		PortNumber,
253 	SK_MAC_ADDR	*pMc,
254 	int		Flags);
255 
256 extern	int	SkAddrXmacMcAdd(
257 	SK_AC		*pAC,
258 	SK_IOC		IoC,
259 	SK_U32		PortNumber,
260 	SK_MAC_ADDR	*pMc,
261 	int		Flags);
262 
263 extern	int	SkAddrGmacMcAdd(
264 	SK_AC		*pAC,
265 	SK_IOC		IoC,
266 	SK_U32		PortNumber,
267 	SK_MAC_ADDR	*pMc,
268 	int		Flags);
269 
270 extern	int	SkAddrMcUpdate(
271 	SK_AC	*pAC,
272 	SK_IOC	IoC,
273 	SK_U32	PortNumber);
274 
275 extern	int	SkAddrXmacMcUpdate(
276 	SK_AC	*pAC,
277 	SK_IOC	IoC,
278 	SK_U32	PortNumber);
279 
280 extern	int	SkAddrGmacMcUpdate(
281 	SK_AC	*pAC,
282 	SK_IOC	IoC,
283 	SK_U32	PortNumber);
284 
285 extern	int	SkAddrOverride(
286 	SK_AC		*pAC,
287 	SK_IOC		IoC,
288 	SK_U32		PortNumber,
289 	SK_MAC_ADDR	SK_FAR *pNewAddr,
290 	int		Flags);
291 
292 extern	int	SkAddrPromiscuousChange(
293 	SK_AC	*pAC,
294 	SK_IOC	IoC,
295 	SK_U32	PortNumber,
296 	int	NewPromMode);
297 
298 extern	int	SkAddrXmacPromiscuousChange(
299 	SK_AC	*pAC,
300 	SK_IOC	IoC,
301 	SK_U32	PortNumber,
302 	int	NewPromMode);
303 
304 extern	int	SkAddrGmacPromiscuousChange(
305 	SK_AC	*pAC,
306 	SK_IOC	IoC,
307 	SK_U32	PortNumber,
308 	int	NewPromMode);
309 
310 #ifndef SK_SLIM
311 extern	int	SkAddrSwap(
312 	SK_AC	*pAC,
313 	SK_IOC	IoC,
314 	SK_U32	FromPortNumber,
315 	SK_U32	ToPortNumber);
316 #endif
317 
318 #else	/* defined(SK_KR_PROTO)) */
319 
320 /* Non-ANSI/C++ compliant function prototypes */
321 
322 #error KR-style prototypes are not yet provided.
323 
324 #endif	/* defined(SK_KR_PROTO)) */
325 
326 
327 #ifdef __cplusplus
328 }
329 #endif	/* __cplusplus */
330 
331 #endif	/* __INC_SKADDR_H */
332