skaddr.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. /******************************************************************************
  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. * (C)Copyright 1998-2001 SysKonnect GmbH.
  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. * History:
  25. *
  26. * $Log: skaddr.h,v $
  27. * Revision 1.26 2002/11/15 07:24:42 tschilli
  28. * SK_ADDR_EQUAL macro fixed.
  29. *
  30. * Revision 1.25 2002/06/10 13:55:18 tschilli
  31. * Changes for handling YUKON.
  32. * All changes are internally and not visible to the programmer
  33. * using this module.
  34. *
  35. * Revision 1.24 2001/01/22 13:41:34 rassmann
  36. * Supporting two nets on dual-port adapters.
  37. *
  38. * Revision 1.23 2000/08/10 11:27:50 rassmann
  39. * Editorial changes.
  40. * Preserving 32-bit alignment in structs for the adapter context.
  41. *
  42. * Revision 1.22 2000/08/07 11:10:40 rassmann
  43. * Editorial changes.
  44. *
  45. * Revision 1.21 2000/05/04 09:39:59 rassmann
  46. * Editorial changes.
  47. * Corrected multicast address hashing.
  48. *
  49. * Revision 1.20 1999/11/22 13:46:14 cgoos
  50. * Changed license header to GPL.
  51. * Allowing overwrite for SK_ADDR_EQUAL.
  52. *
  53. * Revision 1.19 1999/05/28 10:56:07 rassmann
  54. * Editorial changes.
  55. *
  56. * Revision 1.18 1999/04/06 17:22:04 rassmann
  57. * Added private "ActivePort".
  58. *
  59. * Revision 1.17 1999/01/14 16:18:19 rassmann
  60. * Corrected multicast initialization.
  61. *
  62. * Revision 1.16 1999/01/04 10:30:36 rassmann
  63. * SkAddrOverride only possible after SK_INIT_IO phase.
  64. *
  65. * Revision 1.15 1998/12/29 13:13:11 rassmann
  66. * An address override is now preserved in the SK_INIT_IO phase.
  67. * All functions return an int now.
  68. * Extended parameter checking.
  69. *
  70. * Revision 1.14 1998/11/24 12:39:45 rassmann
  71. * Reserved multicast entry for BPDU address.
  72. * 13 multicast entries left for protocol.
  73. *
  74. * Revision 1.13 1998/11/13 17:24:32 rassmann
  75. * Changed return value of SkAddrOverride to int.
  76. *
  77. * Revision 1.12 1998/11/13 16:56:19 rassmann
  78. * Added macro SK_ADDR_COMPARE.
  79. * Changed return type of SkAddrOverride to SK_BOOL.
  80. *
  81. * Revision 1.11 1998/10/28 18:16:35 rassmann
  82. * Avoiding I/Os before SK_INIT_RUN level.
  83. * Aligning InexactFilter.
  84. *
  85. * Revision 1.10 1998/10/22 11:39:10 rassmann
  86. * Corrected signed/unsigned mismatches.
  87. *
  88. * Revision 1.9 1998/10/15 15:15:49 rassmann
  89. * Changed Flags Parameters from SK_U8 to int.
  90. * Checked with lint.
  91. *
  92. * Revision 1.8 1998/09/24 19:15:12 rassmann
  93. * Code cleanup.
  94. *
  95. * Revision 1.7 1998/09/18 20:22:13 rassmann
  96. * Added HW access.
  97. *
  98. * Revision 1.6 1998/09/04 19:40:20 rassmann
  99. * Interface enhancements.
  100. *
  101. * Revision 1.5 1998/09/04 12:40:57 rassmann
  102. * Interface cleanup.
  103. *
  104. * Revision 1.4 1998/09/04 12:14:13 rassmann
  105. * Interface cleanup.
  106. *
  107. * Revision 1.3 1998/09/02 16:56:40 rassmann
  108. * Updated interface.
  109. *
  110. * Revision 1.2 1998/08/27 14:26:09 rassmann
  111. * Updated interface.
  112. *
  113. * Revision 1.1 1998/08/21 08:31:08 rassmann
  114. * First public version.
  115. *
  116. ******************************************************************************/
  117. /******************************************************************************
  118. *
  119. * Description:
  120. *
  121. * This module is intended to manage multicast addresses and promiscuous mode
  122. * on GEnesis adapters.
  123. *
  124. * Include File Hierarchy:
  125. *
  126. * "skdrv1st.h"
  127. * ...
  128. * "sktypes.h"
  129. * "skqueue.h"
  130. * "skaddr.h"
  131. * ...
  132. * "skdrv2nd.h"
  133. *
  134. ******************************************************************************/
  135. #ifndef __INC_SKADDR_H
  136. #define __INC_SKADDR_H
  137. #ifdef __cplusplus
  138. #error C++ is not yet supported.
  139. extern "C" {
  140. #endif /* cplusplus */
  141. /* defines ********************************************************************/
  142. #define SK_MAC_ADDR_LEN 6 /* Length of MAC address. */
  143. #define SK_MAX_ADDRS 14 /* #Addrs for exact match. */
  144. /* ----- Common return values ----- */
  145. #define SK_ADDR_SUCCESS 0 /* Function returned successfully. */
  146. #define SK_ADDR_ILLEGAL_PORT 100 /* Port number too high. */
  147. #define SK_ADDR_TOO_EARLY 101 /* Function called too early. */
  148. /* ----- Clear/Add flag bits ----- */
  149. #define SK_ADDR_PERMANENT 1 /* RLMT Address */
  150. /* ----- Additional Clear flag bits ----- */
  151. #define SK_MC_SW_ONLY 2 /* Do not update HW when clearing. */
  152. /* ----- Override flag bits ----- */
  153. #define SK_ADDR_LOGICAL_ADDRESS 0
  154. #define SK_ADDR_VIRTUAL_ADDRESS (SK_ADDR_LOGICAL_ADDRESS) /* old */
  155. #define SK_ADDR_PHYSICAL_ADDRESS 1
  156. #define SK_ADDR_CLEAR_LOGICAL 2
  157. #define SK_ADDR_SET_LOGICAL 4
  158. /* ----- Override return values ----- */
  159. #define SK_ADDR_OVERRIDE_SUCCESS (SK_ADDR_SUCCESS)
  160. #define SK_ADDR_DUPLICATE_ADDRESS 1
  161. #define SK_ADDR_MULTICAST_ADDRESS 2
  162. /* ----- Partitioning of excact match table ----- */
  163. #define SK_ADDR_EXACT_MATCHES 16 /* #Exact match entries. */
  164. #define SK_ADDR_FIRST_MATCH_RLMT 1
  165. #define SK_ADDR_LAST_MATCH_RLMT 2
  166. #define SK_ADDR_FIRST_MATCH_DRV 3
  167. #define SK_ADDR_LAST_MATCH_DRV (SK_ADDR_EXACT_MATCHES - 1)
  168. /* ----- SkAddrMcAdd/SkAddrMcUpdate return values ----- */
  169. #define SK_MC_FILTERING_EXACT 0 /* Exact filtering. */
  170. #define SK_MC_FILTERING_INEXACT 1 /* Inexact filtering. */
  171. /* ----- Additional SkAddrMcAdd return values ----- */
  172. #define SK_MC_ILLEGAL_ADDRESS 2 /* Illegal address. */
  173. #define SK_MC_ILLEGAL_PORT 3 /* Illegal port (not the active one). */
  174. #define SK_MC_RLMT_OVERFLOW 4 /* Too many RLMT mc addresses. */
  175. /* Promiscuous mode bits ----- */
  176. #define SK_PROM_MODE_NONE 0 /* Normal receive. */
  177. #define SK_PROM_MODE_LLC 1 /* Receive all LLC frames. */
  178. #define SK_PROM_MODE_ALL_MC 2 /* Receive all multicast frames. */
  179. /* #define SK_PROM_MODE_NON_LLC 4 */ /* Receive all non-LLC frames. */
  180. /* Macros */
  181. #if 0
  182. #ifndef SK_ADDR_EQUAL
  183. /*
  184. * "&" instead of "&&" allows better optimization on IA-64.
  185. * The replacement is safe here, as all bytes exist.
  186. */
  187. #ifndef SK_ADDR_DWORD_COMPARE
  188. #define SK_ADDR_EQUAL(A1,A2) ( \
  189. (((SK_U8 *)(A1))[5] == ((SK_U8 *)(A2))[5]) & \
  190. (((SK_U8 *)(A1))[4] == ((SK_U8 *)(A2))[4]) & \
  191. (((SK_U8 *)(A1))[3] == ((SK_U8 *)(A2))[3]) & \
  192. (((SK_U8 *)(A1))[2] == ((SK_U8 *)(A2))[2]) & \
  193. (((SK_U8 *)(A1))[1] == ((SK_U8 *)(A2))[1]) & \
  194. (((SK_U8 *)(A1))[0] == ((SK_U8 *)(A2))[0]))
  195. #else /* SK_ADDR_DWORD_COMPARE */
  196. #define SK_ADDR_EQUAL(A1,A2) ( \
  197. (*(SK_U32 *)&(((SK_U8 *)(A1))[2]) == *(SK_U32 *)&(((SK_U8 *)(A2))[2])) & \
  198. (*(SK_U32 *)&(((SK_U8 *)(A1))[0]) == *(SK_U32 *)&(((SK_U8 *)(A2))[0])))
  199. #endif /* SK_ADDR_DWORD_COMPARE */
  200. #endif /* SK_ADDR_EQUAL */
  201. #endif /* 0 */
  202. #ifndef SK_ADDR_EQUAL
  203. #ifndef SK_ADDR_DWORD_COMPARE
  204. #define SK_ADDR_EQUAL(A1,A2) ( \
  205. (((SK_U8 *)(A1))[5] == ((SK_U8 *)(A2))[5]) & \
  206. (((SK_U8 *)(A1))[4] == ((SK_U8 *)(A2))[4]) & \
  207. (((SK_U8 *)(A1))[3] == ((SK_U8 *)(A2))[3]) & \
  208. (((SK_U8 *)(A1))[2] == ((SK_U8 *)(A2))[2]) & \
  209. (((SK_U8 *)(A1))[1] == ((SK_U8 *)(A2))[1]) & \
  210. (((SK_U8 *)(A1))[0] == ((SK_U8 *)(A2))[0]))
  211. #else /* SK_ADDR_DWORD_COMPARE */
  212. #define SK_ADDR_EQUAL(A1,A2) ( \
  213. (*(SK_U16 *)&(((SK_U8 *)(A1))[4]) == *(SK_U16 *)&(((SK_U8 *)(A2))[4])) && \
  214. (*(SK_U32 *)&(((SK_U8 *)(A1))[0]) == *(SK_U32 *)&(((SK_U8 *)(A2))[0])))
  215. #endif /* SK_ADDR_DWORD_COMPARE */
  216. #endif /* SK_ADDR_EQUAL */
  217. /* typedefs *******************************************************************/
  218. typedef struct s_MacAddr {
  219. SK_U8 a[SK_MAC_ADDR_LEN];
  220. } SK_MAC_ADDR;
  221. /* SK_FILTER is used to ensure alignment of the filter. */
  222. typedef union s_InexactFilter {
  223. SK_U8 Bytes[8];
  224. SK_U64 Val; /* Dummy entry for alignment only. */
  225. } SK_FILTER64;
  226. typedef struct s_AddrNet SK_ADDR_NET;
  227. typedef struct s_AddrPort {
  228. /* ----- Public part (read-only) ----- */
  229. SK_MAC_ADDR CurrentMacAddress; /* Current physical MAC Address. */
  230. SK_MAC_ADDR PermanentMacAddress; /* Permanent physical MAC Address. */
  231. int PromMode; /* Promiscuous Mode. */
  232. /* ----- Private part ----- */
  233. SK_MAC_ADDR PreviousMacAddress; /* Prev. phys. MAC Address. */
  234. SK_BOOL CurrentMacAddressSet; /* CurrentMacAddress is set. */
  235. SK_U8 Align01;
  236. SK_U32 FirstExactMatchRlmt;
  237. SK_U32 NextExactMatchRlmt;
  238. SK_U32 FirstExactMatchDrv;
  239. SK_U32 NextExactMatchDrv;
  240. SK_MAC_ADDR Exact[SK_ADDR_EXACT_MATCHES];
  241. SK_FILTER64 InexactFilter; /* For 64-bit hash register. */
  242. SK_FILTER64 InexactRlmtFilter; /* For 64-bit hash register. */
  243. SK_FILTER64 InexactDrvFilter; /* For 64-bit hash register. */
  244. } SK_ADDR_PORT;
  245. struct s_AddrNet {
  246. /* ----- Public part (read-only) ----- */
  247. SK_MAC_ADDR CurrentMacAddress; /* Logical MAC Address. */
  248. SK_MAC_ADDR PermanentMacAddress; /* Logical MAC Address. */
  249. /* ----- Private part ----- */
  250. SK_U32 ActivePort; /* View of module ADDR. */
  251. SK_BOOL CurrentMacAddressSet; /* CurrentMacAddress is set. */
  252. SK_U8 Align01;
  253. SK_U16 Align02;
  254. };
  255. typedef struct s_Addr {
  256. /* ----- Public part (read-only) ----- */
  257. SK_ADDR_NET Net[SK_MAX_NETS];
  258. SK_ADDR_PORT Port[SK_MAX_MACS];
  259. /* ----- Private part ----- */
  260. } SK_ADDR;
  261. /* function prototypes ********************************************************/
  262. #ifndef SK_KR_PROTO
  263. /* Functions provided by SkAddr */
  264. /* ANSI/C++ compliant function prototypes */
  265. extern int SkAddrInit(
  266. SK_AC *pAC,
  267. SK_IOC IoC,
  268. int Level);
  269. extern int SkAddrMcClear(
  270. SK_AC *pAC,
  271. SK_IOC IoC,
  272. SK_U32 PortNumber,
  273. int Flags);
  274. extern int SkAddrXmacMcClear(
  275. SK_AC *pAC,
  276. SK_IOC IoC,
  277. SK_U32 PortNumber,
  278. int Flags);
  279. extern int SkAddrGmacMcClear(
  280. SK_AC *pAC,
  281. SK_IOC IoC,
  282. SK_U32 PortNumber,
  283. int Flags);
  284. extern int SkAddrMcAdd(
  285. SK_AC *pAC,
  286. SK_IOC IoC,
  287. SK_U32 PortNumber,
  288. SK_MAC_ADDR *pMc,
  289. int Flags);
  290. extern int SkAddrXmacMcAdd(
  291. SK_AC *pAC,
  292. SK_IOC IoC,
  293. SK_U32 PortNumber,
  294. SK_MAC_ADDR *pMc,
  295. int Flags);
  296. extern int SkAddrGmacMcAdd(
  297. SK_AC *pAC,
  298. SK_IOC IoC,
  299. SK_U32 PortNumber,
  300. SK_MAC_ADDR *pMc,
  301. int Flags);
  302. extern int SkAddrMcUpdate(
  303. SK_AC *pAC,
  304. SK_IOC IoC,
  305. SK_U32 PortNumber);
  306. extern int SkAddrXmacMcUpdate(
  307. SK_AC *pAC,
  308. SK_IOC IoC,
  309. SK_U32 PortNumber);
  310. extern int SkAddrGmacMcUpdate(
  311. SK_AC *pAC,
  312. SK_IOC IoC,
  313. SK_U32 PortNumber);
  314. extern int SkAddrOverride(
  315. SK_AC *pAC,
  316. SK_IOC IoC,
  317. SK_U32 PortNumber,
  318. SK_MAC_ADDR *pNewAddr,
  319. int Flags);
  320. extern int SkAddrPromiscuousChange(
  321. SK_AC *pAC,
  322. SK_IOC IoC,
  323. SK_U32 PortNumber,
  324. int NewPromMode);
  325. extern int SkAddrXmacPromiscuousChange(
  326. SK_AC *pAC,
  327. SK_IOC IoC,
  328. SK_U32 PortNumber,
  329. int NewPromMode);
  330. extern int SkAddrGmacPromiscuousChange(
  331. SK_AC *pAC,
  332. SK_IOC IoC,
  333. SK_U32 PortNumber,
  334. int NewPromMode);
  335. extern int SkAddrSwap(
  336. SK_AC *pAC,
  337. SK_IOC IoC,
  338. SK_U32 FromPortNumber,
  339. SK_U32 ToPortNumber);
  340. #else /* defined(SK_KR_PROTO)) */
  341. /* Non-ANSI/C++ compliant function prototypes */
  342. #error KR-style prototypes are not yet provided.
  343. #endif /* defined(SK_KR_PROTO)) */
  344. #ifdef __cplusplus
  345. }
  346. #endif /* __cplusplus */
  347. #endif /* __INC_SKADDR_H */