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 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
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.
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
42 * -- End of Copyright Notice --
45 #ifndef IxEthDBMessages_p_H
46 #define IxEthDBMessages_p_H
49 #include <IxOsCacheMMU.h>
50 #include "IxEthDB_p.h"
52 /* events watched by the Eth event processor */
53 #define IX_ETH_DB_MIN_EVENT_ID (IX_ETHNPE_EDB_GETMACADDRESSDATABASE)
54 #define IX_ETH_DB_MAX_EVENT_ID (IX_ETHNPE_PC_SETAPMACTABLE)
56 /* macros to fill and extract data from NPE messages - place any endian conversions here */
57 #define RESET_ELT_MESSAGE(message) { memset((void *) &(message), 0, sizeof((message))); }
58 #define NPE_MSG_ID(msg) ((msg).data[0] >> 24)
60 #define FILL_SETPORTVLANTABLEENTRY_MSG(message, portID, setOffset, vlanMembershipSet, ttiSet) \
62 message.data[0] = (IX_ETHNPE_VLAN_SETPORTVLANTABLEENTRY << 24) | (portID << 16) | (setOffset * 2); \
63 message.data[1] = (vlanMembershipSet << 8) | ttiSet; \
66 #define FILL_SETPORTVLANTABLERANGE_MSG(message, portID, offset, length, zone) \
68 message.data[0] = IX_ETHNPE_VLAN_SETPORTVLANTABLERANGE << 24 | portID << 16 | offset << 9 | length << 1; \
69 message.data[1] = (UINT32) zone; \
72 #define FILL_SETDEFAULTRXVID_MSG(message, portID, tpid, vlanTag) \
74 message.data[0] = (IX_ETHNPE_VLAN_SETDEFAULTRXVID << 24) \
77 message.data[1] = (tpid << 16) | vlanTag; \
80 #define FILL_SETRXTAGMODE_MSG(message, portID, filterMode, tagMode) \
82 message.data[0] = IX_ETHNPE_VLAN_SETRXTAGMODE << 24 \
87 message.data[1] = 0; \
90 #define FILL_SETRXQOSENTRY(message, portID, classIndex, trafficClass, aqmQueue) \
92 message.data[0] = IX_ETHNPE_VLAN_SETRXQOSENTRY << 24 \
96 message.data[1] = trafficClass << 24 \
102 #define FILL_SETPORTIDEXTRACTIONMODE(message, portID, enable) \
104 message.data[0] = IX_ETHNPE_VLAN_SETPORTIDEXTRACTIONMODE << 24 \
106 | (enable ? 0x1 : 0x0); \
108 message.data[1] = 0; \
112 #define FILL_SETBLOCKINGSTATE_MSG(message, portID, blocked) \
114 message.data[0] = IX_ETHNPE_STP_SETBLOCKINGSTATE << 24 \
116 | (blocked ? 0x1 : 0x0); \
118 message.data[1] = 0; \
121 #define FILL_SETBBSID_MSG(message, portID, bbsid) \
123 message.data[0] = IX_ETHNPE_PC_SETBBSID << 24 \
125 | bbsid->macAddress[0] << 8 \
126 | bbsid->macAddress[1]; \
128 message.data[1] = bbsid->macAddress[2] << 24 \
129 | bbsid->macAddress[3] << 16 \
130 | bbsid->macAddress[4] << 8 \
131 | bbsid->macAddress[5]; \
134 #define FILL_SETFRAMECONTROLDURATIONID(message, portID, frameControlDurationID) \
136 message.data[0] = (IX_ETHNPE_PC_SETFRAMECONTROLDURATIONID << 24) | (portID << 16); \
137 message.data[1] = frameControlDurationID; \
140 #define FILL_SETAPMACTABLE_MSG(message, zone) \
142 message.data[0] = IX_ETHNPE_PC_SETAPMACTABLE << 24 \
143 | 0 << 8 /* always use index 0 */ \
144 | 64; /* 32 entries, 8 bytes each, 4 bytes in a word */ \
145 message.data[1] = (UINT32) zone; \
148 #define FILL_SETFIREWALLMODE_MSG(message, portID, epDelta, mode, address) \
150 message.data[0] = IX_ETHNPE_FW_SETFIREWALLMODE << 24 \
152 | (epDelta & 0xFF) << 8 \
155 message.data[1] = (UINT32) address; \
158 #define FILL_SETMACADDRESSDATABASE_MSG(message, portID, epDelta, blockCount, address) \
160 message.data[0] = IX_ETHNPE_EDB_SETMACADDRESSSDATABASE << 24 \
161 | (epDelta & 0xFF) << 8 \
162 | (blockCount & 0xFF); \
164 message.data[1] = (UINT32) address; \
167 #define FILL_GETMACADDRESSDATABASE(message, npeId, zone) \
169 message.data[0] = IX_ETHNPE_EDB_GETMACADDRESSDATABASE << 24; \
170 message.data[1] = (UINT32) zone; \
173 #define FILL_SETMAXFRAMELENGTHS_MSG(message, portID, maxRxFrameSize, maxTxFrameSize) \
175 message.data[0] = IX_ETHNPE_SETMAXFRAMELENGTHS << 24 \
177 | ((maxRxFrameSize + 63) / 64) << 8 /* max Rx 64-byte blocks */ \
178 | (maxTxFrameSize + 63) / 64; /* max Tx 64-byte blocks */ \
180 message.data[1] = maxRxFrameSize << 16 | maxTxFrameSize; \
183 #define FILL_SETPORTADDRESS_MSG(message, portID, macAddress) \
185 message.data[0] = IX_ETHNPE_EDB_SETPORTADDRESS << 24 \
187 | macAddress[0] << 8 \
190 message.data[1] = macAddress[2] << 24 \
191 | macAddress[3] << 16 \
192 | macAddress[4] << 8 \
196 /* access to a MAC node in the NPE tree */
197 #define NPE_NODE_BYTE(eltNodeAddr, offset) (((UINT8 *) (eltNodeAddr))[offset])
199 /* browsing of the implicit linear binary tree structure of the NPE tree */
200 #define LEFT_CHILD_OFFSET(offset) ((offset) << 1)
201 #define RIGHT_CHILD_OFFSET(offset) (((offset) << 1) + 1)
203 #define IX_EDB_FLAGS_ACTIVE (0x2)
204 #define IX_EDB_FLAGS_VALID (0x1)
205 #define IX_EDB_FLAGS_RESERVED (0xfc)
206 #define IX_EDB_FLAGS_INACTIVE_VALID (0x1)
208 #define IX_EDB_NPE_NODE_ELT_PORT_ID_OFFSET (6)
209 #define IX_EDB_NPE_NODE_ELT_FLAGS_OFFSET (7)
210 #define IX_EDB_NPE_NODE_WIFI_INDEX_OFFSET (6)
211 #define IX_EDB_NPE_NODE_WIFI_FLAGS_OFFSET (7)
212 #define IX_EDB_NPE_NODE_FW_FLAGS_OFFSET (1)
213 #define IX_EDB_NPE_NODE_FW_RESERVED_OFFSET (6)
214 #define IX_EDB_NPE_NODE_FW_ADDR_OFFSET (2)
216 #define IX_EDB_NPE_NODE_VALID(address) ((NPE_NODE_BYTE(address, IX_EDB_NPE_NODE_ELT_FLAGS_OFFSET) & IX_EDB_FLAGS_VALID) != 0)
217 #define IX_EDB_NPE_NODE_ACTIVE(address) ((NPE_NODE_BYTE(address, IX_EDB_NPE_NODE_ELT_FLAGS_OFFSET) & IX_EDB_FLAGS_ACTIVE) != 0)
218 #define IX_EDB_NPE_NODE_PORT_ID(address) (NPE_NODE_BYTE(address, IX_EDB_NPE_NODE_ELT_PORT_ID_OFFSET))
220 /* macros to send messages to the NPEs */
221 #define IX_ETHDB_ASYNC_SEND_NPE_MSG(npeId, msg, result) \
223 result = ixNpeMhMessageSend(npeId, msg, IX_NPEMH_SEND_RETRIES_DEFAULT); \
225 if (result != IX_SUCCESS) \
227 ERROR_LOG("DB: Failed to send NPE message\n"); \
231 #define IX_ETHDB_SYNC_SEND_NPE_MSG(npeId, msg, result) \
233 result = ixNpeMhMessageWithResponseSend(npeId, msg, msg.data[0] >> 24, ixEthDBNpeMsgAck, IX_NPEMH_SEND_RETRIES_DEFAULT); \
235 if (result == IX_SUCCESS) \
237 result = ixOsalMutexLock(&ixEthDBPortInfo[IX_ETH_DB_NPE_TO_PORT_ID(npeId)].npeAckLock, IX_ETH_DB_NPE_TIMEOUT); \
239 if (result != IX_SUCCESS) \
241 ERROR_LOG("DB: NPE failed to respond within %dms\n", IX_ETH_DB_NPE_TIMEOUT); \
246 ERROR_LOG("DB: Failed to send NPE message\n"); \
251 #define IX_ETH_DB_NPE_MSG_HISTORY_DEPTH (100)
252 extern IX_ETH_DB_PUBLIC UINT32 npeMsgHistory[IX_ETH_DB_NPE_MSG_HISTORY_DEPTH][2];
253 extern IX_ETH_DB_PUBLIC UINT32 npeMsgHistoryLen;
256 #define IX_ETHDB_SEND_NPE_MSG(npeId, msg, result) { LOG_NPE_MSG(msg); IX_ETHDB_SYNC_SEND_NPE_MSG(npeId, msg, result); }
258 #endif /* IxEthDBMessages_p_H */