Commit b86cd700 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by David S. Miller

net: add helper eth_hw_addr_crc

Several drivers use the same code as basis for filter hashes. Therefore
let's factor it out to a helper. This way drivers don't have to access
struct netdev_hw_addr internals.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e90c9fce
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/random.h> #include <linux/random.h>
#include <linux/crc32.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
#include <asm/bitsperlong.h> #include <asm/bitsperlong.h>
...@@ -265,6 +266,17 @@ static inline void eth_hw_addr_random(struct net_device *dev) ...@@ -265,6 +266,17 @@ static inline void eth_hw_addr_random(struct net_device *dev)
eth_random_addr(dev->dev_addr); eth_random_addr(dev->dev_addr);
} }
/**
* eth_hw_addr_crc - Calculate CRC from netdev_hw_addr
* @ha: pointer to hardware address
*
* Calculate CRC from a hardware address as basis for filter hashes.
*/
static inline u32 eth_hw_addr_crc(struct netdev_hw_addr *ha)
{
return ether_crc(ETH_ALEN, ha->addr);
}
/** /**
* ether_addr_copy - Copy an Ethernet address * ether_addr_copy - Copy an Ethernet address
* @dst: Pointer to a six-byte array Ethernet address destination * @dst: Pointer to a six-byte array Ethernet address destination
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment