⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ixethdb_p.h

📁 intel IXP400系列cpu(2.3版)的库文件
💻 H
📖 第 1 页 / 共 3 页
字号:
    if ((portID) >= IX_ETH_DB_NUMBER_OF_PORTS) \    { \        return IX_ETH_DB_INVALID_PORT; \    } \    else \    { \        if (!ixEthDBPortInfo[portID].initialized) \        { \            return IX_ETH_DB_PORT_UNINITIALIZED; \        } \    } \}/* single NPE check */#define IX_ETH_DB_CHECK_SINGLE_NPE(portID) \    if (ixEthDBSingleEthNpeCheck(portID) != IX_ETH_DB_SUCCESS) \    { \        WARNING_LOG("EthDB: port ID %d is unavailable\n",(UINT32) portID); \        \        return IX_ETH_DB_INVALID_PORT; \    }/* feature check */#define IX_ETH_DB_CHECK_FEATURE(portID, feature) \    if ((ixEthDBPortInfo[portID].featureStatus & feature) == 0) \    { \        return IX_ETH_DB_FEATURE_UNAVAILABLE; \    }/* busy retrying */#define BUSY_RETRY(functionCall) \    { \        UINT32 retries = 0; \        IxEthDBStatus br_result; \        \        while ((br_result = functionCall) == IX_ETH_DB_BUSY \            && BUSY_RETRY_ENABLED && (FOREVER_RETRY || ++retries < MAX_RETRIES)) { ixOsalSleep(BUSY_RETRY_YIELD); }; \        \        if ((!FOREVER_RETRY && retries == MAX_RETRIES) || (br_result == IX_ETH_DB_FAIL)) \        {\            ERROR_LOG("Ethernet Learning Database Error: BUSY_RETRY failed at %s:%d\n", __FILE__, __LINE__); \        }\    }#define BUSY_RETRY_WITH_RESULT(functionCall, brwr_result) \    { \        UINT32 retries = 0; \        \        while ((brwr_result = functionCall) == IX_ETH_DB_BUSY \            && BUSY_RETRY_ENABLED && (FOREVER_RETRY || ++retries < MAX_RETRIES)) { ixOsalSleep(BUSY_RETRY_YIELD); }; \        \        if ((!FOREVER_RETRY && retries == MAX_RETRIES) || (brwr_result == IX_ETH_DB_FAIL)) \        {\            ERROR_LOG("Ethernet Learning Database Error: BUSY_RETRY_WITH_RESULT failed at %s:%d\n", __FILE__, __LINE__); \        }\    }/* iterators */#define IS_ITERATOR_VALID(iteratorPtr) ((iteratorPtr)->node != NULL)/* dependency port maps */    /* 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) *//* gives an empty dependency map */#define SET_EMPTY_DEPENDENCY_MAP(map)      { int i = 0; for (; i < 32 ; i++) map[i] = 0; }    #define IS_EMPTY_DEPENDENCY_MAP(result, map)       { int i = 0 ; result = TRUE; for (; i < 32 ; i++) if (map[i] != 0) { result = FALSE; break; }}    /** * gives a map consisting only of 'portID' */#define SET_DEPENDENCY_MAP(map, portID)    {SET_EMPTY_DEPENDENCY_MAP(map); map[portID >> 3] = 1 << (portID & 0x7);}/** * gives a map resulting from joining map1 and map2 */#define JOIN_MAPS(map, map1, map2)         { int i = 0; for (; i < 32 ; i++) map[i] = map1[i] | map2[i]; }/** * gives the map resulting from joining portID and map */#define JOIN_PORT_TO_MAP(map, portID)      { map[portID >> 3] |= 1 << (portID & 0x7); }/** * gives the map resulting from excluding portID from map */#define EXCLUDE_PORT_FROM_MAP(map, portID) { map[portID >> 3] &= ~(1 << (portID & 0x7); }/** * returns TRUE if map1 is a subset of map2 and FALSE otherwise */#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; }/** * returns TRUE is portID is part of map and FALSE otherwise */#define IS_PORT_INCLUDED(portID, map)      ((map[portID >> 3] & (1 << (portID & 0x7))) != 0)/** * returns the difference between map1 and map2 (ports included in map1 and not included in map2) */#define DIFF_MAPS(map, map1, map2)         { int i = 0; for (; i < 32 ; i++) map[i] = map1[i] ^ (map1[i] & map2[i]); }/** * returns TRUE if the maps collide (have at least one port in common) and FALSE otherwise */#define MAPS_COLLIDE(result, map1, map2)   { int i = 0; result = FALSE; for (; i < 32 ; i++) if ((map1[i] & map2[i]) != 0) result = TRUE; }/* size (number of ports) of a dependency map */#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); }}/* copy map2 into map1 */#define COPY_DEPENDENCY_MAP(map1, map2)    { ixOsalMemCopy (map1, map2, sizeof (map1)); }/* definition of a port map size/port number which cannot be reached (we support at most 32 ports) */#define MAX_PORT_SIZE   (0xFF)#define MAX_PORT_NUMBER (0xFF)#define IX_ETH_DB_CHECK_REFERENCE(ptr)   { if ((ptr) == NULL) { return IX_ETH_DB_INVALID_ARG; } }#define IX_ETH_DB_CHECK_MAP(portID, map) { if (!IS_PORT_INCLUDED(portID, map)) { return IX_ETH_DB_INVALID_ARG; } }#define IX_ETH_DB_CHECK_ADDR(addr)   { if ((addr[0]+addr[1]+addr[2]+addr[3]+addr[4]+addr[5]) == 0) { return IX_ETH_DB_INVALID_ARG; } }/* event queue macros */#define EVENT_QUEUE_WRAP(offset)            ((offset) >= EVENT_QUEUE_SIZE ? (offset) - EVENT_QUEUE_SIZE : (offset))#define CAN_ENQUEUE(eventQueuePtr)          ((eventQueuePtr)->length < EVENT_QUEUE_SIZE)        #define QUEUE_HEAD(eventQueuePtr)           (&(eventQueuePtr)->queue[EVENT_QUEUE_WRAP((eventQueuePtr)->base + (eventQueuePtr)->length)])#define QUEUE_TAIL(eventQueuePtr)           (&(eventQueuePtr)->queue[(eventQueuePtr)->base])#define PUSH_UPDATE_QUEUE(eventQueuePtr)    { (eventQueuePtr)->length++; }#define SHIFT_UPDATE_QUEUE(eventQueuePtr) \        { \            (eventQueuePtr)->base = EVENT_QUEUE_WRAP((eventQueuePtr)->base + 1); \            (eventQueuePtr)->length--; \        }#define RESET_QUEUE(eventQueuePtr) \    { \        (eventQueuePtr)->base   = 0; \        (eventQueuePtr)->length = 0; \    }/* node stack macros - used to browse a tree without using a recursive function */#define NODE_STACK_INIT(stack)               { (stack)->nodeCount = 0; }#define NODE_STACK_PUSH(stack, node, offset) { (stack)->nodes[(stack)->nodeCount] = (node); (stack)->offsets[((stack)->nodeCount)++] = (offset); }#define NODE_STACK_POP(stack, node, offset)  { (node) = (stack)->nodes[--((stack)->nodeCount)]; offset = (stack)->offsets[(stack)->nodeCount]; }#define NODE_STACK_NONEMPTY(stack)           ((stack)->nodeCount != 0)#ifndef IX_NDEBUG#define IX_ETH_DB_NPE_MSG_HISTORY_DEPTH (100)#define LOG_NPE_MSG(msg) \    do { \        UINT32 npeMsgHistoryIndex = (npeMsgHistoryLen++) % IX_ETH_DB_NPE_MSG_HISTORY_DEPTH; \        npeMsgHistory[npeMsgHistoryIndex][0] = msg.data[0]; \        npeMsgHistory[npeMsgHistoryIndex][1] = msg.data[1]; \    } while (0);#else#define LOG_NPE_MSG() /* nothing */#endif/* ----------- Data -------------- *//* typedefs */typedef UINT32 (*HashFunction)(void *entity);typedef BOOL (*MatchFunction)(void *reference, void *entry);typedef void (*FreeFunction)(void *entry);/** * basic component of a hash table */typedef struct HashNode_t{    void *data;                                 /**< specific data */    struct HashNode_t *next;                    /**< used for bucket chaining */    __mempool__ struct HashNode_t *nextFree;    /**< memory pool management */    __lock__ IxOsalFastMutex lock;              /**< node lock */} HashNode;/** * @brief hash table iterator definition * * an iterator is an object which can be used * to browse a hash table */typedef struct{    UINT32 bucketIndex;     /**< index of the currently iterated bucket */    HashNode *previousNode; /**< reference to the previously iterated node within the current bucket */    HashNode *node;         /**< reference to the currently iterated node */} HashIterator;typedef union{    struct    {        UINT32 age;        BOOL staticEntry; /**< TRUE if this address is static (doesn't age) */    } filteringData;    struct    {        UINT8 addressMask[IX_IEEE803_MAC_ADDRESS_SIZE];    } firewallData;    struct    {        UINT32 age;        BOOL staticEntry;        UINT32 ieee802_1qTag;      } filteringVlanData;    struct    {        UINT32 recIndex; 	/**< used only when linearizing the entries for NPE usage */	UINT32 logicalPortID; 	/**< Logical port ID from 0-39 */        UINT8 recType;   	/**< VLAN/LOCAL/ETHER/TOAP/TOSTA */        UINT8 padLength; 	/**< No of bytes to be padded to TOAP&TOSTA frames */        UINT8 gwMacAddress[IX_IEEE803_MAC_ADDRESS_SIZE];        UINT8 bssid[IX_IEEE803_MAC_ADDRESS_SIZE];        __alignment__ UINT8 reserved2[2];    } wifiData;} IxEthDBRecordData;typedef struct MacDescriptor_t{    UINT8 macAddress[IX_IEEE803_MAC_ADDRESS_SIZE];     __alignment__ UINT8 reserved1[2];        UINT32 portID;    IxEthDBRecordType type;    IxEthDBRecordData recordData;        /* used for internal operations, such as NPE linearization */    void *internal;        /* custom user data */    void *user;        __mempool__ struct MacDescriptor_t *nextFree;   /**< memory pool management */    __smartpointer__ UINT32 refCount;               /**< smart pointer reference counter */} MacDescriptor;/** * hash table definition */typedef struct{    HashNode *hashBuckets[NUM_BUCKETS];    UINT32 numBuckets;    __lock__ IxOsalFastMutex bucketLocks[NUM_BUCKETS];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -