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 * SPDX-License-Identifier: BSD-3-Clause
18 * -- End of Copyright Notice --
28 #include <IxEthDBPortDefs.h>
30 #include "IxEthDBMessages_p.h"
31 #include "IxEthDBLog_p.h"
33 #if (CPU==SIMSPARCSOLARIS)
35 /* when running unit tests intLock() won't protect the event queue so we lock it manually */
36 #define TEST_FIXTURE_LOCK_EVENT_QUEUE { ixOsalMutexLock(&eventQueueLock, IX_OSAL_WAIT_FOREVER); }
37 #define TEST_FIXTURE_UNLOCK_EVENT_QUEUE { ixOsalMutexUnlock(&eventQueueLock); }
41 #define TEST_FIXTURE_LOCK_EVENT_QUEUE /* nothing */
42 #define TEST_FIXTURE_UNLOCK_EVENT_QUEUE /* nothing */
44 #endif /* #if(CPU==SIMSPARCSOLARIS) */
48 #define TEST_FIXTURE_INCREMENT_DB_CORE_ACCESS_COUNTER /* nothing */
49 #define TEST_FIXTURE_MARK_OVERFLOW_EVENT /* nothing */
53 extern int dbAccessCounter;
54 extern int overflowEvent;
56 #define TEST_FIXTURE_INCREMENT_DB_CORE_ACCESS_COUNTER { dbAccessCounter++; }
57 #define TEST_FIXTURE_MARK_OVERFLOW_EVENT { overflowEvent = 1; }
61 /* code readability markers */
62 #define __mempool__ /* memory pool marker */
63 #define __lock__ /* hash write locking marker */
64 #define __smartpointer__ /* smart pointer marker - warning: use only clone() when duplicating! */
65 #define __alignment__ /* marker for data used only as alignment zones */
68 #define IX_ETH_DB_NPE_TIMEOUT (100) /* NPE response timeout, in ms */
71 * number of hash table buckets
72 * it should be at least 8x the predicted number of entries for performance
73 * each bucket needs 8 bytes
75 #define NUM_BUCKETS (8192)
78 * number of hash table buckets to preload when incrementing bucket iterator
81 #define IX_ETHDB_CACHE_LINE_AHEAD (2)
83 #define IX_ETHDB_BUCKETPTR_AHEAD ((IX_ETHDB_CACHE_LINE_AHEAD * IX_OSAL_CACHE_LINE_SIZE)/sizeof(void *))
85 #define IX_ETHDB_BUCKET_INDEX_MASK (((IX_OSAL_CACHE_LINE_SIZE)/sizeof(void *)) - 1)
88 #define MAX_LOCKS (20) /**< maximum number of locks used simultaneously, do not tamper with */
90 /* learning tree constants */
91 #define INITIAL_ELT_SIZE (8) /**< initial byte size of tree (empty unused root size) */
92 #define MAX_ELT_SIZE (512) /**< maximum number of entries (includes unused root) */
93 #define MAX_GW_SIZE (32) /**< maximum number of gateway entries (including unused root) */
94 #define MAX_FW_SIZE (32) /**< maximum number of firewall entries (including unused root) */
95 #define ELT_ENTRY_SIZE (8) /**< entry size, in bytes */
96 #define ELT_ROOT_OFFSET (ELT_ENTRY_SIZE) /**< tree root offset, in bytes - node preceeding root is unused */
97 #define FULL_ELT_BYTE_SIZE (MAX_ELT_SIZE * ELT_ENTRY_SIZE) /**< full size of tree, in bytes, including unused root */
98 #define FULL_GW_BYTE_SIZE (MAX_GW_SIZE * ELT_ENTRY_SIZE) /**< full size of gateway list, in bytes, including unused root */
99 #define FULL_FW_BYTE_SIZE (MAX_FW_SIZE * ELT_ENTRY_SIZE) /**< full size of firewall table, in bytes, including unused root */
101 /* maximum size of the VLAN table:
102 * 4096 bits (one per VLAN)
104 * interleaved VLAN membership and VLAN TTI (*2) */
105 #define FULL_VLAN_BYTE_SIZE (4096 / 8 * 2)
107 /* upper 9 bits used as set index, lower 3 bits as byte index */
108 #define VLAN_SET_OFFSET(vlanID) ((vlanID) >> 3)
109 #define VLAN_SET_MASK(vlanID) (0x7 - ((vlanID) & 0x7))
111 /* Update zone definitions */
112 #define NPE_TREE_MEM_SIZE (4096) /* ((511 entries + 1 unused root) * 8 bytes/entry) */
114 /* check the above value, we rely on 4k */
115 #if NPE_TREE_MEM_SIZE != 4096
116 #error NPE_TREE_MEM_SIZE is not defined to 4096 bytes!
119 /* Size Filtering limits (Jumbo frame filtering) */
120 #define IX_ETHDB_MAX_FRAME_SIZE 65535 /* other ports than NPE ports */
121 #define IX_ETHDB_MIN_FRAME_SIZE 1 /* other ports than NPE ports */
122 #define IX_ETHDB_MAX_NPE_FRAME_SIZE 16320 /* NPE ports firmware limit */
123 #define IX_ETHDB_MIN_NPE_FRAME_SIZE 1 /* NPE ports firmware limit */
124 #define IX_ETHDB_DEFAULT_FRAME_SIZE 1522
126 /* memory management pool sizes */
131 * NODE_POOL_SIZE controls the maximum number of elements in the database at any one time.
132 * It should be large enough to cover all the search trees of all the ports simultaneously.
134 * MAC_POOL_SIZE should be higher than NODE_POOL_SIZE by at least the total number of MAC addresses
135 * possible to be held at any time in all the ports.
137 * TREE_POOL_SIZE should follow the same guideline as for MAC_POOL_SIZE.
139 * The database structure described here (2000/4000/4000) is enough for two NPEs holding at most 511
140 * entries each plus one PCI NIC holding at most 900 entries.
143 #define NODE_POOL_SIZE (2000) /**< number of HashNode objects - also master number of elements in the database; each entry has 16 bytes */
144 #define MAC_POOL_SIZE (4000) /**< number of MacDescriptor objects; each entry has 28 bytes */
145 #define TREE_POOL_SIZE (4000) /**< number of MacTreeNode objects; each entry has 16 bytes */
148 #define BUSY_RETRY_ENABLED (true) /**< if set to true the API will retry automatically calls returning BUSY */
149 #define FOREVER_RETRY (true) /**< if set to true the API will retry forever BUSY calls */
150 #define MAX_RETRIES (400) /**< upper retry limit - used only when FOREVER_RETRY is false */
151 #define BUSY_RETRY_YIELD (5) /**< ticks to yield for every failed retry */
153 /* event management */
154 #define EVENT_QUEUE_SIZE (500) /**< size of the sink collecting events from the Message Handler FIFO */
155 #define EVENT_PROCESSING_LIMIT (100) /**< batch processing control size (how many events are extracted from the queue at once) */
157 /* MAC descriptors */
158 #define STATIC_ENTRY (true)
159 #define DYNAMIC_ENTRY (false)
161 /* age reset on next maintenance - incrementing by 1 will reset to 0 */
162 #define AGE_RESET (0xFFFFFFFF)
164 /* dependency maps */
165 #define EMPTY_DEPENDENCY_MAP (0)
172 #define IX_ETH_DB_CHECK_PORT_EXISTS(portID) \
174 if ((portID) >= IX_ETH_DB_NUMBER_OF_PORTS) \
176 return IX_ETH_DB_INVALID_PORT; \
180 #define IX_ETH_DB_CHECK_PORT_INITIALIZED(portID) \
182 if ((portID) >= IX_ETH_DB_NUMBER_OF_PORTS) \
184 return IX_ETH_DB_INVALID_PORT; \
188 if (!ixEthDBPortInfo[portID].initialized) \
190 return IX_ETH_DB_PORT_UNINITIALIZED; \
195 /* single NPE check */
196 #define IX_ETH_DB_CHECK_SINGLE_NPE(portID) \
197 if (ixEthDBSingleEthNpeCheck(portID) != IX_ETH_DB_SUCCESS) \
199 WARNING_LOG("EthDB: port ID %d is unavailable\n",(UINT32) portID); \
201 return IX_ETH_DB_INVALID_PORT; \
205 #define IX_ETH_DB_CHECK_FEATURE(portID, feature) \
206 if ((ixEthDBPortInfo[portID].featureStatus & feature) == 0) \
208 return IX_ETH_DB_FEATURE_UNAVAILABLE; \
212 #define BUSY_RETRY(functionCall) \
214 UINT32 retries = 0; \
215 IxEthDBStatus br_result; \
217 while ((br_result = functionCall) == IX_ETH_DB_BUSY \
218 && BUSY_RETRY_ENABLED && (FOREVER_RETRY || ++retries < MAX_RETRIES)) { ixOsalSleep(BUSY_RETRY_YIELD); }; \
220 if ((!FOREVER_RETRY && retries == MAX_RETRIES) || (br_result == IX_ETH_DB_FAIL)) \
222 ERROR_LOG("Ethernet Learning Database Error: BUSY_RETRY failed at %s:%d\n", __FILE__, __LINE__); \
226 #define BUSY_RETRY_WITH_RESULT(functionCall, brwr_result) \
228 UINT32 retries = 0; \
230 while ((brwr_result = functionCall) == IX_ETH_DB_BUSY \
231 && BUSY_RETRY_ENABLED && (FOREVER_RETRY || ++retries < MAX_RETRIES)) { ixOsalSleep(BUSY_RETRY_YIELD); }; \
233 if ((!FOREVER_RETRY && retries == MAX_RETRIES) || (brwr_result == IX_ETH_DB_FAIL)) \
235 ERROR_LOG("Ethernet Learning Database Error: BUSY_RETRY_WITH_RESULT failed at %s:%d\n", __FILE__, __LINE__); \
240 #define IS_ITERATOR_VALID(iteratorPtr) ((iteratorPtr)->node != NULL)
242 /* dependency port maps */
244 /* 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) */
246 /* gives an empty dependency map */
247 #define SET_EMPTY_DEPENDENCY_MAP(map) { int i = 0; for (; i < 32 ; i++) map[i] = 0; }
249 #define IS_EMPTY_DEPENDENCY_MAP(result, map) { int i = 0 ; result = true; for (; i < 32 ; i++) if (map[i] != 0) { result = false; break; }}
252 * gives a map consisting only of 'portID'
254 #define SET_DEPENDENCY_MAP(map, portID) {SET_EMPTY_DEPENDENCY_MAP(map); map[portID >> 3] = 1 << (portID & 0x7);}
257 * gives a map resulting from joining map1 and map2
259 #define JOIN_MAPS(map, map1, map2) { int i = 0; for (; i < 32 ; i++) map[i] = map1[i] | map2[i]; }
262 * gives the map resulting from joining portID and map
264 #define JOIN_PORT_TO_MAP(map, portID) { map[portID >> 3] |= 1 << (portID & 0x7); }
267 * gives the map resulting from excluding portID from map
269 #define EXCLUDE_PORT_FROM_MAP(map, portID) { map[portID >> 3] &= ~(1 << (portID & 0x7); }
272 * returns true if map1 is a subset of map2 and false otherwise
274 #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; }
277 * returns true is portID is part of map and false otherwise
279 #define IS_PORT_INCLUDED(portID, map) ((map[portID >> 3] & (1 << (portID & 0x7))) != 0)
282 * returns the difference between map1 and map2 (ports included in map1 and not included in map2)
284 #define DIFF_MAPS(map, map1, map2) { int i = 0; for (; i < 32 ; i++) map[i] = map1[i] ^ (map1[i] & map2[i]); }
287 * returns true if the maps collide (have at least one port in common) and false otherwise
289 #define MAPS_COLLIDE(result, map1, map2) { int i = 0; result = false; for (; i < 32 ; i++) if ((map1[i] & map2[i]) != 0) result = true; }
291 /* size (number of ports) of a dependency map */
292 #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); }}
294 /* copy map2 into map1 */
295 #define COPY_DEPENDENCY_MAP(map1, map2) { memcpy (map1, map2, sizeof (map1)); }
297 /* definition of a port map size/port number which cannot be reached (we support at most 32 ports) */
298 #define MAX_PORT_SIZE (0xFF)
299 #define MAX_PORT_NUMBER (0xFF)
301 #define IX_ETH_DB_CHECK_REFERENCE(ptr) { if ((ptr) == NULL) { return IX_ETH_DB_INVALID_ARG; } }
302 #define IX_ETH_DB_CHECK_MAP(portID, map) { if (!IS_PORT_INCLUDED(portID, map)) { return IX_ETH_DB_INVALID_ARG; } }
304 /* event queue macros */
305 #define EVENT_QUEUE_WRAP(offset) ((offset) >= EVENT_QUEUE_SIZE ? (offset) - EVENT_QUEUE_SIZE : (offset))
307 #define CAN_ENQUEUE(eventQueuePtr) ((eventQueuePtr)->length < EVENT_QUEUE_SIZE)
309 #define QUEUE_HEAD(eventQueuePtr) (&(eventQueuePtr)->queue[EVENT_QUEUE_WRAP((eventQueuePtr)->base + (eventQueuePtr)->length)])
311 #define QUEUE_TAIL(eventQueuePtr) (&(eventQueuePtr)->queue[(eventQueuePtr)->base])
313 #define PUSH_UPDATE_QUEUE(eventQueuePtr) { (eventQueuePtr)->length++; }
315 #define SHIFT_UPDATE_QUEUE(eventQueuePtr) \
317 (eventQueuePtr)->base = EVENT_QUEUE_WRAP((eventQueuePtr)->base + 1); \
318 (eventQueuePtr)->length--; \
321 #define RESET_QUEUE(eventQueuePtr) \
323 (eventQueuePtr)->base = 0; \
324 (eventQueuePtr)->length = 0; \
327 /* node stack macros - used to browse a tree without using a recursive function */
328 #define NODE_STACK_INIT(stack) { (stack)->nodeCount = 0; }
329 #define NODE_STACK_PUSH(stack, node, offset) { (stack)->nodes[(stack)->nodeCount] = (node); (stack)->offsets[(stack)->nodeCount++] = (offset); }
330 #define NODE_STACK_POP(stack, node, offset) { (node) = (stack)->nodes[--(stack)->nodeCount]; offset = (stack)->offsets[(stack)->nodeCount]; }
331 #define NODE_STACK_NONEMPTY(stack) ((stack)->nodeCount != 0)
334 #define IX_ETH_DB_NPE_MSG_HISTORY_DEPTH (100)
335 #define LOG_NPE_MSG(msg) \
337 UINT32 npeMsgHistoryIndex = (npeMsgHistoryLen++) % IX_ETH_DB_NPE_MSG_HISTORY_DEPTH; \
338 npeMsgHistory[npeMsgHistoryIndex][0] = msg.data[0]; \
339 npeMsgHistory[npeMsgHistoryIndex][1] = msg.data[1]; \
342 #define LOG_NPE_MSG() /* nothing */
345 /* ----------- Data -------------- */
349 typedef UINT32 (*HashFunction)(void *entity);
350 typedef BOOL (*MatchFunction)(void *reference, void *entry);
351 typedef void (*FreeFunction)(void *entry);
354 * basic component of a hash table
356 typedef struct HashNode_t
358 void *data; /**< specific data */
359 struct HashNode_t *next; /**< used for bucket chaining */
361 __mempool__ struct HashNode_t *nextFree; /**< memory pool management */
363 __lock__ IxOsalFastMutex lock; /**< node lock */
367 * @brief hash table iterator definition
369 * an iterator is an object which can be used
370 * to browse a hash table
374 UINT32 bucketIndex; /**< index of the currently iterated bucket */
375 HashNode *previousNode; /**< reference to the previously iterated node within the current bucket */
376 HashNode *node; /**< reference to the currently iterated node */
380 * definition of a MAC descriptor (a database record)
385 IX_ETH_DB_WIFI_AP_TO_STA = 0x0,
386 IX_ETH_DB_WIFI_AP_TO_AP = 0x1
387 } IxEthDBWiFiRecordType;
394 BOOL staticEntry; /**< true if this address is static (doesn't age) */
401 UINT32 ieee802_1qTag;
406 IxEthDBWiFiRecordType type; /**< AP_TO_AP (0x1) or AP_TO_STA (0x0) */
407 UINT32 gwAddressIndex; /**< used only when linearizing the entries for NPE usage */
408 UINT8 gwMacAddress[IX_IEEE803_MAC_ADDRESS_SIZE];
410 __alignment__ UINT8 reserved2[2];
414 typedef struct MacDescriptor_t
416 UINT8 macAddress[IX_IEEE803_MAC_ADDRESS_SIZE];
418 __alignment__ UINT8 reserved1[2];
421 IxEthDBRecordType type;
422 IxEthDBRecordData recordData;
424 /* used for internal operations, such as NPE linearization */
427 /* custom user data */
430 __mempool__ struct MacDescriptor_t *nextFree; /**< memory pool management */
431 __smartpointer__ UINT32 refCount; /**< smart pointer reference counter */
435 * hash table definition
439 HashNode *hashBuckets[NUM_BUCKETS];
442 __lock__ IxOsalFastMutex bucketLocks[NUM_BUCKETS];
444 HashFunction entryHashFunction;
445 MatchFunction *matchFunctions;
446 FreeFunction freeFunction;
451 IX_ETH_DB_MAC_KEY = 1,
452 IX_ETH_DB_MAC_PORT_KEY = 2,
453 IX_ETH_DB_MAC_VLAN_KEY = 3,
454 IX_ETH_DB_MAX_KEY_INDEX = 3
455 } IxEthDBSearchKeyType;
457 typedef struct MacTreeNode_t
459 __smartpointer__ MacDescriptor *descriptor;
460 struct MacTreeNode_t *left, *right;
462 __mempool__ struct MacTreeNode_t *nextFree;
465 typedef IxEthDBStatus (*IxEthDBPortUpdateHandler)(IxEthDBPortId portID, IxEthDBRecordType type);
467 typedef void (*IxEthDBNoteWriteFn)(void *address, MacTreeNode *node);
471 BOOL updateEnabled; /**< true if updates are enabled for port */
472 BOOL userControlled; /**< true if the user has manually used ixEthDBPortUpdateEnableSet */
473 BOOL treeInitialized; /**< true if the NPE has received an initial tree */
474 IxEthDBPortUpdateHandler updateHandler; /**< port update handler routine */
475 void *npeUpdateZone; /**< port update memory zone */
476 void *npeGwUpdateZone; /**< port update memory zone for gateways */
477 void *vlanUpdateZone; /**< port update memory zone for VLAN tables */
478 MacTreeNode *searchTree; /**< internal search tree, in MacTreeNode representation */
479 BOOL searchTreePendingWrite; /**< true if searchTree holds a tree pending write to the port */
484 IxEthDBPortId portID; /**< port ID */
485 BOOL enabled; /**< true if the port is enabled */
486 BOOL agingEnabled; /**< true if aging on this port is enabled */
488 IxEthDBPortMap dependencyPortMap; /**< dependency port map for this port */
489 PortUpdateMethod updateMethod; /**< update method structure */
490 BOOL macAddressUploaded; /**< true if the MAC address was uploaded into the port */
491 UINT32 maxRxFrameSize; /**< maximum Rx frame size for this port */
492 UINT32 maxTxFrameSize; /**< maximum Rx frame size for this port */
495 __alignment__ UINT8 reserved[2];
496 UINT32 frameControlDurationID; /**< Frame Control - Duration/ID WiFi control */
498 IxEthDBVlanTag vlanTag; /**< default VLAN tag for port */
499 IxEthDBPriorityTable priorityTable; /**< QoS <=> internal priority mapping */
500 IxEthDBVlanSet vlanMembership;
501 IxEthDBVlanSet transmitTaggingInfo;
502 IxEthDBFrameFilter frameFilter;
503 IxEthDBTaggingAction taggingAction;
505 UINT32 npeFrameFilter;
506 UINT32 npeTaggingAction;
508 IxEthDBFirewallMode firewallMode;
509 BOOL srcAddressFilterEnabled;
513 IxEthDBFeature featureCapability;
514 IxEthDBFeature featureStatus;
516 UINT32 ixEthDBTrafficClassAQMAssignments[IX_IEEE802_1Q_QOS_PRIORITY_COUNT];
518 UINT32 ixEthDBTrafficClassCount;
520 UINT32 ixEthDBTrafficClassAvailable;
524 __lock__ IxOsalMutex npeAckLock;
527 /* list of port information structures indexed on port Ids */
528 extern IX_ETH_DB_PUBLIC PortInfo ixEthDBPortInfo[IX_ETH_DB_NUMBER_OF_PORTS];
532 IX_ETH_DB_ADD_FILTERING_RECORD = 0xFF0001,
533 IX_ETH_DB_REMOVE_FILTERING_RECORD = 0xFF0002
539 IxEthDBPortId portID;
540 IxEthDBMacAddr macAddr;
546 PortEvent queue[EVENT_QUEUE_SIZE];
553 IxEthDBPortId portID; /**< originating port */
554 MacDescriptor *macDescriptors[MAX_ELT_SIZE]; /**< addresses to be synced into db */
555 UINT32 addressCount; /**< number of addresses */
560 MacTreeNode *nodes[MAX_ELT_SIZE];
561 UINT32 offsets[MAX_ELT_SIZE];
567 /* ----------- Memory management -------------- */
569 IX_ETH_DB_PUBLIC void ixEthDBInitMemoryPools(void);
571 IX_ETH_DB_PUBLIC HashNode* ixEthDBAllocHashNode(void);
572 IX_ETH_DB_PUBLIC void ixEthDBFreeHashNode(HashNode *);
574 IX_ETH_DB_PUBLIC __smartpointer__ MacDescriptor* ixEthDBAllocMacDescriptor(void);
575 IX_ETH_DB_PUBLIC __smartpointer__ MacDescriptor* ixEthDBCloneMacDescriptor(MacDescriptor *macDescriptor);
576 IX_ETH_DB_PUBLIC __smartpointer__ void ixEthDBFreeMacDescriptor(MacDescriptor *);
578 IX_ETH_DB_PUBLIC __smartpointer__ MacTreeNode* ixEthDBAllocMacTreeNode(void);
579 IX_ETH_DB_PUBLIC __smartpointer__ MacTreeNode* ixEthDBCloneMacTreeNode(MacTreeNode *);
580 IX_ETH_DB_PUBLIC __smartpointer__ void ixEthDBFreeMacTreeNode(MacTreeNode *);
582 IX_ETH_DB_PUBLIC void ixEthDBPoolFreeMacTreeNode(MacTreeNode *);
583 IX_ETH_DB_PUBLIC UINT32 ixEthDBSearchTreeUsageGet(MacTreeNode *tree);
584 IX_ETH_DB_PUBLIC int ixEthDBShowMemoryStatus(void);
587 IX_ETH_DB_PUBLIC void ixEthDBInitHash(HashTable *hashTable, UINT32 numBuckets, HashFunction entryHashFunction, MatchFunction *matchFunctions, FreeFunction freeFunction);
589 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBAddHashEntry(HashTable *hashTable, void *entry);
590 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBRemoveHashEntry(HashTable *hashTable, int keyType, void *reference);
591 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBSearchHashEntry(HashTable *hashTable, int keyType, void *reference, HashNode **searchResult);
592 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPeekHashEntry(HashTable *hashTable, int keyType, void *reference);
593 IX_ETH_DB_PUBLIC void ixEthDBReleaseHashNode(HashNode *node);
595 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBInitHashIterator(HashTable *hashTable, HashIterator *iterator);
596 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBIncrementHashIterator(HashTable *hashTable, HashIterator *iterator);
597 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBRemoveEntryAtHashIterator(HashTable *hashTable, HashIterator *iterator);
598 IX_ETH_DB_PUBLIC void ixEthDBReleaseHashIterator(HashIterator *iterator);
601 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPortAddressSet(IxEthDBPortId portID, IxEthDBMacAddr *macAddr);
602 IX_ETH_DB_PUBLIC void ixEthDBMaximumFrameSizeAckCallback(IxNpeMhNpeId npeID, IxNpeMhMessage msg);
604 /* DB Core functions */
605 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBInit(void);
606 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBAdd(MacDescriptor *newRecordTemplate, IxEthDBPortMap updateTrigger);
607 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBRemove(MacDescriptor *templateRecord, IxEthDBPortMap updateTrigger);
608 IX_ETH_DB_PUBLIC HashNode* ixEthDBSearch(IxEthDBMacAddr *macAddress, IxEthDBRecordType typeFilter);
609 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPeek(IxEthDBMacAddr *macAddress, IxEthDBRecordType typeFilter);
611 /* Learning support */
612 IX_ETH_DB_PUBLIC UINT32 ixEthDBAddressCompare(UINT8 *mac1, UINT8 *mac2);
613 IX_ETH_DB_PUBLIC BOOL ixEthDBAddressMatch(void *reference, void *entry);
614 IX_ETH_DB_PUBLIC UINT32 ixEthDBEntryXORHash(void *macDescriptor);
615 IX_ETH_DB_PUBLIC UINT32 ixEthDBKeyXORHash(void *macAddress);
618 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBNPEUpdateHandler(IxEthDBPortId portID, IxEthDBRecordType type);
619 IX_ETH_DB_PUBLIC void ixEthDBUpdatePortLearningTrees(IxEthDBPortMap triggerPorts);
620 IX_ETH_DB_PUBLIC void ixEthDBNPEAccessRequest(IxEthDBPortId portID);
621 IX_ETH_DB_PUBLIC void ixEthDBUpdateLock(void);
622 IX_ETH_DB_PUBLIC void ixEthDBUpdateUnlock(void);
623 IX_ETH_DB_PUBLIC MacTreeNode* ixEthDBQuery(MacTreeNode *searchTree, IxEthDBPortMap query, IxEthDBRecordType recordFilter, UINT32 maximumEntries);
624 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFirewallUpdate(IxEthDBPortId portID, void *address, UINT32 epDelta);
627 IX_ETH_DB_PUBLIC void ixEthDBPortSetAckCallback(IxNpeMhNpeId npeID, IxNpeMhMessage msg);
628 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBEventProcessorInit(void);
629 IX_ETH_DB_PUBLIC void ixEthDBPortInit(IxEthDBPortId portID);
630 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPortEnable(IxEthDBPortId portID);
631 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPortDisable(IxEthDBPortId portID);
632 IX_ETH_DB_PUBLIC void ixEthDBNPEUpdateAreasInit(void);
633 IX_ETH_DB_PUBLIC UINT32 ixEthDBMatchMethodsRegister(MatchFunction *matchFunctions);
634 IX_ETH_DB_PUBLIC UINT32 ixEthDBRecordSerializeMethodsRegister(void);
635 IX_ETH_DB_PUBLIC UINT32 ixEthDBUpdateTypeRegister(BOOL *typeArray);
636 IX_ETH_DB_PUBLIC void ixEthDBNPEUpdateAreasUnload(void);
637 IX_ETH_DB_PUBLIC void ixEthDBFeatureCapabilityScan(void);
638 IX_ETH_DB_PUBLIC UINT32 ixEthDBKeyTypeRegister(UINT32 *keyType);
640 /* Event processing */
641 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBDefaultEventCallbackEnable(IxEthDBPortId portID, BOOL enable);
642 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBTriggerAddPortUpdate(IxEthDBMacAddr *macAddr, IxEthDBPortId portID, BOOL staticEntry);
643 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBTriggerRemovePortUpdate(IxEthDBMacAddr *macAddr, IxEthDBPortId portID);
644 IX_ETH_DB_PUBLIC void ixEthDBNPEEventCallback(IxNpeMhNpeId npeID, IxNpeMhMessage msg);
647 IX_ETH_DB_PUBLIC void ixEthDBGetMacDatabaseCbk(IxNpeMhNpeId npeID, IxNpeMhMessage msg);
648 IX_ETH_DB_PUBLIC void ixEthDBNpeMsgAck(IxNpeMhNpeId npeID, IxNpeMhMessage msg);
649 IX_ETH_DB_PUBLIC void ixEthDBNPESyncScan(IxEthDBPortId portID, void *eltBaseAddress, UINT32 eltSize);
650 IX_ETH_DB_PUBLIC void ixEthDBNPETreeWrite(IxEthDBRecordType type, UINT32 totalSize, void *baseAddress, MacTreeNode *tree, UINT32 *blocks, UINT32 *startIndex);
651 IX_ETH_DB_PUBLIC void ixEthDBNPEGatewayNodeWrite(void *address, MacTreeNode *node);
653 /* Other public API functions */
654 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBStartLearningFunction(void);
655 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBStopLearningFunction(void);
656 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPortUpdateEnableSet(IxEthDBPortId portID, BOOL enableUpdate);
658 /* Maximum Tx/Rx public functions */
659 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFilteringPortMaximumRxFrameSizeSet(IxEthDBPortId portID, UINT32 maximumRxFrameSize);
660 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBFilteringPortMaximumTxFrameSizeSet(IxEthDBPortId portID, UINT32 maximumTxFrameSize);
663 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBPortVlanTableSet(IxEthDBPortId portID, IxEthDBVlanSet portVlanTable, IxEthDBVlanSet vlanSet);
666 IX_ETH_DB_PUBLIC BOOL ixEthDBAddressRecordMatch(void *untypedReference, void *untypedEntry);
667 IX_ETH_DB_PUBLIC BOOL ixEthDBVlanRecordMatch(void *untypedReference, void *untypedEntry);
668 IX_ETH_DB_PUBLIC BOOL ixEthDBPortRecordMatch(void *untypedReference, void *untypedEntry);
669 IX_ETH_DB_PUBLIC BOOL ixEthDBNullMatch(void *reference, void *entry);
670 IX_ETH_DB_PUBLIC HashNode* ixEthDBPortSearch(IxEthDBMacAddr *macAddress, IxEthDBPortId portID, IxEthDBRecordType typeFilter);
671 IX_ETH_DB_PUBLIC HashNode* ixEthDBVlanSearch(IxEthDBMacAddr *macAddress, IxEthDBVlanId vlanID, IxEthDBRecordType typeFilter);
674 IX_ETH_DB_PUBLIC const char* mac2string(const unsigned char *mac);
675 IX_ETH_DB_PUBLIC void showHashInfo(void);
676 IX_ETH_DB_PUBLIC int ixEthDBAnalyzeHash(void);
677 IX_ETH_DB_PUBLIC const char* errorString(IxEthDBStatus error);
678 IX_ETH_DB_PUBLIC int numHashElements(void);
679 IX_ETH_DB_PUBLIC void zapHashtable(void);
680 IX_ETH_DB_PUBLIC BOOL ixEthDBCheckSingleBitValue(UINT32 value);
682 /* Single Eth NPE Check */
683 IX_ETH_DB_PUBLIC IxEthDBStatus ixEthDBSingleEthNpeCheck(IxEthDBPortId portId);
685 #endif /* IxEthDB_p_H */