net/tg3: use crc32() instead of hand-rolled equivalent
Subsystems (3)
PATCH 1/1 net/tg3: use crc32() instead of hand-rolled equivalent
From: Eric Biggers <[email protected]>
The calculation done by calc_crc() is equivalent to ~crc32(~0, buf, len), so just use that instead.
Signed-off-by Eric Biggers <[email protected]>
--- drivers/net/ethernet/broadcom/Kconfig | 1 + drivers/net/ethernet/broadcom/tg3.c | 23 ++--------------------- 2 files changed, 3 insertions(+), 21 deletions(-)
drivers/net/ethernet/broadcom/Kconfig +1 -0
@@ -121,10 +121,11 @@ config SB1250_MAC config TIGON3 tristate "Broadcom Tigon3 support" depends on PCI depends on PTP_1588_CLOCK_OPTIONAL + select CRC32 select PHYLIB help This driver supports Broadcom Tigon3 based gigabit Ethernet cards. To compile this driver as a module, choose M here: the module
drivers/net/ethernet/broadcom/tg3.c +2 -21
@@ -52,11 +52,11 @@#include <linux/dma-mapping.h> #include <linux/firmware.h> #include <linux/ssb/ssb_driver_gige.h> #include <linux/hwmon.h> #include <linux/hwmon-sysfs.h> -#include <linux/crc32poly.h> +#include <linux/crc32.h> #include <linux/dmi.h> #include <net/checksum.h> #include <net/gso.h> #include <net/ip.h>
@@ -9807,30 +9807,11 @@ static void tg3_setup_rxbd_thresholds(struct tg3 *tp)tw32 (JMB_REPLENISH_LWM , bdcache_maxcnt); }static inline u32 calc_crc (unsigned char *buf,int len) { -u32 reg; -u32 tmp; -int j, k; - - reg =0xffffffff ; - -for (j =0 ; j < len; j++) { - reg ^= buf[j]; - -for (k =0 ; k <8 ; k++) { - tmp = reg &0x01 ; - - reg >>=1 ; - -if (tmp) - reg ^=CRC32_POLY_LE ; - } - } - -return ~reg; +return ~crc32 (~0 , buf, len); }static void tg3_set_multi (struct tg3 *tp,unsigned int accept_all) {/* accept or reject all multicast frames */
base-commit: e39d14a760c039af0653e3df967e7525413924a0
Signature · 1 line
2.49.0
Quoted 4 lines · On Mon, 12 May 2025 21:14:02 -0700 Eric Biggers wrote:
From: Eric Biggers <[email protected]>
The calculation done by
calc_crc()is equivalent to ~crc32(~0, buf, len), so just use that instead.
I applied this and the bmac patch, thanks!
For some reason the bot doesn't want to reply.