IxEthDBMessages_p.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. /**
  2. * @file IxEthDBMessages_p.h
  3. *
  4. * @brief Definitions of NPE messages
  5. *
  6. * @par
  7. * IXP400 SW Release version 2.0
  8. *
  9. * -- Copyright Notice --
  10. *
  11. * @par
  12. * Copyright 2001-2005, Intel Corporation.
  13. * All rights reserved.
  14. *
  15. * @par
  16. * Redistribution and use in source and binary forms, with or without
  17. * modification, are permitted provided that the following conditions
  18. * are met:
  19. * 1. Redistributions of source code must retain the above copyright
  20. * notice, this list of conditions and the following disclaimer.
  21. * 2. Redistributions in binary form must reproduce the above copyright
  22. * notice, this list of conditions and the following disclaimer in the
  23. * documentation and/or other materials provided with the distribution.
  24. * 3. Neither the name of the Intel Corporation nor the names of its contributors
  25. * may be used to endorse or promote products derived from this software
  26. * without specific prior written permission.
  27. *
  28. * @par
  29. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
  30. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  31. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  32. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
  33. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  34. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  35. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  36. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  37. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  38. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  39. * SUCH DAMAGE.
  40. *
  41. * @par
  42. * -- End of Copyright Notice --
  43. */
  44. #ifndef IxEthDBMessages_p_H
  45. #define IxEthDBMessages_p_H
  46. #include <IxEthNpe.h>
  47. #include <IxOsCacheMMU.h>
  48. #include "IxEthDB_p.h"
  49. /* events watched by the Eth event processor */
  50. #define IX_ETH_DB_MIN_EVENT_ID (IX_ETHNPE_EDB_GETMACADDRESSDATABASE)
  51. #define IX_ETH_DB_MAX_EVENT_ID (IX_ETHNPE_PC_SETAPMACTABLE)
  52. /* macros to fill and extract data from NPE messages - place any endian conversions here */
  53. #define RESET_ELT_MESSAGE(message) { memset((void *) &(message), 0, sizeof((message))); }
  54. #define NPE_MSG_ID(msg) ((msg).data[0] >> 24)
  55. #define FILL_SETPORTVLANTABLEENTRY_MSG(message, portID, setOffset, vlanMembershipSet, ttiSet) \
  56. do { \
  57. message.data[0] = (IX_ETHNPE_VLAN_SETPORTVLANTABLEENTRY << 24) | (portID << 16) | (setOffset * 2); \
  58. message.data[1] = (vlanMembershipSet << 8) | ttiSet; \
  59. } while (0);
  60. #define FILL_SETPORTVLANTABLERANGE_MSG(message, portID, offset, length, zone) \
  61. do { \
  62. message.data[0] = IX_ETHNPE_VLAN_SETPORTVLANTABLERANGE << 24 | portID << 16 | offset << 9 | length << 1; \
  63. message.data[1] = (UINT32) zone; \
  64. } while (0);
  65. #define FILL_SETDEFAULTRXVID_MSG(message, portID, tpid, vlanTag) \
  66. do { \
  67. message.data[0] = (IX_ETHNPE_VLAN_SETDEFAULTRXVID << 24) \
  68. | (portID << 16); \
  69. \
  70. message.data[1] = (tpid << 16) | vlanTag; \
  71. } while (0);
  72. #define FILL_SETRXTAGMODE_MSG(message, portID, filterMode, tagMode) \
  73. do { \
  74. message.data[0] = IX_ETHNPE_VLAN_SETRXTAGMODE << 24 \
  75. | portID << 16 \
  76. | filterMode << 2 \
  77. | tagMode; \
  78. \
  79. message.data[1] = 0; \
  80. } while (0);
  81. #define FILL_SETRXQOSENTRY(message, portID, classIndex, trafficClass, aqmQueue) \
  82. do { \
  83. message.data[0] = IX_ETHNPE_VLAN_SETRXQOSENTRY << 24 \
  84. | portID << 16 \
  85. | classIndex; \
  86. \
  87. message.data[1] = trafficClass << 24 \
  88. | 0x1 << 23 \
  89. | aqmQueue << 16 \
  90. | aqmQueue << 4; \
  91. } while (0);
  92. #define FILL_SETPORTIDEXTRACTIONMODE(message, portID, enable) \
  93. do { \
  94. message.data[0] = IX_ETHNPE_VLAN_SETPORTIDEXTRACTIONMODE << 24 \
  95. | portID << 16 \
  96. | (enable ? 0x1 : 0x0); \
  97. \
  98. message.data[1] = 0; \
  99. } while (0);
  100. #define FILL_SETBLOCKINGSTATE_MSG(message, portID, blocked) \
  101. do { \
  102. message.data[0] = IX_ETHNPE_STP_SETBLOCKINGSTATE << 24 \
  103. | portID << 16 \
  104. | (blocked ? 0x1 : 0x0); \
  105. \
  106. message.data[1] = 0; \
  107. } while (0);
  108. #define FILL_SETBBSID_MSG(message, portID, bbsid) \
  109. do { \
  110. message.data[0] = IX_ETHNPE_PC_SETBBSID << 24 \
  111. | portID << 16 \
  112. | bbsid->macAddress[0] << 8 \
  113. | bbsid->macAddress[1]; \
  114. \
  115. message.data[1] = bbsid->macAddress[2] << 24 \
  116. | bbsid->macAddress[3] << 16 \
  117. | bbsid->macAddress[4] << 8 \
  118. | bbsid->macAddress[5]; \
  119. } while (0);
  120. #define FILL_SETFRAMECONTROLDURATIONID(message, portID, frameControlDurationID) \
  121. do { \
  122. message.data[0] = (IX_ETHNPE_PC_SETFRAMECONTROLDURATIONID << 24) | (portID << 16); \
  123. message.data[1] = frameControlDurationID; \
  124. } while (0);
  125. #define FILL_SETAPMACTABLE_MSG(message, zone) \
  126. do { \
  127. message.data[0] = IX_ETHNPE_PC_SETAPMACTABLE << 24 \
  128. | 0 << 8 /* always use index 0 */ \
  129. | 64; /* 32 entries, 8 bytes each, 4 bytes in a word */ \
  130. message.data[1] = (UINT32) zone; \
  131. } while (0);
  132. #define FILL_SETFIREWALLMODE_MSG(message, portID, epDelta, mode, address) \
  133. do { \
  134. message.data[0] = IX_ETHNPE_FW_SETFIREWALLMODE << 24 \
  135. | portID << 16 \
  136. | (epDelta & 0xFF) << 8 \
  137. | mode; \
  138. \
  139. message.data[1] = (UINT32) address; \
  140. } while (0);
  141. #define FILL_SETMACADDRESSDATABASE_MSG(message, portID, epDelta, blockCount, address) \
  142. do { \
  143. message.data[0] = IX_ETHNPE_EDB_SETMACADDRESSSDATABASE << 24 \
  144. | (epDelta & 0xFF) << 8 \
  145. | (blockCount & 0xFF); \
  146. \
  147. message.data[1] = (UINT32) address; \
  148. } while (0);
  149. #define FILL_GETMACADDRESSDATABASE(message, npeId, zone) \
  150. do { \
  151. message.data[0] = IX_ETHNPE_EDB_GETMACADDRESSDATABASE << 24; \
  152. message.data[1] = (UINT32) zone; \
  153. } while (0);
  154. #define FILL_SETMAXFRAMELENGTHS_MSG(message, portID, maxRxFrameSize, maxTxFrameSize) \
  155. do { \
  156. message.data[0] = IX_ETHNPE_SETMAXFRAMELENGTHS << 24 \
  157. | portID << 16 \
  158. | ((maxRxFrameSize + 63) / 64) << 8 /* max Rx 64-byte blocks */ \
  159. | (maxTxFrameSize + 63) / 64; /* max Tx 64-byte blocks */ \
  160. \
  161. message.data[1] = maxRxFrameSize << 16 | maxTxFrameSize; \
  162. } while (0);
  163. #define FILL_SETPORTADDRESS_MSG(message, portID, macAddress) \
  164. do { \
  165. message.data[0] = IX_ETHNPE_EDB_SETPORTADDRESS << 24 \
  166. | portID << 16 \
  167. | macAddress[0] << 8 \
  168. | macAddress[1]; \
  169. \
  170. message.data[1] = macAddress[2] << 24 \
  171. | macAddress[3] << 16 \
  172. | macAddress[4] << 8 \
  173. | macAddress[5]; \
  174. } while (0);
  175. /* access to a MAC node in the NPE tree */
  176. #define NPE_NODE_BYTE(eltNodeAddr, offset) (((UINT8 *) (eltNodeAddr))[offset])
  177. /* browsing of the implicit linear binary tree structure of the NPE tree */
  178. #define LEFT_CHILD_OFFSET(offset) ((offset) << 1)
  179. #define RIGHT_CHILD_OFFSET(offset) (((offset) << 1) + 1)
  180. #define IX_EDB_FLAGS_ACTIVE (0x2)
  181. #define IX_EDB_FLAGS_VALID (0x1)
  182. #define IX_EDB_FLAGS_RESERVED (0xfc)
  183. #define IX_EDB_FLAGS_INACTIVE_VALID (0x1)
  184. #define IX_EDB_NPE_NODE_ELT_PORT_ID_OFFSET (6)
  185. #define IX_EDB_NPE_NODE_ELT_FLAGS_OFFSET (7)
  186. #define IX_EDB_NPE_NODE_WIFI_INDEX_OFFSET (6)
  187. #define IX_EDB_NPE_NODE_WIFI_FLAGS_OFFSET (7)
  188. #define IX_EDB_NPE_NODE_FW_FLAGS_OFFSET (1)
  189. #define IX_EDB_NPE_NODE_FW_RESERVED_OFFSET (6)
  190. #define IX_EDB_NPE_NODE_FW_ADDR_OFFSET (2)
  191. #define IX_EDB_NPE_NODE_VALID(address) ((NPE_NODE_BYTE(address, IX_EDB_NPE_NODE_ELT_FLAGS_OFFSET) & IX_EDB_FLAGS_VALID) != 0)
  192. #define IX_EDB_NPE_NODE_ACTIVE(address) ((NPE_NODE_BYTE(address, IX_EDB_NPE_NODE_ELT_FLAGS_OFFSET) & IX_EDB_FLAGS_ACTIVE) != 0)
  193. #define IX_EDB_NPE_NODE_PORT_ID(address) (NPE_NODE_BYTE(address, IX_EDB_NPE_NODE_ELT_PORT_ID_OFFSET))
  194. /* macros to send messages to the NPEs */
  195. #define IX_ETHDB_ASYNC_SEND_NPE_MSG(npeId, msg, result) \
  196. do { \
  197. result = ixNpeMhMessageSend(npeId, msg, IX_NPEMH_SEND_RETRIES_DEFAULT); \
  198. \
  199. if (result != IX_SUCCESS) \
  200. { \
  201. ERROR_LOG("DB: Failed to send NPE message\n"); \
  202. } \
  203. } while (0);
  204. #define IX_ETHDB_SYNC_SEND_NPE_MSG(npeId, msg, result) \
  205. do { \
  206. result = ixNpeMhMessageWithResponseSend(npeId, msg, msg.data[0] >> 24, ixEthDBNpeMsgAck, IX_NPEMH_SEND_RETRIES_DEFAULT); \
  207. \
  208. if (result == IX_SUCCESS) \
  209. { \
  210. result = ixOsalMutexLock(&ixEthDBPortInfo[IX_ETH_DB_NPE_TO_PORT_ID(npeId)].npeAckLock, IX_ETH_DB_NPE_TIMEOUT); \
  211. \
  212. if (result != IX_SUCCESS) \
  213. { \
  214. ERROR_LOG("DB: NPE failed to respond within %dms\n", IX_ETH_DB_NPE_TIMEOUT); \
  215. } \
  216. } \
  217. else \
  218. { \
  219. ERROR_LOG("DB: Failed to send NPE message\n"); \
  220. } \
  221. } while (0);
  222. #ifndef IX_NDEBUG
  223. #define IX_ETH_DB_NPE_MSG_HISTORY_DEPTH (100)
  224. extern IX_ETH_DB_PUBLIC UINT32 npeMsgHistory[IX_ETH_DB_NPE_MSG_HISTORY_DEPTH][2];
  225. extern IX_ETH_DB_PUBLIC UINT32 npeMsgHistoryLen;
  226. #endif
  227. #define IX_ETHDB_SEND_NPE_MSG(npeId, msg, result) { LOG_NPE_MSG(msg); IX_ETHDB_SYNC_SEND_NPE_MSG(npeId, msg, result); }
  228. #endif /* IxEthDBMessages_p_H */