IxEthDBMessages_p.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. * SPDX-License-Identifier: BSD-3-Clause
  17. * @par
  18. * -- End of Copyright Notice --
  19. */
  20. #ifndef IxEthDBMessages_p_H
  21. #define IxEthDBMessages_p_H
  22. #include <IxEthNpe.h>
  23. #include <IxOsCacheMMU.h>
  24. #include "IxEthDB_p.h"
  25. /* events watched by the Eth event processor */
  26. #define IX_ETH_DB_MIN_EVENT_ID (IX_ETHNPE_EDB_GETMACADDRESSDATABASE)
  27. #define IX_ETH_DB_MAX_EVENT_ID (IX_ETHNPE_PC_SETAPMACTABLE)
  28. /* macros to fill and extract data from NPE messages - place any endian conversions here */
  29. #define RESET_ELT_MESSAGE(message) { memset((void *) &(message), 0, sizeof((message))); }
  30. #define NPE_MSG_ID(msg) ((msg).data[0] >> 24)
  31. #define FILL_SETPORTVLANTABLEENTRY_MSG(message, portID, setOffset, vlanMembershipSet, ttiSet) \
  32. do { \
  33. message.data[0] = (IX_ETHNPE_VLAN_SETPORTVLANTABLEENTRY << 24) | (portID << 16) | (setOffset * 2); \
  34. message.data[1] = (vlanMembershipSet << 8) | ttiSet; \
  35. } while (0);
  36. #define FILL_SETPORTVLANTABLERANGE_MSG(message, portID, offset, length, zone) \
  37. do { \
  38. message.data[0] = IX_ETHNPE_VLAN_SETPORTVLANTABLERANGE << 24 | portID << 16 | offset << 9 | length << 1; \
  39. message.data[1] = (UINT32) zone; \
  40. } while (0);
  41. #define FILL_SETDEFAULTRXVID_MSG(message, portID, tpid, vlanTag) \
  42. do { \
  43. message.data[0] = (IX_ETHNPE_VLAN_SETDEFAULTRXVID << 24) \
  44. | (portID << 16); \
  45. \
  46. message.data[1] = (tpid << 16) | vlanTag; \
  47. } while (0);
  48. #define FILL_SETRXTAGMODE_MSG(message, portID, filterMode, tagMode) \
  49. do { \
  50. message.data[0] = IX_ETHNPE_VLAN_SETRXTAGMODE << 24 \
  51. | portID << 16 \
  52. | filterMode << 2 \
  53. | tagMode; \
  54. \
  55. message.data[1] = 0; \
  56. } while (0);
  57. #define FILL_SETRXQOSENTRY(message, portID, classIndex, trafficClass, aqmQueue) \
  58. do { \
  59. message.data[0] = IX_ETHNPE_VLAN_SETRXQOSENTRY << 24 \
  60. | portID << 16 \
  61. | classIndex; \
  62. \
  63. message.data[1] = trafficClass << 24 \
  64. | 0x1 << 23 \
  65. | aqmQueue << 16 \
  66. | aqmQueue << 4; \
  67. } while (0);
  68. #define FILL_SETPORTIDEXTRACTIONMODE(message, portID, enable) \
  69. do { \
  70. message.data[0] = IX_ETHNPE_VLAN_SETPORTIDEXTRACTIONMODE << 24 \
  71. | portID << 16 \
  72. | (enable ? 0x1 : 0x0); \
  73. \
  74. message.data[1] = 0; \
  75. } while (0);
  76. #define FILL_SETBLOCKINGSTATE_MSG(message, portID, blocked) \
  77. do { \
  78. message.data[0] = IX_ETHNPE_STP_SETBLOCKINGSTATE << 24 \
  79. | portID << 16 \
  80. | (blocked ? 0x1 : 0x0); \
  81. \
  82. message.data[1] = 0; \
  83. } while (0);
  84. #define FILL_SETBBSID_MSG(message, portID, bbsid) \
  85. do { \
  86. message.data[0] = IX_ETHNPE_PC_SETBBSID << 24 \
  87. | portID << 16 \
  88. | bbsid->macAddress[0] << 8 \
  89. | bbsid->macAddress[1]; \
  90. \
  91. message.data[1] = bbsid->macAddress[2] << 24 \
  92. | bbsid->macAddress[3] << 16 \
  93. | bbsid->macAddress[4] << 8 \
  94. | bbsid->macAddress[5]; \
  95. } while (0);
  96. #define FILL_SETFRAMECONTROLDURATIONID(message, portID, frameControlDurationID) \
  97. do { \
  98. message.data[0] = (IX_ETHNPE_PC_SETFRAMECONTROLDURATIONID << 24) | (portID << 16); \
  99. message.data[1] = frameControlDurationID; \
  100. } while (0);
  101. #define FILL_SETAPMACTABLE_MSG(message, zone) \
  102. do { \
  103. message.data[0] = IX_ETHNPE_PC_SETAPMACTABLE << 24 \
  104. | 0 << 8 /* always use index 0 */ \
  105. | 64; /* 32 entries, 8 bytes each, 4 bytes in a word */ \
  106. message.data[1] = (UINT32) zone; \
  107. } while (0);
  108. #define FILL_SETFIREWALLMODE_MSG(message, portID, epDelta, mode, address) \
  109. do { \
  110. message.data[0] = IX_ETHNPE_FW_SETFIREWALLMODE << 24 \
  111. | portID << 16 \
  112. | (epDelta & 0xFF) << 8 \
  113. | mode; \
  114. \
  115. message.data[1] = (UINT32) address; \
  116. } while (0);
  117. #define FILL_SETMACADDRESSDATABASE_MSG(message, portID, epDelta, blockCount, address) \
  118. do { \
  119. message.data[0] = IX_ETHNPE_EDB_SETMACADDRESSSDATABASE << 24 \
  120. | (epDelta & 0xFF) << 8 \
  121. | (blockCount & 0xFF); \
  122. \
  123. message.data[1] = (UINT32) address; \
  124. } while (0);
  125. #define FILL_GETMACADDRESSDATABASE(message, npeId, zone) \
  126. do { \
  127. message.data[0] = IX_ETHNPE_EDB_GETMACADDRESSDATABASE << 24; \
  128. message.data[1] = (UINT32) zone; \
  129. } while (0);
  130. #define FILL_SETMAXFRAMELENGTHS_MSG(message, portID, maxRxFrameSize, maxTxFrameSize) \
  131. do { \
  132. message.data[0] = IX_ETHNPE_SETMAXFRAMELENGTHS << 24 \
  133. | portID << 16 \
  134. | ((maxRxFrameSize + 63) / 64) << 8 /* max Rx 64-byte blocks */ \
  135. | (maxTxFrameSize + 63) / 64; /* max Tx 64-byte blocks */ \
  136. \
  137. message.data[1] = maxRxFrameSize << 16 | maxTxFrameSize; \
  138. } while (0);
  139. #define FILL_SETPORTADDRESS_MSG(message, portID, macAddress) \
  140. do { \
  141. message.data[0] = IX_ETHNPE_EDB_SETPORTADDRESS << 24 \
  142. | portID << 16 \
  143. | macAddress[0] << 8 \
  144. | macAddress[1]; \
  145. \
  146. message.data[1] = macAddress[2] << 24 \
  147. | macAddress[3] << 16 \
  148. | macAddress[4] << 8 \
  149. | macAddress[5]; \
  150. } while (0);
  151. /* access to a MAC node in the NPE tree */
  152. #define NPE_NODE_BYTE(eltNodeAddr, offset) (((UINT8 *) (eltNodeAddr))[offset])
  153. /* browsing of the implicit linear binary tree structure of the NPE tree */
  154. #define LEFT_CHILD_OFFSET(offset) ((offset) << 1)
  155. #define RIGHT_CHILD_OFFSET(offset) (((offset) << 1) + 1)
  156. #define IX_EDB_FLAGS_ACTIVE (0x2)
  157. #define IX_EDB_FLAGS_VALID (0x1)
  158. #define IX_EDB_FLAGS_RESERVED (0xfc)
  159. #define IX_EDB_FLAGS_INACTIVE_VALID (0x1)
  160. #define IX_EDB_NPE_NODE_ELT_PORT_ID_OFFSET (6)
  161. #define IX_EDB_NPE_NODE_ELT_FLAGS_OFFSET (7)
  162. #define IX_EDB_NPE_NODE_WIFI_INDEX_OFFSET (6)
  163. #define IX_EDB_NPE_NODE_WIFI_FLAGS_OFFSET (7)
  164. #define IX_EDB_NPE_NODE_FW_FLAGS_OFFSET (1)
  165. #define IX_EDB_NPE_NODE_FW_RESERVED_OFFSET (6)
  166. #define IX_EDB_NPE_NODE_FW_ADDR_OFFSET (2)
  167. #define IX_EDB_NPE_NODE_VALID(address) ((NPE_NODE_BYTE(address, IX_EDB_NPE_NODE_ELT_FLAGS_OFFSET) & IX_EDB_FLAGS_VALID) != 0)
  168. #define IX_EDB_NPE_NODE_ACTIVE(address) ((NPE_NODE_BYTE(address, IX_EDB_NPE_NODE_ELT_FLAGS_OFFSET) & IX_EDB_FLAGS_ACTIVE) != 0)
  169. #define IX_EDB_NPE_NODE_PORT_ID(address) (NPE_NODE_BYTE(address, IX_EDB_NPE_NODE_ELT_PORT_ID_OFFSET))
  170. /* macros to send messages to the NPEs */
  171. #define IX_ETHDB_ASYNC_SEND_NPE_MSG(npeId, msg, result) \
  172. do { \
  173. result = ixNpeMhMessageSend(npeId, msg, IX_NPEMH_SEND_RETRIES_DEFAULT); \
  174. \
  175. if (result != IX_SUCCESS) \
  176. { \
  177. ERROR_LOG("DB: Failed to send NPE message\n"); \
  178. } \
  179. } while (0);
  180. #define IX_ETHDB_SYNC_SEND_NPE_MSG(npeId, msg, result) \
  181. do { \
  182. result = ixNpeMhMessageWithResponseSend(npeId, msg, msg.data[0] >> 24, ixEthDBNpeMsgAck, IX_NPEMH_SEND_RETRIES_DEFAULT); \
  183. \
  184. if (result == IX_SUCCESS) \
  185. { \
  186. result = ixOsalMutexLock(&ixEthDBPortInfo[IX_ETH_DB_NPE_TO_PORT_ID(npeId)].npeAckLock, IX_ETH_DB_NPE_TIMEOUT); \
  187. \
  188. if (result != IX_SUCCESS) \
  189. { \
  190. ERROR_LOG("DB: NPE failed to respond within %dms\n", IX_ETH_DB_NPE_TIMEOUT); \
  191. } \
  192. } \
  193. else \
  194. { \
  195. ERROR_LOG("DB: Failed to send NPE message\n"); \
  196. } \
  197. } while (0);
  198. #ifndef IX_NDEBUG
  199. #define IX_ETH_DB_NPE_MSG_HISTORY_DEPTH (100)
  200. extern IX_ETH_DB_PUBLIC UINT32 npeMsgHistory[IX_ETH_DB_NPE_MSG_HISTORY_DEPTH][2];
  201. extern IX_ETH_DB_PUBLIC UINT32 npeMsgHistoryLen;
  202. #endif
  203. #define IX_ETHDB_SEND_NPE_MSG(npeId, msg, result) { LOG_NPE_MSG(msg); IX_ETHDB_SYNC_SEND_NPE_MSG(npeId, msg, result); }
  204. #endif /* IxEthDBMessages_p_H */