History

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.

Heiner Kallweit committed 6 years ago

Commit b86cd701 parent e90c9fc1 file · +12 −0Browse files

Showing the changes to include/linux (1 of 1 file). Show all

Unified · Split

include/linux/etherdevice.h+12−0
@@ -20,6 +20,7 @@ · 19 unmodified lines
20#include <linux/if_ether.h>20#include <linux/if_ether.h>
21#include <linux/netdevice.h>21#include <linux/netdevice.h>
22#include <linux/random.h>22#include <linux/random.h>
23#include <linux/crc32.h>
23#include <asm/unaligned.h>24#include <asm/unaligned.h>
24#include <asm/bitsperlong.h>25#include <asm/bitsperlong.h>
25 26
@@ -265,6 +266,17 @@ static inline void eth_hw_addr_random(struct net_device *dev) · 239 unmodified lines
265 eth_random_addr(dev->dev_addr);266 eth_random_addr(dev->dev_addr);
266}267}
267 268
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 */
275static inline u32 eth_hw_addr_crc(struct netdev_hw_addr *ha)
276{
277 return ether_crc(ETH_ALEN, ha->addr);
278}
279
268/**280/**
269 * ether_addr_copy - Copy an Ethernet address281 * ether_addr_copy - Copy an Ethernet address
270 * @dst: Pointer to a six-byte array Ethernet address destination282 * @dst: Pointer to a six-byte array Ethernet address destination