net: ethernet: freescale: Use generic CRC32 implementation
Use generic kernel CRC32 implementation because it: 1. Should be faster (uses lookup tables), 2. Removes duplicated CRC generation code, 3. Uses well-proven algorithm instead of coding it one more time. Suggested-by: Eric Biggers <ebiggers3@gmail.com> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
34786005ec
commit
16f6e9835b
@ -48,6 +48,7 @@
|
|||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/irq.h>
|
#include <linux/irq.h>
|
||||||
#include <linux/clk.h>
|
#include <linux/clk.h>
|
||||||
|
#include <linux/crc32.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/mdio.h>
|
#include <linux/mdio.h>
|
||||||
#include <linux/phy.h>
|
#include <linux/phy.h>
|
||||||
@ -2955,7 +2956,7 @@ static void set_multicast_list(struct net_device *ndev)
|
|||||||
{
|
{
|
||||||
struct fec_enet_private *fep = netdev_priv(ndev);
|
struct fec_enet_private *fep = netdev_priv(ndev);
|
||||||
struct netdev_hw_addr *ha;
|
struct netdev_hw_addr *ha;
|
||||||
unsigned int i, bit, data, crc, tmp;
|
unsigned int crc, tmp;
|
||||||
unsigned char hash;
|
unsigned char hash;
|
||||||
unsigned int hash_high = 0, hash_low = 0;
|
unsigned int hash_high = 0, hash_low = 0;
|
||||||
|
|
||||||
@ -2983,15 +2984,7 @@ static void set_multicast_list(struct net_device *ndev)
|
|||||||
/* Add the addresses in hash register */
|
/* Add the addresses in hash register */
|
||||||
netdev_for_each_mc_addr(ha, ndev) {
|
netdev_for_each_mc_addr(ha, ndev) {
|
||||||
/* calculate crc32 value of mac address */
|
/* calculate crc32 value of mac address */
|
||||||
crc = 0xffffffff;
|
crc = ether_crc_le(ndev->addr_len, ha->addr);
|
||||||
|
|
||||||
for (i = 0; i < ndev->addr_len; i++) {
|
|
||||||
data = ha->addr[i];
|
|
||||||
for (bit = 0; bit < 8; bit++, data >>= 1) {
|
|
||||||
crc = (crc >> 1) ^
|
|
||||||
(((crc ^ data) & 1) ? CRC32_POLY : 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* only upper 6 bits (FEC_HASH_BITS) are used
|
/* only upper 6 bits (FEC_HASH_BITS) are used
|
||||||
* which point to specific bit in the hash registers
|
* which point to specific bit in the hash registers
|
||||||
|
Loading…
Reference in New Issue
Block a user