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.
Showing the changes to include/linux (1 of 1 file). Show all
Unified · Split
| @@ -20,6 +20,7 @@ · 19 unmodified lines | ||
| 20 | 20 | #include <linux/if_ether.h> |
| 21 | 21 | #include <linux/netdevice.h> |
| 22 | 22 | #include <linux/random.h> |
| 23 | +#include <linux/crc32.h> | |
| 23 | 24 | #include <asm/unaligned.h> |
| 24 | 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 | 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 | + */ | |
| 275 | +static 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 | 281 | * ether_addr_copy - Copy an Ethernet address |
| 270 | 282 | * @dst: Pointer to a six-byte array Ethernet address destination |