Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Use ether_crc32_be().



details:   https://anonhg.NetBSD.org/src/rev/a12ec372335f
branches:  trunk
changeset: 486066:a12ec372335f
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri May 12 16:44:19 2000 +0000

description:
Use ether_crc32_be().

diffstat:

 sys/dev/ic/dp8390.c  |  21 +++++----------------
 sys/dev/ic/elinkxl.c |  33 ++-------------------------------
 sys/dev/ic/rtl81x9.c |  32 +++-----------------------------
 3 files changed, 10 insertions(+), 76 deletions(-)

diffs (150 lines):

diff -r 1fa4fe4442a8 -r a12ec372335f sys/dev/ic/dp8390.c
--- a/sys/dev/ic/dp8390.c       Fri May 12 16:42:41 2000 +0000
+++ b/sys/dev/ic/dp8390.c       Fri May 12 16:44:19 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dp8390.c,v 1.35 2000/03/22 20:58:28 ws Exp $   */
+/*     $NetBSD: dp8390.c,v 1.36 2000/05/12 16:44:19 thorpej Exp $      */
 
 /*
  * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
@@ -1037,9 +1037,8 @@
 {
        struct ifnet *ifp = &ec->ec_if;
        struct ether_multi *enm;
-       u_int8_t *cp, c;
        u_int32_t crc;
-       int i, len;
+       int i;
        struct ether_multistep step;
 
        /*
@@ -1075,19 +1074,9 @@
                                af[i] = 0xff;
                        return;
                }
-               cp = enm->enm_addrlo;
-               crc = 0xffffffff;
-               for (len = sizeof(enm->enm_addrlo); --len >= 0;) {
-                       c = *cp++;
-                       for (i = 8; --i >= 0;) {
-                               if (((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01)) {
-                                       crc <<= 1;
-                                       crc ^= 0x04c11db6 | 1;
-                               } else
-                                       crc <<= 1;
-                               c >>= 1;
-                       }
-               }
+
+               crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
+
                /* Just want the 6 most significant bits. */
                crc >>= 26;
 
diff -r 1fa4fe4442a8 -r a12ec372335f sys/dev/ic/elinkxl.c
--- a/sys/dev/ic/elinkxl.c      Fri May 12 16:42:41 2000 +0000
+++ b/sys/dev/ic/elinkxl.c      Fri May 12 16:44:19 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elinkxl.c,v 1.32 2000/05/12 15:22:33 tsutsui Exp $     */
+/*     $NetBSD: elinkxl.c,v 1.33 2000/05/12 16:44:19 thorpej Exp $     */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -124,7 +124,6 @@
 static void ex_shutdown __P((void *));
 static void ex_start __P((struct ifnet *));
 static void ex_txstat __P((struct ex_softc *));
-static u_int16_t ex_mchash __P((u_char *));
 
 int ex_mii_readreg __P((struct device *, int, int));
 void ex_mii_writereg __P((struct device *, int, int, int));
@@ -668,35 +667,7 @@
        callout_reset(&sc->ex_mii_callout, hz, ex_tick, sc);
 }
 
-/*
- * Multicast hash filter according to the 3Com spec.
- */
-static u_int16_t
-ex_mchash(addr)
-       u_char *addr;
-{
-       u_int32_t crc, carry;
-       int i, j;
-       u_char 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 & 0x000000ff);
-}
-
+#define        ex_mchash(addr) (ether_crc32_be((addr), ETHER_ADDR_LEN) & 0xff)
 
 /*
  * Set multicast receive filter. Also take care of promiscuous mode
diff -r 1fa4fe4442a8 -r a12ec372335f sys/dev/ic/rtl81x9.c
--- a/sys/dev/ic/rtl81x9.c      Fri May 12 16:42:41 2000 +0000
+++ b/sys/dev/ic/rtl81x9.c      Fri May 12 16:44:19 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtl81x9.c,v 1.6 2000/05/01 15:08:55 tsutsui Exp $      */
+/*     $NetBSD: rtl81x9.c,v 1.7 2000/05/12 16:44:20 thorpej Exp $      */
 
 /*
  * Copyright (c) 1997, 1998
@@ -169,7 +169,6 @@
 STATIC void rl_phy_statchg     __P((struct device *));
 STATIC void rl_tick __P((void *));
 
-STATIC u_int8_t rl_calchash    __P((caddr_t));
 STATIC void rl_setmulti                __P((struct rl_softc *));
 STATIC int rl_list_tx_init     __P((struct rl_softc *));
 
@@ -551,33 +550,8 @@
        /* Nothing to do. */
 }
 
-/*
- * Calculate CRC of a multicast group address, return the upper 6 bits.
- */
-STATIC u_int8_t rl_calchash(addr)
-       caddr_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);
-}
+#define        rl_calchash(addr) \
+       (ether_crc32_be((addr), ETHER_ADDR_LEN) >> 26)
 
 /*
  * Program the 64-bit multicast hash filter.



Home | Main Index | Thread Index | Old Index