Skip to content

Commit b86cd70

Browse files
hkallweitdavem330
authored andcommitted
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: Heiner Kallweit <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e90c9fc commit b86cd70

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

include/linux/etherdevice.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/if_ether.h>
2121
#include <linux/netdevice.h>
2222
#include <linux/random.h>
23+
#include <linux/crc32.h>
2324
#include <asm/unaligned.h>
2425
#include <asm/bitsperlong.h>
2526

@@ -265,6 +266,17 @@ static inline void eth_hw_addr_random(struct net_device *dev)
265266
eth_random_addr(dev->dev_addr);
266267
}
267268

269+
/**
270+
* eth_hw_addr_crc - Calculate CRC from netdev_hw_addr
271+
* @ha: pointer to hardware address
272+
*
273+
* Calculate CRC from a hardware address as basis for filter hashes.
274+
*/
275+
static inline u32 eth_hw_addr_crc(struct netdev_hw_addr *ha)
276+
{
277+
return ether_crc(ETH_ALEN, ha->addr);
278+
}
279+
268280
/**
269281
* ether_addr_copy - Copy an Ethernet address
270282
* @dst: Pointer to a six-byte array Ethernet address destination

0 commit comments

Comments
 (0)