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_le().



details:   https://anonhg.NetBSD.org/src/rev/a3d06b4cf355
branches:  trunk
changeset: 486067:a3d06b4cf355
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri May 12 16:45:42 2000 +0000

description:
Use ether_crc32_le().

diffstat:

 sys/dev/ic/lance.c     |  19 +++----------------
 sys/dev/ic/lemac.c     |  17 ++++-------------
 sys/dev/ic/mb86960.c   |  19 +++----------------
 sys/dev/ic/smc83c170.c |  19 +++----------------
 sys/dev/ic/tulip.c     |  43 ++++++++-----------------------------------
 5 files changed, 21 insertions(+), 96 deletions(-)

diffs (247 lines):

diff -r a12ec372335f -r a3d06b4cf355 sys/dev/ic/lance.c
--- a/sys/dev/ic/lance.c        Fri May 12 16:44:19 2000 +0000
+++ b/sys/dev/ic/lance.c        Fri May 12 16:45:42 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lance.c,v 1.11 2000/03/30 12:45:31 augustss Exp $      */
+/*     $NetBSD: lance.c,v 1.12 2000/05/12 16:45:42 thorpej Exp $       */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -717,15 +717,7 @@
 {
        struct ifnet *ifp = &ac->ec_if;
        struct ether_multi *enm;
-       u_char *cp;
        u_int32_t crc;
-       static const u_int32_t crctab[] = {
-               0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
-               0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
-               0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c,
-               0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c
-       };
-       int len;
        struct ether_multistep step;
 
        /*
@@ -754,13 +746,8 @@
                        goto allmulti;
                }
 
-               cp = enm->enm_addrlo;
-               crc = 0xffffffff;
-               for (len = sizeof(enm->enm_addrlo); --len >= 0;) {
-                       crc ^= *cp++;
-                       crc = (crc >> 4) ^ crctab[crc & 0xf];
-                       crc = (crc >> 4) ^ crctab[crc & 0xf];
-               }
+               crc = ether_crc32_le(enm->enm_addrlo, ETHER_ADDR_LEN);
+
                /* Just want the 6 most significant bits. */
                crc >>= 26;
 
diff -r a12ec372335f -r a3d06b4cf355 sys/dev/ic/lemac.c
--- a/sys/dev/ic/lemac.c        Fri May 12 16:44:19 2000 +0000
+++ b/sys/dev/ic/lemac.c        Fri May 12 16:45:42 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lemac.c,v 1.13 2000/03/06 21:02:01 thorpej Exp $ */
+/* $NetBSD: lemac.c,v 1.14 2000/05/12 16:45:42 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1994, 1995, 1997 Matt Thomas <matt%3am-software.com@localhost>
@@ -459,19 +459,10 @@
     const u_char *mca,
     int enable)
 {
-    u_int idx, bit, crc = 0xFFFFFFFFUL;
-    static const u_int crctab[] = {
-       0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
-       0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
-       0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c,
-       0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c
-    };
+    u_int idx, bit, crc;
 
-    for (idx = 0; idx < 6; idx++) {
-       crc ^= *mca++;
-       crc = (crc >> 4) ^ crctab[crc & 0xf];
-       crc = (crc >> 4) ^ crctab[crc & 0xf];
-    }
+    crc = ether_crc32_le(mca, ETHER_ADDR_LEN);
+
     /*
      * The following two lines convert the N bit index into a longword index
      * and a longword mask.  
diff -r a12ec372335f -r a3d06b4cf355 sys/dev/ic/mb86960.c
--- a/sys/dev/ic/mb86960.c      Fri May 12 16:44:19 2000 +0000
+++ b/sys/dev/ic/mb86960.c      Fri May 12 16:45:42 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mb86960.c,v 1.38 2000/03/30 12:45:31 augustss Exp $    */
+/*     $NetBSD: mb86960.c,v 1.39 2000/05/12 16:45:43 thorpej Exp $     */
 
 /*
  * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
@@ -1566,15 +1566,7 @@
 {
        struct ifnet *ifp = &ec->ec_if;
        struct ether_multi *enm;
-       u_char *cp;
        u_int32_t crc;
-       static const u_int32_t crctab[] = {
-               0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
-               0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
-               0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c,
-               0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c
-       };
-       int len;
        struct ether_multistep step;
 
        /*
@@ -1604,13 +1596,8 @@
                        goto allmulti;
                }
 
-               cp = enm->enm_addrlo;
-               crc = 0xffffffff;
-               for (len = sizeof(enm->enm_addrlo); --len >= 0;) {
-                       crc ^= *cp++;
-                       crc = (crc >> 4) ^ crctab[crc & 0xf];
-                       crc = (crc >> 4) ^ crctab[crc & 0xf];
-               }
+               crc = ether_crc32_le(enm->enm_addrlo, ETHER_ADDR_LEN);
+
                /* Just want the 6 most significant bits. */
                crc >>= 26;
 
diff -r a12ec372335f -r a3d06b4cf355 sys/dev/ic/smc83c170.c
--- a/sys/dev/ic/smc83c170.c    Fri May 12 16:44:19 2000 +0000
+++ b/sys/dev/ic/smc83c170.c    Fri May 12 16:45:42 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: smc83c170.c,v 1.29 2000/03/23 07:01:32 thorpej Exp $   */
+/*     $NetBSD: smc83c170.c,v 1.30 2000/05/12 16:45:43 thorpej Exp $   */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -1319,15 +1319,7 @@
        struct ifnet *ifp = &sc->sc_ethercom.ec_if;
        struct ether_multi *enm;
        struct ether_multistep step;
-       u_int8_t *cp;
        u_int32_t crc, mchash[4];
-       int len;
-       static const u_int32_t crctab[] = {
-               0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
-               0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
-               0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c,
-               0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c
-       };
 
        /*
         * Set up the multicast address filter by passing all multicast
@@ -1362,13 +1354,8 @@
                        goto allmulti;
                }
 
-               cp = enm->enm_addrlo;
-               crc = 0xffffffff;
-               for (len = sizeof(enm->enm_addrlo); --len >= 0;) {
-                       crc ^= *cp++;
-                       crc = (crc >> 4) ^ crctab[crc & 0xf];
-                       crc = (crc >> 4) ^ crctab[crc & 0xf];
-               }
+               crc = ether_crc32_le(enm->enm_addrlo, ETHER_ADDR_LEN);
+
                /* Just want the 6 most significant bits. */
                crc >>= 26;
 
diff -r a12ec372335f -r a3d06b4cf355 sys/dev/ic/tulip.c
--- a/sys/dev/ic/tulip.c        Fri May 12 16:44:19 2000 +0000
+++ b/sys/dev/ic/tulip.c        Fri May 12 16:45:42 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tulip.c,v 1.61 2000/04/07 18:58:15 thorpej Exp $       */
+/*     $NetBSD: tulip.c,v 1.62 2000/05/12 16:45:43 thorpej Exp $       */
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -151,8 +151,8 @@
 void   tlp_21142_reset __P((struct tulip_softc *));
 void   tlp_pmac_reset __P((struct tulip_softc *));
 
-u_int32_t tlp_crc32 __P((const u_int8_t *, size_t));
-#define        tlp_mchash(addr, sz) (tlp_crc32((addr), ETHER_ADDR_LEN) & ((sz) - 1))
+#define        tlp_mchash(addr, sz)                                            \
+       (ether_crc32_le((addr), ETHER_ADDR_LEN) & ((sz) - 1))
 
 /*
  * MII bit-bang glue.
@@ -2221,34 +2221,6 @@
 }
 
 /*
- * tlp_crc32:
- *
- *     Compute the 32-bit CRC of the provided buffer.
- */
-u_int32_t
-tlp_crc32(buf, len)
-       const u_int8_t *buf;
-       size_t len;
-{
-       static const u_int32_t crctab[] = {
-               0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
-               0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
-               0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c,
-               0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c
-       };
-       u_int32_t crc;
-       int i;
-
-       crc = 0xffffffff;
-       for (i = 0; i < len; i++) {
-               crc ^= buf[i];
-               crc = (crc >> 4) ^ crctab[crc & 0xf];
-               crc = (crc >> 4) ^ crctab[crc & 0xf];
-       }
-       return (crc);
-}
-
-/*
  * tlp_srom_crcok:
  *
  *     Check the CRC of the Tulip SROM.
@@ -2259,7 +2231,7 @@
 {
        u_int32_t crc;
 
-       crc = tlp_crc32(romdata, TULIP_ROM_CRC32_CHECKSUM);
+       crc = ether_crc32_le(romdata, TULIP_ROM_CRC32_CHECKSUM);
        crc = (crc & 0xffff) ^ 0xffff;
        if (crc == TULIP_ROM_GETW(romdata, TULIP_ROM_CRC32_CHECKSUM))
                return (1);
@@ -2267,7 +2239,7 @@
        /*
         * Try an alternate checksum.
         */
-       crc = tlp_crc32(romdata, TULIP_ROM_CRC32_CHECKSUM1);
+       crc = ether_crc32_le(romdata, TULIP_ROM_CRC32_CHECKSUM1);
        crc = (crc & 0xffff) ^ 0xffff;
        if (crc == TULIP_ROM_GETW(romdata, TULIP_ROM_CRC32_CHECKSUM1))
                return (1);
@@ -2756,7 +2728,8 @@
                 * According to the FreeBSD `wb' driver, yes, you
                 * really do invert the hash.
                 */
-               hash = (~(tlp_crc32(enm->enm_addrlo, ETHER_ADDR_LEN) >> 26))
+               hash =
+                   (~(ether_crc32_le(enm->enm_addrlo, ETHER_ADDR_LEN) >> 26))
                    & 0x3f;
                mchash[hash >> 5] |= 1 << (hash & 0x1f);
                ETHER_NEXT_MULTI(step, enm);
@@ -2819,7 +2792,7 @@
                        goto allmulti;
                }
 
-               hash = (tlp_crc32(enm->enm_addrlo, ETHER_ADDR_LEN) >> 26)
+               hash = (ether_crc32_le(enm->enm_addrlo, ETHER_ADDR_LEN) >> 26)
                    & 0x3f;
                mchash[hash >> 5] |= 1 << (hash & 0x1f);
                ETHER_NEXT_MULTI(step, enm);



Home | Main Index | Thread Index | Old Index