2 * @file IxEthDBMessages_p.h
4 * @brief Definitions of NPE messages
7 * IXP400 SW Release version 2.0
9 * -- Copyright Notice --
12 * Copyright 2001-2005, Intel Corporation.
13 * All rights reserved.
16 * SPDX-License-Identifier: BSD-3-Clause
18 * -- End of Copyright Notice --
21 #ifndef IxEthDBMessages_p_H
22 #define IxEthDBMessages_p_H
25 #include <IxOsCacheMMU.h>
26 #include "IxEthDB_p.h"
28 /* events watched by the Eth event processor */
29 #define IX_ETH_DB_MIN_EVENT_ID (IX_ETHNPE_EDB_GETMACADDRESSDATABASE)
30 #define IX_ETH_DB_MAX_EVENT_ID (IX_ETHNPE_PC_SETAPMACTABLE)
32 /* macros to fill and extract data from NPE messages - place any endian conversions here */
33 #define RESET_ELT_MESSAGE(message) { memset((void *) &(message), 0, sizeof((message))); }
34 #define NPE_MSG_ID(msg) ((msg).data[0] >> 24)
36 #define FILL_SETPORTVLANTABLEENTRY_MSG(message, portID, setOffset, vlanMembershipSet, ttiSet) \
38 message.data[0] = (IX_ETHNPE_VLAN_SETPORTVLANTABLEENTRY << 24) | (portID << 16) | (setOffset * 2); \
39 message.data[1] = (vlanMembershipSet << 8) | ttiSet; \
42 #define FILL_SETPORTVLANTABLERANGE_MSG(message, portID, offset, length, zone) \
44 message.data[0] = IX_ETHNPE_VLAN_SETPORTVLANTABLERANGE << 24 | portID << 16 | offset << 9 | length << 1; \
45 message.data[1] = (UINT32) zone; \
48 #define FILL_SETDEFAULTRXVID_MSG(message, portID, tpid, vlanTag) \
50 message.data[0] = (IX_ETHNPE_VLAN_SETDEFAULTRXVID << 24) \
53 message.data[1] = (tpid << 16) | vlanTag; \
56 #define FILL_SETRXTAGMODE_MSG(message, portID, filterMode, tagMode) \
58 message.data[0] = IX_ETHNPE_VLAN_SETRXTAGMODE << 24 \
63 message.data[1] = 0; \
66 #define FILL_SETRXQOSENTRY(message, portID, classIndex, trafficClass, aqmQueue) \
68 message.data[0] = IX_ETHNPE_VLAN_SETRXQOSENTRY << 24 \
72 message.data[1] = trafficClass << 24 \
78 #define FILL_SETPORTIDEXTRACTIONMODE(message, portID, enable) \
80 message.data[0] = IX_ETHNPE_VLAN_SETPORTIDEXTRACTIONMODE << 24 \
82 | (enable ? 0x1 : 0x0); \
84 message.data[1] = 0; \
88 #define FILL_SETBLOCKINGSTATE_MSG(message, portID, blocked) \
90 message.data[0] = IX_ETHNPE_STP_SETBLOCKINGSTATE << 24 \
92 | (blocked ? 0x1 : 0x0); \
94 message.data[1] = 0; \
97 #define FILL_SETBBSID_MSG(message, portID, bbsid) \
99 message.data[0] = IX_ETHNPE_PC_SETBBSID << 24 \
101 | bbsid->macAddress[0] << 8 \
102 | bbsid->macAddress[1]; \
104 message.data[1] = bbsid->macAddress[2] << 24 \
105 | bbsid->macAddress[3] << 16 \
106 | bbsid->macAddress[4] << 8 \
107 | bbsid->macAddress[5]; \
110 #define FILL_SETFRAMECONTROLDURATIONID(message, portID, frameControlDurationID) \
112 message.data[0] = (IX_ETHNPE_PC_SETFRAMECONTROLDURATIONID << 24) | (portID << 16); \
113 message.data[1] = frameControlDurationID; \
116 #define FILL_SETAPMACTABLE_MSG(message, zone) \
118 message.data[0] = IX_ETHNPE_PC_SETAPMACTABLE << 24 \
119 | 0 << 8 /* always use index 0 */ \
120 | 64; /* 32 entries, 8 bytes each, 4 bytes in a word */ \
121 message.data[1] = (UINT32) zone; \
124 #define FILL_SETFIREWALLMODE_MSG(message, portID, epDelta, mode, address) \
126 message.data[0] = IX_ETHNPE_FW_SETFIREWALLMODE << 24 \
128 | (epDelta & 0xFF) << 8 \
131 message.data[1] = (UINT32) address; \
134 #define FILL_SETMACADDRESSDATABASE_MSG(message, portID, epDelta, blockCount, address) \
136 message.data[0] = IX_ETHNPE_EDB_SETMACADDRESSSDATABASE << 24 \
137 | (epDelta & 0xFF) << 8 \
138 | (blockCount & 0xFF); \
140 message.data[1] = (UINT32) address; \
143 #define FILL_GETMACADDRESSDATABASE(message, npeId, zone) \
145 message.data[0] = IX_ETHNPE_EDB_GETMACADDRESSDATABASE << 24; \
146 message.data[1] = (UINT32) zone; \
149 #define FILL_SETMAXFRAMELENGTHS_MSG(message, portID, maxRxFrameSize, maxTxFrameSize) \
151 message.data[0] = IX_ETHNPE_SETMAXFRAMELENGTHS << 24 \
153 | ((maxRxFrameSize + 63) / 64) << 8 /* max Rx 64-byte blocks */ \
154 | (maxTxFrameSize + 63) / 64; /* max Tx 64-byte blocks */ \
156 message.data[1] = maxRxFrameSize << 16 | maxTxFrameSize; \
159 #define FILL_SETPORTADDRESS_MSG(message, portID, macAddress) \
161 message.data[0] = IX_ETHNPE_EDB_SETPORTADDRESS << 24 \
163 | macAddress[0] << 8 \
166 message.data[1] = macAddress[2] << 24 \
167 | macAddress[3] << 16 \
168 | macAddress[4] << 8 \
172 /* access to a MAC node in the NPE tree */
173 #define NPE_NODE_BYTE(eltNodeAddr, offset) (((UINT8 *) (eltNodeAddr))[offset])
175 /* browsing of the implicit linear binary tree structure of the NPE tree */
176 #define LEFT_CHILD_OFFSET(offset) ((offset) << 1)
177 #define RIGHT_CHILD_OFFSET(offset) (((offset) << 1) + 1)
179 #define IX_EDB_FLAGS_ACTIVE (0x2)
180 #define IX_EDB_FLAGS_VALID (0x1)
181 #define IX_EDB_FLAGS_RESERVED (0xfc)
182 #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)
192 #define IX_EDB_NPE_NODE_VALID(address) ((NPE_NODE_BYTE(address, IX_EDB_NPE_NODE_ELT_FLAGS_OFFSET) & IX_EDB_FLAGS_VALID) != 0)
193 #define IX_EDB_NPE_NODE_ACTIVE(address) ((NPE_NODE_BYTE(address, IX_EDB_NPE_NODE_ELT_FLAGS_OFFSET) & IX_EDB_FLAGS_ACTIVE) != 0)
194 #define IX_EDB_NPE_NODE_PORT_ID(address) (NPE_NODE_BYTE(address, IX_EDB_NPE_NODE_ELT_PORT_ID_OFFSET))
196 /* macros to send messages to the NPEs */
197 #define IX_ETHDB_ASYNC_SEND_NPE_MSG(npeId, msg, result) \
199 result = ixNpeMhMessageSend(npeId, msg, IX_NPEMH_SEND_RETRIES_DEFAULT); \
201 if (result != IX_SUCCESS) \
203 ERROR_LOG("DB: Failed to send NPE message\n"); \
207 #define IX_ETHDB_SYNC_SEND_NPE_MSG(npeId, msg, result) \
209 result = ixNpeMhMessageWithResponseSend(npeId, msg, msg.data[0] >> 24, ixEthDBNpeMsgAck, IX_NPEMH_SEND_RETRIES_DEFAULT); \
211 if (result == IX_SUCCESS) \
213 result = ixOsalMutexLock(&ixEthDBPortInfo[IX_ETH_DB_NPE_TO_PORT_ID(npeId)].npeAckLock, IX_ETH_DB_NPE_TIMEOUT); \
215 if (result != IX_SUCCESS) \
217 ERROR_LOG("DB: NPE failed to respond within %dms\n", IX_ETH_DB_NPE_TIMEOUT); \
222 ERROR_LOG("DB: Failed to send NPE message\n"); \
227 #define IX_ETH_DB_NPE_MSG_HISTORY_DEPTH (100)
228 extern IX_ETH_DB_PUBLIC UINT32 npeMsgHistory[IX_ETH_DB_NPE_MSG_HISTORY_DEPTH][2];
229 extern IX_ETH_DB_PUBLIC UINT32 npeMsgHistoryLen;
232 #define IX_ETHDB_SEND_NPE_MSG(npeId, msg, result) { LOG_NPE_MSG(msg); IX_ETHDB_SYNC_SEND_NPE_MSG(npeId, msg, result); }
234 #endif /* IxEthDBMessages_p_H */