Sample hash table code – Digi NS9215 User Manual

Page 334

Advertising
background image

E T H E R N E T C O M M U N I C A T I O N M O D U L E

Sample hash table code

334

Hardware Reference NS9215

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

S a m p l e h a s h t a b l e c o d e

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];

// create hash table for MAC address

eth_make_hash_table (hash_table);

Advertising