diff options
author | David S. Miller <davem@davemloft.net> | 2020-05-04 21:19:58 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-05-04 21:19:58 +0300 |
commit | cad5eaf74f17049db21a90be9514cb920de5ba39 (patch) | |
tree | 49246aa0456e76e6598214b7990b568fc9fe380c | |
parent | e90c9fcedc087c8ba1d34da88381838ed68bfb1c (diff) | |
parent | bc54ac3609aa0361dfeb15758b7bacf3637f6d4a (diff) | |
download | linux-cad5eaf74f17049db21a90be9514cb920de5ba39.tar.xz |
Merge branch 'net-add-helper-eth_hw_addr_crc'
Heiner Kallweit says:
====================
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.
First user is r8169.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/realtek/r8169_main.c | 3 | ||||
-rw-r--r-- | include/linux/etherdevice.h | 12 |
2 files changed, 13 insertions, 2 deletions
diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 8b665f2ec21f..2f6512ed0a78 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -19,7 +19,6 @@ #include <linux/ethtool.h> #include <linux/phy.h> #include <linux/if_vlan.h> -#include <linux/crc32.h> #include <linux/in.h> #include <linux/io.h> #include <linux/ip.h> @@ -2610,7 +2609,7 @@ static void rtl_set_rx_mode(struct net_device *dev) mc_filter[1] = mc_filter[0] = 0; netdev_for_each_mc_addr(ha, dev) { - u32 bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26; + u32 bit_nr = eth_hw_addr_crc(ha) >> 26; mc_filter[bit_nr >> 5] |= BIT(bit_nr & 31); } diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h index 8801f1f986e5..2e5debc0373c 100644 --- a/include/linux/etherdevice.h +++ b/include/linux/etherdevice.h @@ -20,6 +20,7 @@ #include <linux/if_ether.h> #include <linux/netdevice.h> #include <linux/random.h> +#include <linux/crc32.h> #include <asm/unaligned.h> #include <asm/bitsperlong.h> @@ -266,6 +267,17 @@ static inline void eth_hw_addr_random(struct net_device *dev) } /** + * 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 * @dst: Pointer to a six-byte array Ethernet address destination * @src: Pointer to a six-byte array Ethernet address source |