All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: netdev@vger.kernel.org
Subject: [PATCH 07/10] chelsio: use standard CRC routines
Date: Fri, 01 Dec 2006 16:36:19 -0800	[thread overview]
Message-ID: <20061202003707.675818000@osdl.org> (raw)
In-Reply-To: 20061202003612.573260000@osdl.org

[-- Attachment #1: pm3393-crc.patch --]
[-- Type: text/plain, Size: 2198 bytes --]

Replace driver crc calculation with existing library.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

---
 drivers/net/Kconfig          |    1 +
 drivers/net/chelsio/pm3393.c |   31 +++----------------------------
 2 files changed, 4 insertions(+), 28 deletions(-)

--- chelsio.orig/drivers/net/Kconfig
+++ chelsio/drivers/net/Kconfig
@@ -2360,6 +2360,7 @@ menu "Ethernet (10000 Mbit)"
 config CHELSIO_T1
         tristate "Chelsio 10Gb Ethernet support"
         depends on PCI
+	select CRC32
         help
           This driver supports Chelsio gigabit and 10-gigabit
           Ethernet cards. More information about adapter features and
--- chelsio.orig/drivers/net/chelsio/pm3393.c
+++ chelsio/drivers/net/chelsio/pm3393.c
@@ -43,6 +43,8 @@
 #include "elmer0.h"
 #include "suni1x10gexp_regs.h"
 
+#include <linux/crc32.h>
+
 #define OFFSET(REG_ADDR)    (REG_ADDR << 2)
 
 /* Max frame size PM3393 can handle. Includes Ethernet header and CRC. */
@@ -345,33 +347,6 @@ static int pm3393_set_mtu(struct cmac *c
 	return 0;
 }
 
-static u32 calc_crc(u8 *b, int len)
-{
-	int i;
-	u32 crc = (u32)~0;
-
-	/* calculate crc one bit at a time */
-	while (len--) {
-		crc ^= *b++;
-		for (i = 0; i < 8; i++) {
-			if (crc & 0x1)
-				crc = (crc >> 1) ^ 0xedb88320;
-			else
-				crc = (crc >> 1);
-		}
-	}
-
-	/* reverse bits */
-	crc = ((crc >> 4) & 0x0f0f0f0f) | ((crc << 4) & 0xf0f0f0f0);
-	crc = ((crc >> 2) & 0x33333333) | ((crc << 2) & 0xcccccccc);
-	crc = ((crc >> 1) & 0x55555555) | ((crc << 1) & 0xaaaaaaaa);
-	/* swap bytes */
-	crc = (crc >> 16) | (crc << 16);
-	crc = (crc >> 8 & 0x00ff00ff) | (crc << 8 & 0xff00ff00);
-
-	return crc;
-}
-
 static int pm3393_set_rx_mode(struct cmac *cmac, struct t1_rx_mode *rm)
 {
 	int enabled = cmac->instance->enabled & MAC_DIRECTION_RX;
@@ -405,7 +380,7 @@ static int pm3393_set_rx_mode(struct cma
 		u16 mc_filter[4] = { 0, };
 
 		while ((addr = t1_get_next_mcaddr(rm))) {
-			bit = (calc_crc(addr, ETH_ALEN) >> 23) & 0x3f;	/* bit[23:28] */
+			bit = (ether_crc(ETH_ALEN, addr) >> 23) & 0x3f;	/* bit[23:28] */
 			mc_filter[bit >> 4] |= 1 << (bit & 0xf);
 		}
 		pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_LOW, mc_filter[0]);

-- 


  parent reply	other threads:[~2006-12-02  0:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-02  0:36 [PATCH 00/10] chelsio: 10G driver Stephen Hemminger
2006-12-02  0:36 ` [PATCH 01/10] chelsio: whitespace fixes Stephen Hemminger
2006-12-02  0:36 ` [PATCH 02/10] chelsio: use kzalloc Stephen Hemminger
2006-12-02  0:36 ` [PATCH 03/10] chelsio: remove unused mutex Stephen Hemminger
2006-12-02  0:36 ` [PATCH 05/10] chelsio: add 1G swcixw aupport Stephen Hemminger
2006-12-02  0:36 ` [PATCH 06/10] chelsio: cleanup pm3393 code Stephen Hemminger
2006-12-02  0:36 ` Stephen Hemminger [this message]
2006-12-02  0:36 ` [PATCH 08/10] chelsio: add MSI support Stephen Hemminger
2006-12-02  0:36 ` [PATCH 09/10] chelsio: statistics improvement Stephen Hemminger
2006-12-02  0:36 ` [PATCH 10/10] chelesio: transmit locking (plus bug fix) Stephen Hemminger
2006-12-03 10:45   ` Eric Lemoine
2006-12-04 17:58     ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061202003707.675818000@osdl.org \
    --to=shemminger@osdl.org \
    --cc=jgarzik@pobox.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.