blob: 5907fd59e25f46bb05ac4fa3c87c6b63d369355e [file] [log] [blame]
Wolfgang Denk4646d2a2006-05-30 15:56:48 +02001/**
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
Wolfgang Denkc57eadc2013-07-28 22:12:47 +020016 * SPDX-License-Identifier: BSD-3-Clause
Wolfgang Denk4646d2a2006-05-30 15:56:48 +020017 * @par
18 * -- End of Copyright Notice --
19 */
20
21#ifndef IxEthDBMessages_p_H
22#define IxEthDBMessages_p_H
23
24#include <IxEthNpe.h>
25#include <IxOsCacheMMU.h>
26#include "IxEthDB_p.h"
27
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)
31
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)
35
36#define FILL_SETPORTVLANTABLEENTRY_MSG(message, portID, setOffset, vlanMembershipSet, ttiSet) \
37 do { \
38 message.data[0] = (IX_ETHNPE_VLAN_SETPORTVLANTABLEENTRY << 24) | (portID << 16) | (setOffset * 2); \
39 message.data[1] = (vlanMembershipSet << 8) | ttiSet; \
40 } while (0);
41
42#define FILL_SETPORTVLANTABLERANGE_MSG(message, portID, offset, length, zone) \
43 do { \
44 message.data[0] = IX_ETHNPE_VLAN_SETPORTVLANTABLERANGE << 24 | portID << 16 | offset << 9 | length << 1; \
45 message.data[1] = (UINT32) zone; \
46 } while (0);
47
48#define FILL_SETDEFAULTRXVID_MSG(message, portID, tpid, vlanTag) \
49 do { \
50 message.data[0] = (IX_ETHNPE_VLAN_SETDEFAULTRXVID << 24) \
51 | (portID << 16); \
52 \
53 message.data[1] = (tpid << 16) | vlanTag; \
54 } while (0);
55
56#define FILL_SETRXTAGMODE_MSG(message, portID, filterMode, tagMode) \
57 do { \
58 message.data[0] = IX_ETHNPE_VLAN_SETRXTAGMODE << 24 \
59 | portID << 16 \
60 | filterMode << 2 \
61 | tagMode; \
62 \
63 message.data[1] = 0; \
64 } while (0);
65
66#define FILL_SETRXQOSENTRY(message, portID, classIndex, trafficClass, aqmQueue) \
67 do { \
68 message.data[0] = IX_ETHNPE_VLAN_SETRXQOSENTRY << 24 \
69 | portID << 16 \
70 | classIndex; \
71 \
72 message.data[1] = trafficClass << 24 \
73 | 0x1 << 23 \
74 | aqmQueue << 16 \
75 | aqmQueue << 4; \
76 } while (0);
77
78#define FILL_SETPORTIDEXTRACTIONMODE(message, portID, enable) \
79 do { \
80 message.data[0] = IX_ETHNPE_VLAN_SETPORTIDEXTRACTIONMODE << 24 \
81 | portID << 16 \
82 | (enable ? 0x1 : 0x0); \
83 \
84 message.data[1] = 0; \
85 } while (0);
86
87
88#define FILL_SETBLOCKINGSTATE_MSG(message, portID, blocked) \
89 do { \
90 message.data[0] = IX_ETHNPE_STP_SETBLOCKINGSTATE << 24 \
91 | portID << 16 \
92 | (blocked ? 0x1 : 0x0); \
93 \
94 message.data[1] = 0; \
95 } while (0);
96
97#define FILL_SETBBSID_MSG(message, portID, bbsid) \
98 do { \
99 message.data[0] = IX_ETHNPE_PC_SETBBSID << 24 \
100 | portID << 16 \
101 | bbsid->macAddress[0] << 8 \
102 | bbsid->macAddress[1]; \
103 \
104 message.data[1] = bbsid->macAddress[2] << 24 \
105 | bbsid->macAddress[3] << 16 \
106 | bbsid->macAddress[4] << 8 \
107 | bbsid->macAddress[5]; \
108 } while (0);
109
110#define FILL_SETFRAMECONTROLDURATIONID(message, portID, frameControlDurationID) \
111 do { \
112 message.data[0] = (IX_ETHNPE_PC_SETFRAMECONTROLDURATIONID << 24) | (portID << 16); \
113 message.data[1] = frameControlDurationID; \
114 } while (0);
115
116#define FILL_SETAPMACTABLE_MSG(message, zone) \
117 do { \
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; \
122 } while (0);
123
124#define FILL_SETFIREWALLMODE_MSG(message, portID, epDelta, mode, address) \
125 do { \
126 message.data[0] = IX_ETHNPE_FW_SETFIREWALLMODE << 24 \
127 | portID << 16 \
128 | (epDelta & 0xFF) << 8 \
129 | mode; \
130 \
131 message.data[1] = (UINT32) address; \
132 } while (0);
133
134#define FILL_SETMACADDRESSDATABASE_MSG(message, portID, epDelta, blockCount, address) \
135 do { \
136 message.data[0] = IX_ETHNPE_EDB_SETMACADDRESSSDATABASE << 24 \
137 | (epDelta & 0xFF) << 8 \
138 | (blockCount & 0xFF); \
139 \
140 message.data[1] = (UINT32) address; \
141 } while (0);
142
143#define FILL_GETMACADDRESSDATABASE(message, npeId, zone) \
144 do { \
145 message.data[0] = IX_ETHNPE_EDB_GETMACADDRESSDATABASE << 24; \
146 message.data[1] = (UINT32) zone; \
147 } while (0);
148
149#define FILL_SETMAXFRAMELENGTHS_MSG(message, portID, maxRxFrameSize, maxTxFrameSize) \
150 do { \
151 message.data[0] = IX_ETHNPE_SETMAXFRAMELENGTHS << 24 \
152 | portID << 16 \
153 | ((maxRxFrameSize + 63) / 64) << 8 /* max Rx 64-byte blocks */ \
154 | (maxTxFrameSize + 63) / 64; /* max Tx 64-byte blocks */ \
155 \
156 message.data[1] = maxRxFrameSize << 16 | maxTxFrameSize; \
157 } while (0);
158
159#define FILL_SETPORTADDRESS_MSG(message, portID, macAddress) \
160 do { \
161 message.data[0] = IX_ETHNPE_EDB_SETPORTADDRESS << 24 \
162 | portID << 16 \
163 | macAddress[0] << 8 \
164 | macAddress[1]; \
165 \
166 message.data[1] = macAddress[2] << 24 \
167 | macAddress[3] << 16 \
168 | macAddress[4] << 8 \
169 | macAddress[5]; \
170 } while (0);
171
172/* access to a MAC node in the NPE tree */
173#define NPE_NODE_BYTE(eltNodeAddr, offset) (((UINT8 *) (eltNodeAddr))[offset])
174
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)
178
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)
183
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
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))
195
196/* macros to send messages to the NPEs */
197#define IX_ETHDB_ASYNC_SEND_NPE_MSG(npeId, msg, result) \
198 do { \
199 result = ixNpeMhMessageSend(npeId, msg, IX_NPEMH_SEND_RETRIES_DEFAULT); \
200 \
201 if (result != IX_SUCCESS) \
202 { \
203 ERROR_LOG("DB: Failed to send NPE message\n"); \
204 } \
205 } while (0);
206
207#define IX_ETHDB_SYNC_SEND_NPE_MSG(npeId, msg, result) \
208 do { \
209 result = ixNpeMhMessageWithResponseSend(npeId, msg, msg.data[0] >> 24, ixEthDBNpeMsgAck, IX_NPEMH_SEND_RETRIES_DEFAULT); \
210 \
211 if (result == IX_SUCCESS) \
212 { \
213 result = ixOsalMutexLock(&ixEthDBPortInfo[IX_ETH_DB_NPE_TO_PORT_ID(npeId)].npeAckLock, IX_ETH_DB_NPE_TIMEOUT); \
214 \
215 if (result != IX_SUCCESS) \
216 { \
217 ERROR_LOG("DB: NPE failed to respond within %dms\n", IX_ETH_DB_NPE_TIMEOUT); \
218 } \
219 } \
220 else \
221 { \
222 ERROR_LOG("DB: Failed to send NPE message\n"); \
223 } \
224 } while (0);
225
226#ifndef IX_NDEBUG
227#define IX_ETH_DB_NPE_MSG_HISTORY_DEPTH (100)
228extern IX_ETH_DB_PUBLIC UINT32 npeMsgHistory[IX_ETH_DB_NPE_MSG_HISTORY_DEPTH][2];
229extern IX_ETH_DB_PUBLIC UINT32 npeMsgHistoryLen;
230#endif
231
232#define IX_ETHDB_SEND_NPE_MSG(npeId, msg, result) { LOG_NPE_MSG(msg); IX_ETHDB_SYNC_SEND_NPE_MSG(npeId, msg, result); }
233
234#endif /* IxEthDBMessages_p_H */