www.digiembedded.com
397
Ethernet Communication Module
Sample hash table code
This sample C code describes how to calculate hash table entries based on 6-byte
Ethernet destination addresses and a hash table consisting of two 32-bit registers
(HT1 and HT2). HT1 contains locations 31:0 of the hash table; HT2 contains locations
63:32 of the hash table.
The pointer to the hash table is bits [28:23] of the Ethernet destination address CRC.
The polynomial is the same as that used for the Ethernet FCS:
G(x) = x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1
static ETH_ADDRESS mca_address[MAX_MCA]; /*list of MCA addresses*/
static INT16 mca_count; /*# of MCA addresses*/
/*
*
* Function: void eth_load_mca_table (void)
*
* Description:
*
* This routine loads the MCA table. It generates a hash table for
* the MCA addresses currently registered and then loads this table
* into the registers HT1 and HT2.
*
* Parameters:
*
* none
*
* Return Values:
*
* none
*
*/
static void eth_load_mca_table (void)
{
WORD32 has_table[2];