netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net/tg3: use crc32() instead of hand-rolled equivalent
@ 2025-05-13  4:14 Eric Biggers
  2025-05-15  2:59 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Biggers @ 2025-05-13  4:14 UTC (permalink / raw)
  To: netdev; +Cc: Pavan Chebbi, Michael Chan

From: Eric Biggers <ebiggers@google.com>

The calculation done by calc_crc() is equivalent to
~crc32(~0, buf, len), so just use that instead.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 drivers/net/ethernet/broadcom/Kconfig |  1 +
 drivers/net/ethernet/broadcom/tg3.c   | 23 ++---------------------
 2 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/Kconfig b/drivers/net/ethernet/broadcom/Kconfig
index 1bd4313215d7..636520bb4b8c 100644
--- a/drivers/net/ethernet/broadcom/Kconfig
+++ b/drivers/net/ethernet/broadcom/Kconfig
@@ -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
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index d1f541af4e3b..ff47e96b9124 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -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
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] net/tg3: use crc32() instead of hand-rolled equivalent
  2025-05-13  4:14 [PATCH net-next] net/tg3: use crc32() instead of hand-rolled equivalent Eric Biggers
@ 2025-05-15  2:59 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2025-05-15  2:59 UTC (permalink / raw)
  To: Eric Biggers; +Cc: netdev, Pavan Chebbi, Michael Chan

On Mon, 12 May 2025 21:14:02 -0700 Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> 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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-05-15  2:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-13  4:14 [PATCH net-next] net/tg3: use crc32() instead of hand-rolled equivalent Eric Biggers
2025-05-15  2:59 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).