skaddr.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. * (C)Copyright 1998-2002 SysKonnect GmbH.
  13. * (C)Copyright 2002-2003 Marvell.
  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. * 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. #ifndef __INC_SKADDR_H
  42. #define __INC_SKADDR_H
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif /* cplusplus */
  46. /* defines ********************************************************************/
  47. #define SK_MAC_ADDR_LEN 6 /* Length of MAC address. */
  48. #define SK_MAX_ADDRS 14 /* #Addrs for exact match. */
  49. /* ----- Common return values ----- */
  50. #define SK_ADDR_SUCCESS 0 /* Function returned successfully. */
  51. #define SK_ADDR_ILLEGAL_PORT 100 /* Port number too high. */
  52. #define SK_ADDR_TOO_EARLY 101 /* Function called too early. */
  53. /* ----- Clear/Add flag bits ----- */
  54. #define SK_ADDR_PERMANENT 1 /* RLMT Address */
  55. /* ----- Additional Clear flag bits ----- */
  56. #define SK_MC_SW_ONLY 2 /* Do not update HW when clearing. */
  57. /* ----- Override flag bits ----- */
  58. #define SK_ADDR_LOGICAL_ADDRESS 0
  59. #define SK_ADDR_VIRTUAL_ADDRESS (SK_ADDR_LOGICAL_ADDRESS) /* old */
  60. #define SK_ADDR_PHYSICAL_ADDRESS 1
  61. #define SK_ADDR_CLEAR_LOGICAL 2
  62. #define SK_ADDR_SET_LOGICAL 4
  63. /* ----- Override return values ----- */
  64. #define SK_ADDR_OVERRIDE_SUCCESS (SK_ADDR_SUCCESS)
  65. #define SK_ADDR_DUPLICATE_ADDRESS 1
  66. #define SK_ADDR_MULTICAST_ADDRESS 2
  67. /* ----- Partitioning of excact match table ----- */
  68. #define SK_ADDR_EXACT_MATCHES 16 /* #Exact match entries. */
  69. #define SK_ADDR_FIRST_MATCH_RLMT 1
  70. #define SK_ADDR_LAST_MATCH_RLMT 2
  71. #define SK_ADDR_FIRST_MATCH_DRV 3
  72. #define SK_ADDR_LAST_MATCH_DRV (SK_ADDR_EXACT_MATCHES - 1)
  73. /* ----- SkAddrMcAdd/SkAddrMcUpdate return values ----- */
  74. #define SK_MC_FILTERING_EXACT 0 /* Exact filtering. */
  75. #define SK_MC_FILTERING_INEXACT 1 /* Inexact filtering. */
  76. /* ----- Additional SkAddrMcAdd return values ----- */
  77. #define SK_MC_ILLEGAL_ADDRESS 2 /* Illegal address. */
  78. #define SK_MC_ILLEGAL_PORT 3 /* Illegal port (not the active one). */
  79. #define SK_MC_RLMT_OVERFLOW 4 /* Too many RLMT mc addresses. */
  80. /* Promiscuous mode bits ----- */
  81. #define SK_PROM_MODE_NONE 0 /* Normal receive. */
  82. #define SK_PROM_MODE_LLC 1 /* Receive all LLC frames. */
  83. #define SK_PROM_MODE_ALL_MC 2 /* Receive all multicast frames. */
  84. /* #define SK_PROM_MODE_NON_LLC 4 */ /* Receive all non-LLC frames. */
  85. /* Macros */
  86. #ifdef OLD_STUFF
  87. #ifndef SK_ADDR_EQUAL
  88. /*
  89. * "&" instead of "&&" allows better optimization on IA-64.
  90. * The replacement is safe here, as all bytes exist.
  91. */
  92. #ifndef SK_ADDR_DWORD_COMPARE
  93. #define SK_ADDR_EQUAL(A1,A2) ( \
  94. (((SK_U8 *)(A1))[5] == ((SK_U8 *)(A2))[5]) & \
  95. (((SK_U8 *)(A1))[4] == ((SK_U8 *)(A2))[4]) & \
  96. (((SK_U8 *)(A1))[3] == ((SK_U8 *)(A2))[3]) & \
  97. (((SK_U8 *)(A1))[2] == ((SK_U8 *)(A2))[2]) & \
  98. (((SK_U8 *)(A1))[1] == ((SK_U8 *)(A2))[1]) & \
  99. (((SK_U8 *)(A1))[0] == ((SK_U8 *)(A2))[0]))
  100. #else /* SK_ADDR_DWORD_COMPARE */
  101. #define SK_ADDR_EQUAL(A1,A2) ( \
  102. (*(SK_U32 *)&(((SK_U8 *)(A1))[2]) == *(SK_U32 *)&(((SK_U8 *)(A2))[2])) & \
  103. (*(SK_U32 *)&(((SK_U8 *)(A1))[0]) == *(SK_U32 *)&(((SK_U8 *)(A2))[0])))
  104. #endif /* SK_ADDR_DWORD_COMPARE */
  105. #endif /* SK_ADDR_EQUAL */
  106. #endif /* 0 */
  107. #ifndef SK_ADDR_EQUAL
  108. #ifndef SK_ADDR_DWORD_COMPARE
  109. #define SK_ADDR_EQUAL(A1,A2) ( \
  110. (((SK_U8 SK_FAR *)(A1))[5] == ((SK_U8 SK_FAR *)(A2))[5]) & \
  111. (((SK_U8 SK_FAR *)(A1))[4] == ((SK_U8 SK_FAR *)(A2))[4]) & \
  112. (((SK_U8 SK_FAR *)(A1))[3] == ((SK_U8 SK_FAR *)(A2))[3]) & \
  113. (((SK_U8 SK_FAR *)(A1))[2] == ((SK_U8 SK_FAR *)(A2))[2]) & \
  114. (((SK_U8 SK_FAR *)(A1))[1] == ((SK_U8 SK_FAR *)(A2))[1]) & \
  115. (((SK_U8 SK_FAR *)(A1))[0] == ((SK_U8 SK_FAR *)(A2))[0]))
  116. #else /* SK_ADDR_DWORD_COMPARE */
  117. #define SK_ADDR_EQUAL(A1,A2) ( \
  118. (*(SK_U16 SK_FAR *)&(((SK_U8 SK_FAR *)(A1))[4]) == \
  119. *(SK_U16 SK_FAR *)&(((SK_U8 SK_FAR *)(A2))[4])) && \
  120. (*(SK_U32 SK_FAR *)&(((SK_U8 SK_FAR *)(A1))[0]) == \
  121. *(SK_U32 SK_FAR *)&(((SK_U8 SK_FAR *)(A2))[0])))
  122. #endif /* SK_ADDR_DWORD_COMPARE */
  123. #endif /* SK_ADDR_EQUAL */
  124. /* typedefs *******************************************************************/
  125. typedef struct s_MacAddr {
  126. SK_U8 a[SK_MAC_ADDR_LEN];
  127. } SK_MAC_ADDR;
  128. /* SK_FILTER is used to ensure alignment of the filter. */
  129. typedef union s_InexactFilter {
  130. SK_U8 Bytes[8];
  131. SK_U64 Val; /* Dummy entry for alignment only. */
  132. } SK_FILTER64;
  133. typedef struct s_AddrNet SK_ADDR_NET;
  134. typedef struct s_AddrPort {
  135. /* ----- Public part (read-only) ----- */
  136. SK_MAC_ADDR CurrentMacAddress; /* Current physical MAC Address. */
  137. SK_MAC_ADDR PermanentMacAddress; /* Permanent physical MAC Address. */
  138. int PromMode; /* Promiscuous Mode. */
  139. /* ----- Private part ----- */
  140. SK_MAC_ADDR PreviousMacAddress; /* Prev. phys. MAC Address. */
  141. SK_BOOL CurrentMacAddressSet; /* CurrentMacAddress is set. */
  142. SK_U8 Align01;
  143. SK_U32 FirstExactMatchRlmt;
  144. SK_U32 NextExactMatchRlmt;
  145. SK_U32 FirstExactMatchDrv;
  146. SK_U32 NextExactMatchDrv;
  147. SK_MAC_ADDR Exact[SK_ADDR_EXACT_MATCHES];
  148. SK_FILTER64 InexactFilter; /* For 64-bit hash register. */
  149. SK_FILTER64 InexactRlmtFilter; /* For 64-bit hash register. */
  150. SK_FILTER64 InexactDrvFilter; /* For 64-bit hash register. */
  151. } SK_ADDR_PORT;
  152. struct s_AddrNet {
  153. /* ----- Public part (read-only) ----- */
  154. SK_MAC_ADDR CurrentMacAddress; /* Logical MAC Address. */
  155. SK_MAC_ADDR PermanentMacAddress; /* Logical MAC Address. */
  156. /* ----- Private part ----- */
  157. SK_U32 ActivePort; /* View of module ADDR. */
  158. SK_BOOL CurrentMacAddressSet; /* CurrentMacAddress is set. */
  159. SK_U8 Align01;
  160. SK_U16 Align02;
  161. };
  162. typedef struct s_Addr {
  163. /* ----- Public part (read-only) ----- */
  164. SK_ADDR_NET Net[SK_MAX_NETS];
  165. SK_ADDR_PORT Port[SK_MAX_MACS];
  166. /* ----- Private part ----- */
  167. } SK_ADDR;
  168. /* function prototypes ********************************************************/
  169. #ifndef SK_KR_PROTO
  170. /* Functions provided by SkAddr */
  171. /* ANSI/C++ compliant function prototypes */
  172. extern int SkAddrInit(
  173. SK_AC *pAC,
  174. SK_IOC IoC,
  175. int Level);
  176. extern int SkAddrMcClear(
  177. SK_AC *pAC,
  178. SK_IOC IoC,
  179. SK_U32 PortNumber,
  180. int Flags);
  181. extern int SkAddrMcAdd(
  182. SK_AC *pAC,
  183. SK_IOC IoC,
  184. SK_U32 PortNumber,
  185. SK_MAC_ADDR *pMc,
  186. int Flags);
  187. extern int SkAddrMcUpdate(
  188. SK_AC *pAC,
  189. SK_IOC IoC,
  190. SK_U32 PortNumber);
  191. extern int SkAddrOverride(
  192. SK_AC *pAC,
  193. SK_IOC IoC,
  194. SK_U32 PortNumber,
  195. SK_MAC_ADDR SK_FAR *pNewAddr,
  196. int Flags);
  197. extern int SkAddrPromiscuousChange(
  198. SK_AC *pAC,
  199. SK_IOC IoC,
  200. SK_U32 PortNumber,
  201. int NewPromMode);
  202. #ifndef SK_SLIM
  203. extern int SkAddrSwap(
  204. SK_AC *pAC,
  205. SK_IOC IoC,
  206. SK_U32 FromPortNumber,
  207. SK_U32 ToPortNumber);
  208. #endif
  209. #else /* defined(SK_KR_PROTO)) */
  210. /* Non-ANSI/C++ compliant function prototypes */
  211. #error KR-style prototypes are not yet provided.
  212. #endif /* defined(SK_KR_PROTO)) */
  213. #ifdef __cplusplus
  214. }
  215. #endif /* __cplusplus */
  216. #endif /* __INC_SKADDR_H */