Subject: Re: [PATCH] support for large number of network devices.

From: Ben Greear <[email-masked]>
Date: Tue, 13 Jan 2004 23:54:56 -0800

David S. Miller wrote:

> Therefore, I think it's wise to just do this right from the start and use a hash.
> Stephen can you test up and submit the netdev name hash patch you have?
> 

In case it proves useful, here's the hash I used before.  It makes some
assumptions based on the fact that the last two characters of a device name
are often numbers, especially when you have lots of devices.  Someone
did a mapping of this and found it worked well for vlans, at least.

int fdl_calc_name_idx(const char* dev_name) {
  int tmp = 0;
  int i;

  for (i = 0; dev_name[i]; i++) {
    tmp += (int)(dev_name[i]);
  }
  if (i > 3) {
    tmp += (dev_name[i-2] * 10); /* might add a little spread to the hash */
    tmp += (dev_name[i-3] * 100); /* might add a little spread to the hash */
  }
  return (tmp % FDL_HASH_LEN);
}

-- 
Ben Greear <[email-masked]>
Candela Technologies Inc  http://www.candelatech.com