Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Use ether_crc32_be() for multicast hash calculat...



details:   https://anonhg.NetBSD.org/src/rev/65d9212ed54f
branches:  trunk
changeset: 503037:65d9212ed54f
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Mon Jan 29 12:04:10 2001 +0000

description:
Use ether_crc32_be() for multicast hash calculation.

diffstat:

 sys/dev/pci/if_vr.c |  33 +++------------------------------
 1 files changed, 3 insertions(+), 30 deletions(-)

diffs (54 lines):

diff -r f92994fd48b3 -r 65d9212ed54f sys/dev/pci/if_vr.c
--- a/sys/dev/pci/if_vr.c       Mon Jan 29 11:26:28 2001 +0000
+++ b/sys/dev/pci/if_vr.c       Mon Jan 29 12:04:10 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_vr.c,v 1.45 2001/01/29 01:24:42 enami Exp $ */
+/*     $NetBSD: if_vr.c,v 1.46 2001/01/29 12:04:10 tsutsui Exp $       */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -314,7 +314,6 @@
 static void vr_mii_writereg    __P((struct device *, int, int, int));
 static void vr_mii_statchg     __P((struct device *));
 
-static u_int8_t vr_calchash    __P((u_int8_t *));
 static void vr_setmulti                __P((struct vr_softc *));
 static void vr_reset           __P((struct vr_softc *));
 
@@ -431,34 +430,8 @@
                VR_SETBIT16(sc, VR_COMMAND, VR_CMD_TX_ON|VR_CMD_RX_ON);
 }
 
-/*
- * Calculate CRC of a multicast group address, return the lower 6 bits.
- */
-static u_int8_t
-vr_calchash(addr)
-       u_int8_t *addr;
-{
-       u_int32_t crc, carry;
-       int i, j;
-       u_int8_t c;
-
-       /* Compute CRC for the address value. */
-       crc = 0xFFFFFFFF; /* initial value */
-
-       for (i = 0; i < 6; i++) {
-               c = *(addr + i);
-               for (j = 0; j < 8; j++) {
-                       carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01);
-                       crc <<= 1;
-                       c >>= 1;
-                       if (carry)
-                               crc = (crc ^ 0x04c11db6) | carry;
-               }
-       }
-
-       /* return the filter bit position */
-       return ((crc >> 26) & 0x0000003F);
-}
+#define        vr_calchash(addr) \
+       (ether_crc32_be((addr), ETHER_ADDR_LEN) >> 26)
 
 /*
  * Program the 64-bit multicast hash filter.



Home | Main Index | Thread Index | Old Index