Wolfgang Denk | 4646d2a | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 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 | |
| 45 | #ifndef IxEthDBMessages_p_H |
| 46 | #define IxEthDBMessages_p_H |
| 47 | |
| 48 | #include <IxEthNpe.h> |
| 49 | #include <IxOsCacheMMU.h> |
| 50 | #include "IxEthDB_p.h" |
| 51 | |
| 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) |
| 55 | |
| 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) |
| 59 | |
| 60 | #define FILL_SETPORTVLANTABLEENTRY_MSG(message, portID, setOffset, vlanMembershipSet, ttiSet) \ |
| 61 | do { \ |
| 62 | message.data[0] = (IX_ETHNPE_VLAN_SETPORTVLANTABLEENTRY << 24) | (portID << 16) | (setOffset * 2); \ |
| 63 | message.data[1] = (vlanMembershipSet << 8) | ttiSet; \ |
| 64 | } while (0); |
| 65 | |
| 66 | #define FILL_SETPORTVLANTABLERANGE_MSG(message, portID, offset, length, zone) \ |
| 67 | do { \ |
| 68 | message.data[0] = IX_ETHNPE_VLAN_SETPORTVLANTABLERANGE << 24 | portID << 16 | offset << 9 | length << 1; \ |
| 69 | message.data[1] = (UINT32) zone; \ |
| 70 | } while (0); |
| 71 | |
| 72 | #define FILL_SETDEFAULTRXVID_MSG(message, portID, tpid, vlanTag) \ |
| 73 | do { \ |
| 74 | message.data[0] = (IX_ETHNPE_VLAN_SETDEFAULTRXVID << 24) \ |
| 75 | | (portID << 16); \ |
| 76 | \ |
| 77 | message.data[1] = (tpid << 16) | vlanTag; \ |
| 78 | } while (0); |
| 79 | |
| 80 | #define FILL_SETRXTAGMODE_MSG(message, portID, filterMode, tagMode) \ |
| 81 | do { \ |
| 82 | message.data[0] = IX_ETHNPE_VLAN_SETRXTAGMODE << 24 \ |
| 83 | | portID << 16 \ |
| 84 | | filterMode << 2 \ |
| 85 | | tagMode; \ |
| 86 | \ |
| 87 | message.data[1] = 0; \ |
| 88 | } while (0); |
| 89 | |
| 90 | #define FILL_SETRXQOSENTRY(message, portID, classIndex, trafficClass, aqmQueue) \ |
| 91 | do { \ |
| 92 | message.data[0] = IX_ETHNPE_VLAN_SETRXQOSENTRY << 24 \ |
| 93 | | portID << 16 \ |
| 94 | | classIndex; \ |
| 95 | \ |
| 96 | message.data[1] = trafficClass << 24 \ |
| 97 | | 0x1 << 23 \ |
| 98 | | aqmQueue << 16 \ |
| 99 | | aqmQueue << 4; \ |
| 100 | } while (0); |
| 101 | |
| 102 | #define FILL_SETPORTIDEXTRACTIONMODE(message, portID, enable) \ |
| 103 | do { \ |
| 104 | message.data[0] = IX_ETHNPE_VLAN_SETPORTIDEXTRACTIONMODE << 24 \ |
| 105 | | portID << 16 \ |
| 106 | | (enable ? 0x1 : 0x0); \ |
| 107 | \ |
| 108 | message.data[1] = 0; \ |
| 109 | } while (0); |
| 110 | |
| 111 | |
| 112 | #define FILL_SETBLOCKINGSTATE_MSG(message, portID, blocked) \ |
| 113 | do { \ |
| 114 | message.data[0] = IX_ETHNPE_STP_SETBLOCKINGSTATE << 24 \ |
| 115 | | portID << 16 \ |
| 116 | | (blocked ? 0x1 : 0x0); \ |
| 117 | \ |
| 118 | message.data[1] = 0; \ |
| 119 | } while (0); |
| 120 | |
| 121 | #define FILL_SETBBSID_MSG(message, portID, bbsid) \ |
| 122 | do { \ |
| 123 | message.data[0] = IX_ETHNPE_PC_SETBBSID << 24 \ |
| 124 | | portID << 16 \ |
| 125 | | bbsid->macAddress[0] << 8 \ |
| 126 | | bbsid->macAddress[1]; \ |
| 127 | \ |
| 128 | message.data[1] = bbsid->macAddress[2] << 24 \ |
| 129 | | bbsid->macAddress[3] << 16 \ |
| 130 | | bbsid->macAddress[4] << 8 \ |
| 131 | | bbsid->macAddress[5]; \ |
| 132 | } while (0); |
| 133 | |
| 134 | #define FILL_SETFRAMECONTROLDURATIONID(message, portID, frameControlDurationID) \ |
| 135 | do { \ |
| 136 | message.data[0] = (IX_ETHNPE_PC_SETFRAMECONTROLDURATIONID << 24) | (portID << 16); \ |
| 137 | message.data[1] = frameControlDurationID; \ |
| 138 | } while (0); |
| 139 | |
| 140 | #define FILL_SETAPMACTABLE_MSG(message, zone) \ |
| 141 | do { \ |
| 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; \ |
| 146 | } while (0); |
| 147 | |
| 148 | #define FILL_SETFIREWALLMODE_MSG(message, portID, epDelta, mode, address) \ |
| 149 | do { \ |
| 150 | message.data[0] = IX_ETHNPE_FW_SETFIREWALLMODE << 24 \ |
| 151 | | portID << 16 \ |
| 152 | | (epDelta & 0xFF) << 8 \ |
| 153 | | mode; \ |
| 154 | \ |
| 155 | message.data[1] = (UINT32) address; \ |
| 156 | } while (0); |
| 157 | |
| 158 | #define FILL_SETMACADDRESSDATABASE_MSG(message, portID, epDelta, blockCount, address) \ |
| 159 | do { \ |
| 160 | message.data[0] = IX_ETHNPE_EDB_SETMACADDRESSSDATABASE << 24 \ |
| 161 | | (epDelta & 0xFF) << 8 \ |
| 162 | | (blockCount & 0xFF); \ |
| 163 | \ |
| 164 | message.data[1] = (UINT32) address; \ |
| 165 | } while (0); |
| 166 | |
| 167 | #define FILL_GETMACADDRESSDATABASE(message, npeId, zone) \ |
| 168 | do { \ |
| 169 | message.data[0] = IX_ETHNPE_EDB_GETMACADDRESSDATABASE << 24; \ |
| 170 | message.data[1] = (UINT32) zone; \ |
| 171 | } while (0); |
| 172 | |
| 173 | #define FILL_SETMAXFRAMELENGTHS_MSG(message, portID, maxRxFrameSize, maxTxFrameSize) \ |
| 174 | do { \ |
| 175 | message.data[0] = IX_ETHNPE_SETMAXFRAMELENGTHS << 24 \ |
| 176 | | portID << 16 \ |
| 177 | | ((maxRxFrameSize + 63) / 64) << 8 /* max Rx 64-byte blocks */ \ |
| 178 | | (maxTxFrameSize + 63) / 64; /* max Tx 64-byte blocks */ \ |
| 179 | \ |
| 180 | message.data[1] = maxRxFrameSize << 16 | maxTxFrameSize; \ |
| 181 | } while (0); |
| 182 | |
| 183 | #define FILL_SETPORTADDRESS_MSG(message, portID, macAddress) \ |
| 184 | do { \ |
| 185 | message.data[0] = IX_ETHNPE_EDB_SETPORTADDRESS << 24 \ |
| 186 | | portID << 16 \ |
| 187 | | macAddress[0] << 8 \ |
| 188 | | macAddress[1]; \ |
| 189 | \ |
| 190 | message.data[1] = macAddress[2] << 24 \ |
| 191 | | macAddress[3] << 16 \ |
| 192 | | macAddress[4] << 8 \ |
| 193 | | macAddress[5]; \ |
| 194 | } while (0); |
| 195 | |
| 196 | /* access to a MAC node in the NPE tree */ |
| 197 | #define NPE_NODE_BYTE(eltNodeAddr, offset) (((UINT8 *) (eltNodeAddr))[offset]) |
| 198 | |
| 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) |
| 202 | |
| 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) |
| 207 | |
| 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) |
| 215 | |
| 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)) |
| 219 | |
| 220 | /* macros to send messages to the NPEs */ |
| 221 | #define IX_ETHDB_ASYNC_SEND_NPE_MSG(npeId, msg, result) \ |
| 222 | do { \ |
| 223 | result = ixNpeMhMessageSend(npeId, msg, IX_NPEMH_SEND_RETRIES_DEFAULT); \ |
| 224 | \ |
| 225 | if (result != IX_SUCCESS) \ |
| 226 | { \ |
| 227 | ERROR_LOG("DB: Failed to send NPE message\n"); \ |
| 228 | } \ |
| 229 | } while (0); |
| 230 | |
| 231 | #define IX_ETHDB_SYNC_SEND_NPE_MSG(npeId, msg, result) \ |
| 232 | do { \ |
| 233 | result = ixNpeMhMessageWithResponseSend(npeId, msg, msg.data[0] >> 24, ixEthDBNpeMsgAck, IX_NPEMH_SEND_RETRIES_DEFAULT); \ |
| 234 | \ |
| 235 | if (result == IX_SUCCESS) \ |
| 236 | { \ |
| 237 | result = ixOsalMutexLock(&ixEthDBPortInfo[IX_ETH_DB_NPE_TO_PORT_ID(npeId)].npeAckLock, IX_ETH_DB_NPE_TIMEOUT); \ |
| 238 | \ |
| 239 | if (result != IX_SUCCESS) \ |
| 240 | { \ |
| 241 | ERROR_LOG("DB: NPE failed to respond within %dms\n", IX_ETH_DB_NPE_TIMEOUT); \ |
| 242 | } \ |
| 243 | } \ |
| 244 | else \ |
| 245 | { \ |
| 246 | ERROR_LOG("DB: Failed to send NPE message\n"); \ |
| 247 | } \ |
| 248 | } while (0); |
| 249 | |
| 250 | #ifndef IX_NDEBUG |
| 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; |
| 254 | #endif |
| 255 | |
| 256 | #define IX_ETHDB_SEND_NPE_MSG(npeId, msg, result) { LOG_NPE_MSG(msg); IX_ETHDB_SYNC_SEND_NPE_MSG(npeId, msg, result); } |
| 257 | |
| 258 | #endif /* IxEthDBMessages_p_H */ |