Digi NS9215 manual M p l e h a s h t a b l e code

Models: NS9215

1 517
Download 517 pages 25.29 Kb
Page 334
Image 334

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

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

334Hardware Reference NS9215

Page 334
Image 334
Digi NS9215 manual M p l e h a s h t a b l e code