4 * @brief Private MAC learning API
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 --
52 #include <IxEthDBPortDefs.h>
54 #include "IxEthDBMessages_p.h"
55 #include "IxEthDBLog_p.h"
57 #if (CPU==SIMSPARCSOLARIS)
59 /* when running unit tests intLock() won't protect the event queue so we lock it manually */
60 #define TEST_FIXTURE_LOCK_EVENT_QUEUE { ixOsalMutexLock(&eventQueueLock, IX_OSAL_WAIT_FOREVER); }
61 #define TEST_FIXTURE_UNLOCK_EVENT_QUEUE { ixOsalMutexUnlock(&eventQueueLock); }
65 #define TEST_FIXTURE_LOCK_EVENT_QUEUE /* nothing */
66 #define TEST_FIXTURE_UNLOCK_EVENT_QUEUE /* nothing */
68 #endif /* #if(CPU==SIMSPARCSOLARIS) */
72 #define TEST_FIXTURE_INCREMENT_DB_CORE_ACCESS_COUNTER /* nothing */
73 #define TEST_FIXTURE_MARK_OVERFLOW_EVENT /* nothing */
77 extern int dbAccessCounter;
78 extern int overflowEvent;
80 #define TEST_FIXTURE_INCREMENT_DB_CORE_ACCESS_COUNTER { dbAccessCounter++; }
81 #define TEST_FIXTURE_MARK_OVERFLOW_EVENT { overflowEvent = 1; }
85 /* code readability markers */
86 #define __mempool__ /* memory pool marker */
87 #define __lock__ /* hash write locking marker */
88 #define __smartpointer__ /* smart pointer marker - warning: use only clone() when duplicating! */
89 #define __alignment__ /* marker for data used only as alignment zones */
92 #define IX_ETH_DB_NPE_TIMEOUT (100) /* NPE response timeout, in ms */
95 * number of hash table buckets
96 * it should be at least 8x the predicted number of entries for performance
97 * each bucket needs 8 bytes
99 #define NUM_BUCKETS (8192)
102 * number of hash table buckets to preload when incrementing bucket iterator
105 #define IX_ETHDB_CACHE_LINE_AHEAD (2)
107 #define IX_ETHDB_BUCKETPTR_AHEAD ((IX_ETHDB_CACHE_LINE_AHEAD * IX_OSAL_CACHE_LINE_SIZE)/sizeof(void *))
109 #define IX_ETHDB_BUCKET_INDEX_MASK (((IX_OSAL_CACHE_LINE_SIZE)/sizeof(void *)) - 1)
112 #define MAX_LOCKS (20) /**< maximum number of locks used simultaneously, do not tamper with */
114 /* learning tree constants */
115 #define INITIAL_ELT_SIZE (8) /**< initial byte size of tree (empty unused root size) */
116 #define MAX_ELT_SIZE (512) /**< maximum number of entries (includes unused root) */
117 #define MAX_GW_SIZE (32) /**< maximum number of gateway entries (including unused root) */
118 #define MAX_FW_SIZE (32) /**< maximum number of firewall entries (including unused root) */
119 #define ELT_ENTRY_SIZE (8) /**< entry size, in bytes */
120 #define ELT_ROOT_OFFSET (ELT_ENTRY_SIZE) /**< tree root offset, in bytes - node preceeding root is unused */
121 #define FULL_ELT_BYTE_SIZE (MAX_ELT_SIZE * ELT_ENTRY_SIZE) /**< full size of tree, in bytes, including unused root */
122 #define FULL_GW_BYTE_SIZE (MAX_GW_SIZE * ELT_ENTRY_SIZE) /**< full size of gateway list, in bytes, including unused root */
123 #define FULL_FW_BYTE_SIZE (MAX_FW_SIZE * ELT_ENTRY_SIZE) /**< full size of firewall table, in bytes, including unused root */
125 /* maximum size of the VLAN table:
126 * 4096 bits (one per VLAN)
128 * interleaved VLAN membership and VLAN TTI (*2) */
129 #define FULL_VLAN_BYTE_SIZE (4096 / 8 * 2)
131 /* upper 9 bits used as set index, lower 3 bits as byte index */
132 #define VLAN_SET_OFFSET(vlanID) ((vlanID) >> 3)
133 #define VLAN_SET_MASK(vlanID) (0x7 - ((vlanID) & 0x7))
135 /* Update zone definitions */
136 #define NPE_TREE_MEM_SIZE (4096) /* ((511 entries + 1 unused root) * 8 bytes/entry) */
138 /* check the above value, we rely on 4k */
139 #if NPE_TREE_MEM_SIZE != 4096
140 #error NPE_TREE_MEM_SIZE is not defined to 4096 bytes!
143 /* Size Filtering limits (Jumbo frame filtering) */
144 #define IX_ETHDB_MAX_FRAME_SIZE 65535 /* other ports than NPE ports */
145 #define IX_ETHDB_MIN_FRAME_SIZE 1 /* other ports than NPE ports */
146 #define IX_ETHDB_MAX_NPE_FRAME_SIZE 16320 /* NPE ports firmware limit */
147 #define IX_ETHDB_MIN_NPE_FRAME_SIZE 1 /* NPE ports firmware limit */
148 #define IX_ETHDB_DEFAULT_FRAME_SIZE 1522
150 /* memory management pool sizes */
155 * NODE_POOL_SIZE controls the maximum number of elements in the database at any one time.
156 * It should be large enough to cover all the search trees of all the ports simultaneously.
158 * MAC_POOL_SIZE should be higher than NODE_POOL_SIZE by at least the total number of MAC addresses
159 * possible to be held at any time in all the ports.
161 * TREE_POOL_SIZE should follow the same guideline as for MAC_POOL_SIZE.
163 * The database structure described here (2000/4000/4000) is enough for two NPEs holding at most 511
164 * entries each plus one PCI NIC holding at most 900 entries.
167 #define NODE_POOL_SIZE (2000) /**< number of HashNode objects - also master number of elements in the database; each entry has 16 bytes */
168 #define MAC_POOL_SIZE (4000) /**< number of MacDescriptor objects; each entry has 28 bytes */
169 #define TREE_POOL_SIZE (4000) /**< number of MacTreeNode objects; each entry has 16 bytes */
172 #define BUSY_RETRY_ENABLED (TRUE) /**< if set to TRUE the API will retry automatically calls returning BUSY */
173 #define FOREVER_RETRY (TRUE) /**< if set to TRUE the API will retry forever BUSY calls */
174 #define MAX_RETRIES (400) /**< upper retry limit - used only when FOREVER_RETRY is FALSE */
175 #define BUSY_RETRY_YIELD (5) /**< ticks to yield for every failed retry */
177 /* event management */
178 #define EVENT_QUEUE_SIZE (500) /**< size of the sink collecting events from the Message Handler FIFO */
179 #define EVENT_PROCESSING_LIMIT (100) /**< batch processing control size (how many events are extracted from the queue at once) */
181 /* MAC descriptors */
182 #define STATIC_ENTRY (TRUE)
183 #define DYNAMIC_ENTRY (FALSE)
185 /* age reset on next maintenance - incrementing by 1 will reset to 0 */
186 #define AGE_RESET (0xFFFFFFFF)
188 /* dependency maps */
189 #define EMPTY_DEPENDENCY_MAP (0)
196 #define MIN(a, b) ((a) < (b) ? (a) : (b))
198 #define IX_ETH_DB_CHECK_PORT_EXISTS(portID) \
200 if ((portID) >= IX_ETH_DB_NUMBER_OF_PORTS) \
202 return IX_ETH_DB_INVALID_PORT; \
206 #define IX_ETH_DB_CHECK_PORT_INITIALIZED(portID) \
208 if ((portID) >= IX_ETH_DB_NUMBER_OF_PORTS) \
210 return IX_ETH_DB_INVALID_PORT; \
214 if (!ixEthDBPortInfo[portID].initialized) \
216 return IX_ETH_DB_PORT_UNINITIALIZED; \
221 /* single NPE check */
222 #define IX_ETH_DB_CHECK_SINGLE_NPE(portID) \
223 if (ixEthDBSingleEthNpeCheck(portID) != IX_ETH_DB_SUCCESS) \
225 WARNING_LOG("EthDB: port ID %d is unavailable\n",(UINT32) portID); \
227 return IX_ETH_DB_INVALID_PORT; \
231 #define IX_ETH_DB_CHECK_FEATURE(portID, feature) \
232 if ((ixEthDBPortInfo[portID].featureStatus & feature) == 0) \
234 return IX_ETH_DB_FEATURE_UNAVAILABLE; \
238 #define BUSY_RETRY(functionCall) \
240 UINT32 retries = 0; \
241 IxEthDBStatus br_result; \
243 while ((br_result = functionCall) == IX_ETH_DB_BUSY \
244 && BUSY_RETRY_ENABLED && (FOREVER_RETRY || ++retries < MAX_RETRIES)) { ixOsalSleep(BUSY_RETRY_YIELD); }; \
246 if ((!FOREVER_RETRY && retries == MAX_RETRIES) || (br_result == IX_ETH_DB_FAIL)) \
248 ERROR_LOG("Ethernet Learning Database Error: BUSY_RETRY failed at %s:%d\n", __FILE__, __LINE__); \
252 #define BUSY_RETRY_WITH_RESULT(functionCall, brwr_result) \
254 UINT32 retries = 0; \
256 while ((brwr_result = functionCall) == IX_ETH_DB_BUSY \
257 && BUSY_RETRY_ENABLED && (FOREVER_RETRY || ++retries < MAX_RETRIES)) { ixOsalSleep(BUSY_RETRY_YIELD); }; \
259 if ((!FOREVER_RETRY && retries == MAX_RETRIES) || (brwr_result == IX_ETH_DB_FAIL)) \
261 ERROR_LOG("Ethernet Learning Database Error: BUSY_RETRY_WITH_RESULT failed at %s:%d\n", __FILE__, __LINE__); \
266 #define IS_ITERATOR_VALID(iteratorPtr) ((iteratorPtr)->node != NULL)
268 /* dependency port maps */
270 /* Warning: if port indexing starts from 1 replace (portID) with (portID - 1) in DEPENDENCY_MAP (and make sure IX_ETH_DB_NUMBER_OF_PORTS is big enough) */
272 /* gives an empty dependency map */
273 #define SET_EMPTY_DEPENDENCY_MAP(map) { int i = 0; for (; i < 32 ; i++) map[i] = 0; }
275 #define IS_EMPTY_DEPENDENCY_MAP(result, map) { int i = 0 ; result = TRUE; for (; i < 32 ; i++) if (map[i] != 0) { result = FALSE; break; }}
278 * gives a map consisting only of 'portID'
280 #define SET_DEPENDENCY_MAP(map, portID) {SET_EMPTY_DEPENDENCY_MAP(map); map[portID >> 3] = 1 << (portID & 0x7);}
283 * gives a map resulting from joining map1 and map2
285 #define JOIN_MAPS(map, map1, map2) { int i = 0; for (; i < 32 ; i++) map[i] = map1[i] | map2[i]; }
288 * gives the map resulting from joining portID and map
290 #define JOIN_PORT_TO_MAP(map, portID) { map[portID >> 3] |= 1 << (portID & 0x7); }
293 * gives the map resulting from excluding portID from map
295 #define EXCLUDE_PORT_FROM_MAP(map, portID) { map[portID >> 3] &= ~(1 << (portID & 0x7); }
298 * returns TRUE if map1 is a subset of map2 and FALSE otherwise
300 #define IS_MAP_SUBSET(result, map1, map2) { int i = 0; result = TRUE; for (; i < 32 ; i++) if ((map1[i] | map2[i]) != map2[i]) result = FALSE; }
303 * returns TRUE is portID is part of map and FALSE otherwise
305 #define IS_PORT_INCLUDED(portID, map) ((map[portID >> 3] & (1 << (portID & 0x7))) != 0)
308 * returns the difference between map1 and map2 (ports included in map1 and not included in map2)
310 #define DIFF_MAPS(map, map1, map2) { int i = 0; for (; i < 32 ; i++) map[i] = map1[i] ^ (map1[i] & map2[i]); }
313 * returns TRUE if the maps collide (have at least one port in common) and FALSE otherwise
315 #define MAPS_COLLIDE(result, map1, map2) { int i = 0; result = FALSE; for (; i < 32 ; i++) if ((map1[i] & map2[i]) != 0) result = TRUE; }
317 /* size (number of ports) of a dependency map */
318 #define GET_MAP_SIZE(map, size) { int i = 0, b = 0; size = 0; for (; i < 32 ; i++) { char y = map[i]; for (; b < 8 && (y >>= 1); b++) size += (y & 1); }}
320 /* copy map2 into map1 */
321 #define COPY_DEPENDENCY_MAP(map1, map2) { memcpy (map1, map2, sizeof (map1)); }
323 /* definition of a port map size/port number which cannot be reached (we support at most 32 ports) */
324 #define MAX_PORT_SIZE (0xFF)
325 #define MAX_PORT_NUMBER (0xFF)
327 #define IX_ETH_DB_CHECK_REFERENCE(ptr) { if ((ptr) == NULL) { return IX_ETH_DB_INVALID_ARG; } }
328 #define IX_ETH_DB_CHECK_MAP(portID, map) { if (!IS_PORT_INCLUDED(portID, map)) { return IX_ETH_DB_INVALID_ARG; } }
330 /* event queue macros */
331 #define EVENT_QUEUE_WRAP(offset) ((offset) >= EVENT_QUEUE_SIZE ? (offset) - EVENT_QUEUE_SIZE : (offset))
333 #define CAN_ENQUEUE(eventQueuePtr) ((eventQueuePtr)->length < EVENT_QUEUE_SIZE)
335 #define QUEUE_HEAD(eventQueuePtr) (&(eventQueuePtr)->queue[EVENT_QUEUE_WRAP((eventQueuePtr)->base + (eventQueuePtr)->length)])
337 #define QUEUE_TAIL(eventQueuePtr) (&(eventQueuePtr)->queue[(eventQueuePtr)->base])
339 #define PUSH_UPDATE_QUEUE(eventQueuePtr) { (eventQueuePtr)->length++; }
341 #define SHIFT_UPDATE_QUEUE(eventQueuePtr) \
343 (eventQueuePtr)->base = EVENT_QUEUE_WRAP((eventQueuePtr)->base + 1); \
344 (eventQueuePtr)->length--; \
347 #define RESET_QUEUE(eventQueuePtr) \
349 (eventQueuePtr)->base = 0; \
350 (eventQueuePtr)->length = 0; \
353 /* node stack macros - used to browse a tree without using a recursive function */
354 #define NODE_STACK_INIT(stack) { (stack)->nodeCount = 0; }
355 #define NODE_STACK_PUSH(stack, node, offset) { (stack)->nodes[(stack)->nodeCount] = (node); (stack)->offsets[(stack)->nodeCount++] = (offset); }
356 #define NODE_STACK_POP(stack, node, offset) { (node) = (stack)->nodes[--(stack)->nodeCount]; offset = (stack)->offsets[(stack)->nodeCount]; }
357 #define NODE_STACK_NONEMPTY(stack) ((stack)->nodeCount != 0)
360 #define IX_ETH_DB_NPE_MSG_HISTORY_DEPTH (100)
361 #define LOG_NPE_MSG(msg) \
363 UINT32 npeMsgHistoryIndex = (npeMsgHistoryLen++) % IX_ETH_DB_NPE_MSG_HISTORY_DEPTH; \
364 npeMsgHistory[npeMsgHistoryIndex][0] = msg.data[0]; \
365 npeMsgHistory[npeMsgHistoryIndex][1] = msg.data[1]; \
368 #define LOG_NPE_MSG() /* nothing */
371 /* ----------- Data -------------- */
375 typedef UINT32 (*HashFunction)(void *entity);
376 typedef BOOL (*MatchFunction)(void *reference, void *entry);
377 typedef void (*FreeFunction)(void *entry);
380 * basic component of a hash table
382 typedef struct HashNode_t
384 void *data; /**< specific data */
385 struct HashNode_t *next; /**< used for bucket chaining */
387 __mempool__ struct HashNode_t *nextFree; /**< memory pool management */
389 __lock__ IxOsalFastMutex lock; /**< node lock */
393 * @brief hash table iterator definition
395 * an iterator is an object which can be used
396 * to browse a hash table
400 UINT32 bucketIndex; /**< index of the currently iterated bucket */
401 HashNode *previousNode; /**< reference to the previously iterated node within the current bucket */
402 HashNode *node; /**< reference to the currently iterated node */
406 * definition of a MAC descriptor (a database record)
411 IX_ETH_DB_WIFI_AP_TO_STA = 0x0,
412 IX_ETH_DB_WIFI_AP_TO_AP = 0x1
413 } IxEthDBWiFiRecordType;
420 BOOL staticEntry; /**< TRUE if this address is static (doesn't age) */
427 UINT32 ieee802_1qTag;
432 IxEthDBWiFiRecordType type; /**< AP_TO_AP (0x1) or AP_TO_STA (0x0) */
433 UINT32 gwAddressIndex; /**< used only when linearizing the entries for NPE usage */
434 UINT8 gwMacAddress[IX_IEEE803_MAC_ADDRESS_SIZE];
436 __alignment__ UINT8 reserved2[2];
440 typedef struct MacDescriptor_t
442 UINT8 macAddress[IX_IEEE803_MAC_ADDRESS_SIZE];
444 __alignment__ UINT8 reserved1[2];
447 IxEthDBRecordType type;
448 IxEthDBRecordData recordData;
450 /* used for internal operations, such as NPE linearization */
453 /* custom user data */
456 __mempool__ struct MacDescriptor_t *nextFree; /**< memory pool management */
457 __smartpointer__ UINT32 refCount; /**< smart pointer reference counter */
461 * hash table definition
465 HashNode *hashBuckets[NUM_BUCKETS];
468 __lock__ IxOsalFastMutex bucketLocks[NUM_BUCKETS];
470 HashFunction entryHashFunction;
471 MatchFunction *matchFunctions;
472 FreeFunction freeFunction;
477 IX_ETH_DB_MAC_KEY = 1,
478 IX_ETH_DB_MAC_PORT_KEY = 2,
479 IX_ETH_DB_MAC_VLAN_KEY = 3,
480 IX_ETH_DB_MAX_KEY_INDEX = 3
481 } IxEthDBSearchKeyType;
483 typedef struct MacTreeNode_t
485 __smartpointer__ MacDescriptor *descriptor;
486 struct MacTreeNode_t *left, *right;
488 __mempool__ struct MacTreeNode_t *nextFree;
491 typedef IxEthDBStatus (*IxEthDBPortUpdateHandler)(IxEthDBPortId portID, IxEthDBRecordType type);
493 typedef void (*IxEthDBNoteWriteFn)(void *address, MacTreeNode *node);
497 BOOL updateEnabled; /**< TRUE if updates are enabled for port */
498 BOOL userControlled; /**< TRUE if the user has manually used ixEthDBPortUpdateEnableSet */
499 BOOL treeInitialized; /**< TRUE if the NPE has received an initial tree */
500 IxEthDBPortUpdateHandler updateHandler; /**< port update handler routine */
501 void *npeUpdateZone; /**< port update memory zone */
502 void *npeGwUpdateZone; /**< port update memory zone for gateways */
503 void *vlanUpdateZone; /**< port update memory zone for VLAN tables */
504 MacTreeNode *searchTree; /**< internal search tree, in MacTreeNode representation */
505 BOOL searchTreePendingWrite; /**< TRUE if searchTree holds a tree pending write to the port */
510 IxEthDBPortId portID; /**< port ID */
511 BOOL enabled; /**< TRUE if the port is enabled */
512 BOOL agingEnabled; /**< TRUE if aging on this port is enabled */
514 IxEthDBPortMap dependencyPortMap; /**< dependency port map for this port */
515 PortUpdateMethod updateMethod; /**< update method structure */
516 BOOL macAddressUploaded; /**< TRUE if the MAC address was uploaded into the port */
517 UINT32 maxRxFrameSize; /**< maximum Rx frame size for this port */
518 UINT32 maxTxFrameSize; /**< maximum Rx frame size for this port */
521 __alignment__ UINT8 reserved[2];
522 UINT32 frameControlDurationID; /**< Frame Control - Duration/ID WiFi control */
524 IxEthDBVlanTag vlanTag; /**< default VLAN tag for port */
525 IxEthDBPriorityTable priorityTable; /**< QoS <=> internal priority mapping */
526 IxEthDBVlanSet vlanMembership;
527 IxEthDBVlanSet transmitTaggingInfo;
528 IxEthDBFrameFilter frameFilter;
529 IxEthDBTaggingAction taggingAction;
531 UINT32 npeFrameFilter;
532 UINT32 npeTaggingAction;
534 IxEthDBFirewallMode firewallMode;
535 BOOL srcAddressFilterEnabled;
539 IxEthDBFeature featureCapability;
540 IxEthDBFeature featureStatus;
542 UINT32 ixEthDBTrafficClassAQMAssignments[IX_IEEE802_1Q_QOS_PRIORITY_COUNT];
544 UINT32 ixEthDBTrafficClassCount;
546 UINT32 ixEthDBTrafficClassAvailable;
550 __lock__ IxOsalMutex npeAckLock;
553 /* list of port information structures indexed on port Ids */
554 extern IX_ETH_DB_PUBLIC PortInfo ixEthDBPortInfo[IX_ETH_DB_NUMBER_OF_PORTS];
558 IX_ETH_DB_ADD_FILTERING_RECORD = 0xFF0001,
559 IX_ETH_DB_REMOVE_FILTERING_RECORD = 0xFF0002
565 IxEthDBPortId portID;
566 IxEthDBMacAddr macAddr;
572 PortEvent queue[EVENT_QUEUE_SIZE];
579 IxEthDBPortId portID; /**< originating port */
580 MacDescriptor *macDescriptors[MAX_ELT_SIZE]; /**< addresses to be synced into db */
581 UINT32 addressCount; /**< number of addresses */
586 MacTreeNode *nodes[MAX_ELT_SIZE];
587 UINT32 offsets[MAX_ELT_SIZE];
593 /* ----------- Memory management -------------- */
595 IX_ETH_DB_PUBLIC void ixEthDBInitMemoryPools(void);
597 IX_ETH_DB_PUBLIC HashNode* ixEthDBAllocHashNode(void);
598 IX_ETH_DB_PUBLIC void ixEthDBFreeHashNode(HashNode *);
600 IX_ETH_DB_PUBLIC __smartpointer__ MacDescriptor* ixEthDBAllocMacDescriptor(void);
601 IX_ETH_DB_PUBLIC __smartpointer__ MacDescriptor* ixEthDBCloneMacDescriptor(MacDescriptor *macDescriptor);
602 IX_ETH_DB_PUBLIC __smartpointer__ void ixEthDBFreeMacDescriptor(MacDescriptor *);
604 IX_ETH_DB_PUBLIC __smartpointer__ MacTreeNode* ixEthDBAllocMacTreeNode(void);
605 IX_ETH_DB_PUBLIC __smartpointer__ MacTreeNode* ixEthDBCloneMacTreeNode(MacTreeNode *);
606 IX_ETH_DB_PUBLIC __smartpointer__ void ixEthDBFreeMacTreeNode(MacTreeNode *);
608 IX_ETH_DB_PUBLIC void ixEthDBPoolFreeMacTreeNode(MacTreeNode *);
609 IX_ETH_DB_PUBLIC UINT32 ixEthDBSearchTreeUsageGet(MacTreeNode *tree);
610 IX_ETH_DB_PUBLIC int ixEthDBShowMemoryStatus(void);
613 IX_ETH_DB_PUBLIC void ixEthDBInitHash(HashTable *hashTable, UINT32 numBuckets, HashFunction entryHashFunction, MatchFunction *matchFunctions, FreeFunction freeFunction);
615 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBAddHashEntry(HashTable *hashTable, void *entry);
616 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBRemoveHashEntry(HashTable *hashTable, int keyType, void *reference);
617 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBSearchHashEntry(HashTable *hashTable, int keyType, void *reference, HashNode **searchResult);
618 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPeekHashEntry(HashTable *hashTable, int keyType, void *reference);
619 IX_ETH_DB_PUBLIC void ixEthDBReleaseHashNode(HashNode *node);
621 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBInitHashIterator(HashTable *hashTable, HashIterator *iterator);
622 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBIncrementHashIterator(HashTable *hashTable, HashIterator *iterator);
623 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBRemoveEntryAtHashIterator(HashTable *hashTable, HashIterator *iterator);
624 IX_ETH_DB_PUBLIC void ixEthDBReleaseHashIterator(HashIterator *iterator);
627 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPortAddressSet(IxEthDBPortId portID, IxEthDBMacAddr *macAddr);
628 IX_ETH_DB_PUBLIC void ixEthDBMaximumFrameSizeAckCallback(IxNpeMhNpeId npeID, IxNpeMhMessage msg);
630 /* DB Core functions */
631 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBInit(void);
632 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBAdd(MacDescriptor *newRecordTemplate, IxEthDBPortMap updateTrigger);
633 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBRemove(MacDescriptor *templateRecord, IxEthDBPortMap updateTrigger);
634 IX_ETH_DB_PUBLIC HashNode* ixEthDBSearch(IxEthDBMacAddr *macAddress, IxEthDBRecordType typeFilter);
635 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPeek(IxEthDBMacAddr *macAddress, IxEthDBRecordType typeFilter);
637 /* Learning support */
638 IX_ETH_DB_PUBLIC UINT32 ixEthDBAddressCompare(UINT8 *mac1, UINT8 *mac2);
639 IX_ETH_DB_PUBLIC BOOL ixEthDBAddressMatch(void *reference, void *entry);
640 IX_ETH_DB_PUBLIC UINT32 ixEthDBEntryXORHash(void *macDescriptor);
641 IX_ETH_DB_PUBLIC UINT32 ixEthDBKeyXORHash(void *macAddress);
644 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBNPEUpdateHandler(IxEthDBPortId portID, IxEthDBRecordType type);
645 IX_ETH_DB_PUBLIC void ixEthDBUpdatePortLearningTrees(IxEthDBPortMap triggerPorts);
646 IX_ETH_DB_PUBLIC void ixEthDBNPEAccessRequest(IxEthDBPortId portID);
647 IX_ETH_DB_PUBLIC void ixEthDBUpdateLock(void);
648 IX_ETH_DB_PUBLIC void ixEthDBUpdateUnlock(void);
649 IX_ETH_DB_PUBLIC MacTreeNode* ixEthDBQuery(MacTreeNode *searchTree, IxEthDBPortMap query, IxEthDBRecordType recordFilter, UINT32 maximumEntries);
650 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFirewallUpdate(IxEthDBPortId portID, void *address, UINT32 epDelta);
653 IX_ETH_DB_PUBLIC void ixEthDBPortSetAckCallback(IxNpeMhNpeId npeID, IxNpeMhMessage msg);
654 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBEventProcessorInit(void);
655 IX_ETH_DB_PUBLIC void ixEthDBPortInit(IxEthDBPortId portID);
656 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPortEnable(IxEthDBPortId portID);
657 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPortDisable(IxEthDBPortId portID);
658 IX_ETH_DB_PUBLIC void ixEthDBNPEUpdateAreasInit(void);
659 IX_ETH_DB_PUBLIC UINT32 ixEthDBMatchMethodsRegister(MatchFunction *matchFunctions);
660 IX_ETH_DB_PUBLIC UINT32 ixEthDBRecordSerializeMethodsRegister(void);
661 IX_ETH_DB_PUBLIC UINT32 ixEthDBUpdateTypeRegister(BOOL *typeArray);
662 IX_ETH_DB_PUBLIC void ixEthDBNPEUpdateAreasUnload(void);
663 IX_ETH_DB_PUBLIC void ixEthDBFeatureCapabilityScan(void);
664 IX_ETH_DB_PUBLIC UINT32 ixEthDBKeyTypeRegister(UINT32 *keyType);
666 /* Event processing */
667 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBDefaultEventCallbackEnable(IxEthDBPortId portID, BOOL enable);
668 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBTriggerAddPortUpdate(IxEthDBMacAddr *macAddr, IxEthDBPortId portID, BOOL staticEntry);
669 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBTriggerRemovePortUpdate(IxEthDBMacAddr *macAddr, IxEthDBPortId portID);
670 IX_ETH_DB_PUBLIC void ixEthDBNPEEventCallback(IxNpeMhNpeId npeID, IxNpeMhMessage msg);
673 IX_ETH_DB_PUBLIC void ixEthDBGetMacDatabaseCbk(IxNpeMhNpeId npeID, IxNpeMhMessage msg);
674 IX_ETH_DB_PUBLIC void ixEthDBNpeMsgAck(IxNpeMhNpeId npeID, IxNpeMhMessage msg);
675 IX_ETH_DB_PUBLIC void ixEthDBNPESyncScan(IxEthDBPortId portID, void *eltBaseAddress, UINT32 eltSize);
676 IX_ETH_DB_PUBLIC void ixEthDBNPETreeWrite(IxEthDBRecordType type, UINT32 totalSize, void *baseAddress, MacTreeNode *tree, UINT32 *blocks, UINT32 *startIndex);
677 IX_ETH_DB_PUBLIC void ixEthDBNPEGatewayNodeWrite(void *address, MacTreeNode *node);
679 /* Other public API functions */
680 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBStartLearningFunction(void);
681 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBStopLearningFunction(void);
682 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPortUpdateEnableSet(IxEthDBPortId portID, BOOL enableUpdate);
684 /* Maximum Tx/Rx public functions */
685 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFilteringPortMaximumRxFrameSizeSet(IxEthDBPortId portID, UINT32 maximumRxFrameSize);
686 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFilteringPortMaximumTxFrameSizeSet(IxEthDBPortId portID, UINT32 maximumTxFrameSize);
689 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPortVlanTableSet(IxEthDBPortId portID, IxEthDBVlanSet portVlanTable, IxEthDBVlanSet vlanSet);
692 IX_ETH_DB_PUBLIC BOOL ixEthDBAddressRecordMatch(void *untypedReference, void *untypedEntry);
693 IX_ETH_DB_PUBLIC BOOL ixEthDBVlanRecordMatch(void *untypedReference, void *untypedEntry);
694 IX_ETH_DB_PUBLIC BOOL ixEthDBPortRecordMatch(void *untypedReference, void *untypedEntry);
695 IX_ETH_DB_PUBLIC BOOL ixEthDBNullMatch(void *reference, void *entry);
696 IX_ETH_DB_PUBLIC HashNode* ixEthDBPortSearch(IxEthDBMacAddr *macAddress, IxEthDBPortId portID, IxEthDBRecordType typeFilter);
697 IX_ETH_DB_PUBLIC HashNode* ixEthDBVlanSearch(IxEthDBMacAddr *macAddress, IxEthDBVlanId vlanID, IxEthDBRecordType typeFilter);
700 IX_ETH_DB_PUBLIC const char* mac2string(const unsigned char *mac);
701 IX_ETH_DB_PUBLIC void showHashInfo(void);
702 IX_ETH_DB_PUBLIC int ixEthDBAnalyzeHash(void);
703 IX_ETH_DB_PUBLIC const char* errorString(IxEthDBStatus error);
704 IX_ETH_DB_PUBLIC int numHashElements(void);
705 IX_ETH_DB_PUBLIC void zapHashtable(void);
706 IX_ETH_DB_PUBLIC BOOL ixEthDBCheckSingleBitValue(UINT32 value);
708 /* Single Eth NPE Check */
709 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBSingleEthNpeCheck(IxEthDBPortId portId);
711 #endif /* IxEthDB_p_H */