| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** | 
|  | 2 | * | 
|  | 3 | * Name:	skaddr.h | 
|  | 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). | 
|  | 8 | * | 
|  | 9 | ******************************************************************************/ | 
|  | 10 |  | 
|  | 11 | /****************************************************************************** | 
|  | 12 | * | 
|  | 13 | *	(C)Copyright 1998-2002 SysKonnect GmbH. | 
|  | 14 | *	(C)Copyright 2002-2003 Marvell. | 
|  | 15 | * | 
|  | 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. | 
|  | 20 | * | 
|  | 21 | *	The information in this file is provided "AS IS" without warranty. | 
|  | 22 | * | 
|  | 23 | ******************************************************************************/ | 
|  | 24 |  | 
|  | 25 | /****************************************************************************** | 
|  | 26 | * | 
|  | 27 | * Description: | 
|  | 28 | * | 
|  | 29 | * This module is intended to manage multicast addresses and promiscuous mode | 
|  | 30 | * on GEnesis adapters. | 
|  | 31 | * | 
|  | 32 | * Include File Hierarchy: | 
|  | 33 | * | 
|  | 34 | *	"skdrv1st.h" | 
|  | 35 | *	... | 
|  | 36 | *	"sktypes.h" | 
|  | 37 | *	"skqueue.h" | 
|  | 38 | *	"skaddr.h" | 
|  | 39 | *	... | 
|  | 40 | *	"skdrv2nd.h" | 
|  | 41 | * | 
|  | 42 | ******************************************************************************/ | 
|  | 43 |  | 
|  | 44 | #ifndef __INC_SKADDR_H | 
|  | 45 | #define __INC_SKADDR_H | 
|  | 46 |  | 
|  | 47 | #ifdef __cplusplus | 
|  | 48 | extern "C" { | 
|  | 49 | #endif	/* cplusplus */ | 
|  | 50 |  | 
|  | 51 | /* defines ********************************************************************/ | 
|  | 52 |  | 
|  | 53 | #define SK_MAC_ADDR_LEN				6	/* Length of MAC address. */ | 
|  | 54 | #define	SK_MAX_ADDRS				14	/* #Addrs for exact match. */ | 
|  | 55 |  | 
|  | 56 | /* ----- Common return values ----- */ | 
|  | 57 |  | 
|  | 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. */ | 
|  | 61 |  | 
|  | 62 | /* ----- Clear/Add flag bits ----- */ | 
|  | 63 |  | 
|  | 64 | #define SK_ADDR_PERMANENT			1	/* RLMT Address */ | 
|  | 65 |  | 
|  | 66 | /* ----- Additional Clear flag bits ----- */ | 
|  | 67 |  | 
|  | 68 | #define SK_MC_SW_ONLY				2	/* Do not update HW when clearing. */ | 
|  | 69 |  | 
|  | 70 | /* ----- Override flag bits ----- */ | 
|  | 71 |  | 
|  | 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 | 
|  | 77 |  | 
|  | 78 | /* ----- Override return values ----- */ | 
|  | 79 |  | 
|  | 80 | #define SK_ADDR_OVERRIDE_SUCCESS	(SK_ADDR_SUCCESS) | 
|  | 81 | #define SK_ADDR_DUPLICATE_ADDRESS	1 | 
|  | 82 | #define SK_ADDR_MULTICAST_ADDRESS	2 | 
|  | 83 |  | 
|  | 84 | /* ----- Partitioning of excact match table ----- */ | 
|  | 85 |  | 
|  | 86 | #define SK_ADDR_EXACT_MATCHES		16	/* #Exact match entries. */ | 
|  | 87 |  | 
|  | 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) | 
|  | 92 |  | 
|  | 93 | /* ----- SkAddrMcAdd/SkAddrMcUpdate return values ----- */ | 
|  | 94 |  | 
|  | 95 | #define SK_MC_FILTERING_EXACT		0	/* Exact filtering. */ | 
|  | 96 | #define SK_MC_FILTERING_INEXACT		1	/* Inexact filtering. */ | 
|  | 97 |  | 
|  | 98 | /* ----- Additional SkAddrMcAdd return values ----- */ | 
|  | 99 |  | 
|  | 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. */ | 
|  | 103 |  | 
|  | 104 | /* Promiscuous mode bits ----- */ | 
|  | 105 |  | 
|  | 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. */ | 
|  | 110 |  | 
|  | 111 | /* Macros */ | 
|  | 112 |  | 
|  | 113 | #ifdef OLD_STUFF | 
|  | 114 | #ifndef SK_ADDR_EQUAL | 
|  | 115 | /* | 
|  | 116 | * "&" instead of "&&" allows better optimization on IA-64. | 
|  | 117 | * The replacement is safe here, as all bytes exist. | 
|  | 118 | */ | 
|  | 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 */ | 
|  | 133 | #endif /* 0 */ | 
|  | 134 |  | 
|  | 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 */ | 
|  | 152 |  | 
|  | 153 | /* typedefs *******************************************************************/ | 
|  | 154 |  | 
|  | 155 | typedef struct s_MacAddr { | 
|  | 156 | SK_U8	a[SK_MAC_ADDR_LEN]; | 
|  | 157 | } SK_MAC_ADDR; | 
|  | 158 |  | 
|  | 159 |  | 
|  | 160 | /* SK_FILTER is used to ensure alignment of the filter. */ | 
|  | 161 | typedef union s_InexactFilter { | 
|  | 162 | SK_U8	Bytes[8]; | 
|  | 163 | SK_U64	Val;	/* Dummy entry for alignment only. */ | 
|  | 164 | } SK_FILTER64; | 
|  | 165 |  | 
|  | 166 |  | 
|  | 167 | typedef struct s_AddrNet SK_ADDR_NET; | 
|  | 168 |  | 
|  | 169 |  | 
|  | 170 | typedef struct s_AddrPort { | 
|  | 171 |  | 
|  | 172 | /* ----- Public part (read-only) ----- */ | 
|  | 173 |  | 
|  | 174 | SK_MAC_ADDR	CurrentMacAddress;	/* Current physical MAC Address. */ | 
|  | 175 | SK_MAC_ADDR	PermanentMacAddress;	/* Permanent physical MAC Address. */ | 
|  | 176 | int		PromMode;		/* Promiscuous Mode. */ | 
|  | 177 |  | 
|  | 178 | /* ----- Private part ----- */ | 
|  | 179 |  | 
|  | 180 | SK_MAC_ADDR	PreviousMacAddress;	/* Prev. phys. MAC Address. */ | 
|  | 181 | SK_BOOL		CurrentMacAddressSet;	/* CurrentMacAddress is set. */ | 
|  | 182 | SK_U8		Align01; | 
|  | 183 |  | 
|  | 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. */ | 
|  | 192 | } SK_ADDR_PORT; | 
|  | 193 |  | 
|  | 194 |  | 
|  | 195 | struct s_AddrNet { | 
|  | 196 | /* ----- Public part (read-only) ----- */ | 
|  | 197 |  | 
|  | 198 | SK_MAC_ADDR		CurrentMacAddress;	/* Logical MAC Address. */ | 
|  | 199 | SK_MAC_ADDR		PermanentMacAddress;	/* Logical MAC Address. */ | 
|  | 200 |  | 
|  | 201 | /* ----- Private part ----- */ | 
|  | 202 |  | 
|  | 203 | SK_U32			ActivePort;		/* View of module ADDR. */ | 
|  | 204 | SK_BOOL			CurrentMacAddressSet;	/* CurrentMacAddress is set. */ | 
|  | 205 | SK_U8			Align01; | 
|  | 206 | SK_U16			Align02; | 
|  | 207 | }; | 
|  | 208 |  | 
|  | 209 |  | 
|  | 210 | typedef struct s_Addr { | 
|  | 211 |  | 
|  | 212 | /* ----- Public part (read-only) ----- */ | 
|  | 213 |  | 
|  | 214 | SK_ADDR_NET		Net[SK_MAX_NETS]; | 
|  | 215 | SK_ADDR_PORT	Port[SK_MAX_MACS]; | 
|  | 216 |  | 
|  | 217 | /* ----- Private part ----- */ | 
|  | 218 | } SK_ADDR; | 
|  | 219 |  | 
|  | 220 | /* function prototypes ********************************************************/ | 
|  | 221 |  | 
|  | 222 | #ifndef SK_KR_PROTO | 
|  | 223 |  | 
|  | 224 | /* Functions provided by SkAddr */ | 
|  | 225 |  | 
|  | 226 | /* ANSI/C++ compliant function prototypes */ | 
|  | 227 |  | 
|  | 228 | extern	int	SkAddrInit( | 
|  | 229 | SK_AC	*pAC, | 
|  | 230 | SK_IOC	IoC, | 
|  | 231 | int	Level); | 
|  | 232 |  | 
|  | 233 | extern	int	SkAddrMcClear( | 
|  | 234 | SK_AC	*pAC, | 
|  | 235 | SK_IOC	IoC, | 
|  | 236 | SK_U32	PortNumber, | 
|  | 237 | int	Flags); | 
|  | 238 |  | 
|  | 239 | extern	int	SkAddrXmacMcClear( | 
|  | 240 | SK_AC	*pAC, | 
|  | 241 | SK_IOC	IoC, | 
|  | 242 | SK_U32	PortNumber, | 
|  | 243 | int	Flags); | 
|  | 244 |  | 
|  | 245 | extern	int	SkAddrGmacMcClear( | 
|  | 246 | SK_AC	*pAC, | 
|  | 247 | SK_IOC	IoC, | 
|  | 248 | SK_U32	PortNumber, | 
|  | 249 | int	Flags); | 
|  | 250 |  | 
|  | 251 | extern	int	SkAddrMcAdd( | 
|  | 252 | SK_AC		*pAC, | 
|  | 253 | SK_IOC		IoC, | 
|  | 254 | SK_U32		PortNumber, | 
|  | 255 | SK_MAC_ADDR	*pMc, | 
|  | 256 | int		Flags); | 
|  | 257 |  | 
|  | 258 | extern	int	SkAddrXmacMcAdd( | 
|  | 259 | SK_AC		*pAC, | 
|  | 260 | SK_IOC		IoC, | 
|  | 261 | SK_U32		PortNumber, | 
|  | 262 | SK_MAC_ADDR	*pMc, | 
|  | 263 | int		Flags); | 
|  | 264 |  | 
|  | 265 | extern	int	SkAddrGmacMcAdd( | 
|  | 266 | SK_AC		*pAC, | 
|  | 267 | SK_IOC		IoC, | 
|  | 268 | SK_U32		PortNumber, | 
|  | 269 | SK_MAC_ADDR	*pMc, | 
|  | 270 | int		Flags); | 
|  | 271 |  | 
|  | 272 | extern	int	SkAddrMcUpdate( | 
|  | 273 | SK_AC	*pAC, | 
|  | 274 | SK_IOC	IoC, | 
|  | 275 | SK_U32	PortNumber); | 
|  | 276 |  | 
|  | 277 | extern	int	SkAddrXmacMcUpdate( | 
|  | 278 | SK_AC	*pAC, | 
|  | 279 | SK_IOC	IoC, | 
|  | 280 | SK_U32	PortNumber); | 
|  | 281 |  | 
|  | 282 | extern	int	SkAddrGmacMcUpdate( | 
|  | 283 | SK_AC	*pAC, | 
|  | 284 | SK_IOC	IoC, | 
|  | 285 | SK_U32	PortNumber); | 
|  | 286 |  | 
|  | 287 | extern	int	SkAddrOverride( | 
|  | 288 | SK_AC		*pAC, | 
|  | 289 | SK_IOC		IoC, | 
|  | 290 | SK_U32		PortNumber, | 
|  | 291 | SK_MAC_ADDR	SK_FAR *pNewAddr, | 
|  | 292 | int		Flags); | 
|  | 293 |  | 
|  | 294 | extern	int	SkAddrPromiscuousChange( | 
|  | 295 | SK_AC	*pAC, | 
|  | 296 | SK_IOC	IoC, | 
|  | 297 | SK_U32	PortNumber, | 
|  | 298 | int	NewPromMode); | 
|  | 299 |  | 
|  | 300 | extern	int	SkAddrXmacPromiscuousChange( | 
|  | 301 | SK_AC	*pAC, | 
|  | 302 | SK_IOC	IoC, | 
|  | 303 | SK_U32	PortNumber, | 
|  | 304 | int	NewPromMode); | 
|  | 305 |  | 
|  | 306 | extern	int	SkAddrGmacPromiscuousChange( | 
|  | 307 | SK_AC	*pAC, | 
|  | 308 | SK_IOC	IoC, | 
|  | 309 | SK_U32	PortNumber, | 
|  | 310 | int	NewPromMode); | 
|  | 311 |  | 
|  | 312 | #ifndef SK_SLIM | 
|  | 313 | extern	int	SkAddrSwap( | 
|  | 314 | SK_AC	*pAC, | 
|  | 315 | SK_IOC	IoC, | 
|  | 316 | SK_U32	FromPortNumber, | 
|  | 317 | SK_U32	ToPortNumber); | 
|  | 318 | #endif | 
|  | 319 |  | 
|  | 320 | #else	/* defined(SK_KR_PROTO)) */ | 
|  | 321 |  | 
|  | 322 | /* Non-ANSI/C++ compliant function prototypes */ | 
|  | 323 |  | 
|  | 324 | #error KR-style prototypes are not yet provided. | 
|  | 325 |  | 
|  | 326 | #endif	/* defined(SK_KR_PROTO)) */ | 
|  | 327 |  | 
|  | 328 |  | 
|  | 329 | #ifdef __cplusplus | 
|  | 330 | } | 
|  | 331 | #endif	/* __cplusplus */ | 
|  | 332 |  | 
|  | 333 | #endif	/* __INC_SKADDR_H */ |