Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/macppc/dev Use ether_crc32_le().



details:   https://anonhg.NetBSD.org/src/rev/fb6522ac0d9c
branches:  trunk
changeset: 487998:fb6522ac0d9c
user:      tsubai <tsubai%NetBSD.org@localhost>
date:      Fri Jun 16 14:18:55 2000 +0000

description:
Use ether_crc32_le().

diffstat:

 sys/arch/macppc/dev/if_bm.c |  55 +++++++++++++++-----------------------------
 sys/arch/macppc/dev/if_gm.c |  22 ++---------------
 2 files changed, 22 insertions(+), 55 deletions(-)

diffs (155 lines):

diff -r 75721b590c7f -r fb6522ac0d9c sys/arch/macppc/dev/if_bm.c
--- a/sys/arch/macppc/dev/if_bm.c       Fri Jun 16 11:47:34 2000 +0000
+++ b/sys/arch/macppc/dev/if_bm.c       Fri Jun 16 14:18:55 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_bm.c,v 1.8 2000/04/07 14:35:58 tsubai Exp $ */
+/*     $NetBSD: if_bm.c,v 1.9 2000/06/16 14:18:55 tsubai Exp $ */
 
 /*-
  * Copyright (C) 1998, 1999, 2000 Tsubai Masanari.  All rights reserved.
@@ -849,9 +849,6 @@
        ifmr->ifm_active = sc->sc_mii.mii_media_active;
 }
 
-#define MC_POLY_BE 0x04c11db7UL                /* mcast crc, big endian */
-#define MC_POLY_LE 0xedb88320UL                /* mcast crc, little endian */
-
 /*
  * Set up the logical address filter.
  */
@@ -862,10 +859,8 @@
        struct ifnet *ifp = &sc->sc_if;
        struct ether_multi *enm;
        struct ether_multistep step;
-       int i, j;
        u_int32_t crc;
        u_int16_t hash[4];
-       u_int8_t octet;
 
        /*
         * Set up multicast address filter by passing all multicast addresses
@@ -875,15 +870,18 @@
         * the word.
         */
 
-       if (ifp->if_flags & IFF_ALLMULTI)
-               goto allmulti;
-
        if (ifp->if_flags & IFF_PROMISC) {
                bmac_set_bits(sc, RXCFG, RxPromiscEnable);
-               goto allmulti;
+               return;
+       }
+
+       if (ifp->if_flags & IFF_ALLMULTI) {
+               hash[3] = hash[2] = hash[1] = hash[0] = 0xffff;
+               goto chipit;
        }
 
        hash[3] = hash[2] = hash[1] = hash[0] = 0;
+
        ETHER_FIRST_MULTI(step, &sc->sc_ethercom, enm);
        while (enm != NULL) {
                if (bcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
@@ -895,23 +893,12 @@
                         * ranges is for IP multicast routing, for which the
                         * range is big enough to require all bits set.)
                         */
-                       goto allmulti;
+                       hash[3] = hash[2] = hash[1] = hash[0] = 0xffff;
+                       ifp->if_flags |= IFF_ALLMULTI;
+                       goto chipit;
                }
 
-               crc = 0xffffffff;
-               for (i = 0; i < ETHER_ADDR_LEN; i++) {
-                       octet = enm->enm_addrlo[i];
-
-                       for (j = 0; j < 8; j++) {
-                               if ((crc & 1) ^ (octet & 1)) {
-                                       crc >>= 1;
-                                       crc ^= MC_POLY_LE;
-                               }
-                               else
-                                       crc >>= 1;
-                               octet >>= 1;
-                       }
-               }
+               crc = ether_crc32_le(enm->enm_addrlo, ETHER_ADDR_LEN);
 
                /* Just want the 6 most significant bits. */
                crc >>= 26;
@@ -921,19 +908,15 @@
 
                ETHER_NEXT_MULTI(step, enm);
        }
-       bmac_write_reg(sc, HASH3, hash[3]);
-       bmac_write_reg(sc, HASH2, hash[2]);
-       bmac_write_reg(sc, HASH1, hash[1]);
-       bmac_write_reg(sc, HASH0, hash[0]);
+
        ifp->if_flags &= ~IFF_ALLMULTI;
-       return;
 
-allmulti:
-       ifp->if_flags |= IFF_ALLMULTI;
-       bmac_write_reg(sc, HASH3, 0xffff);
-       bmac_write_reg(sc, HASH2, 0xffff);
-       bmac_write_reg(sc, HASH1, 0xffff);
-       bmac_write_reg(sc, HASH0, 0xffff);
+chipit:
+       bmac_write_reg(sc, HASH0, hash[0]);
+       bmac_write_reg(sc, HASH1, hash[1]);
+       bmac_write_reg(sc, HASH2, hash[2]);
+       bmac_write_reg(sc, HASH3, hash[3]);
+       /* bmac_set_bits(sc, RXCFG, RxHashFilterEnable); */
 }
 
 int
diff -r 75721b590c7f -r fb6522ac0d9c sys/arch/macppc/dev/if_gm.c
--- a/sys/arch/macppc/dev/if_gm.c       Fri Jun 16 11:47:34 2000 +0000
+++ b/sys/arch/macppc/dev/if_gm.c       Fri Jun 16 14:18:55 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_gm.c,v 1.6 2000/06/15 18:36:52 tsubai Exp $ */
+/*     $NetBSD: if_gm.c,v 1.7 2000/06/16 14:18:56 tsubai Exp $ */
 
 /*-
  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
@@ -671,11 +671,10 @@
        struct ether_multi *enm;
        struct ether_multistep step;
        struct ethercom *ec = &sc->sc_ethercom;
-       u_char *cp;
        u_int32_t crc;
        u_int32_t hash[16];
        u_int v;
-       int len, i;
+       int i;
 
        /* Clear hash table */
        for (i = 0; i < 16; i++)
@@ -721,23 +720,8 @@
                        goto chipit;
                }
 
-               cp = enm->enm_addrlo;
-               crc = 0xffffffff;
-               for (len = sizeof(enm->enm_addrlo); --len >= 0;) {
-                       int octet = *cp++;
-                       int i;
+               crc = ether_crc32_le(enm->enm_addrlo, ETHER_ADDR_LEN);
 
-#define MC_POLY_LE     0xedb88320UL    /* mcast crc, little endian */
-                       for (i = 0; i < 8; i++) {
-                               if ((crc & 1) ^ (octet & 1)) {
-                                       crc >>= 1;
-                                       crc ^= MC_POLY_LE;
-                               } else {
-                                       crc >>= 1;
-                               }
-                               octet >>= 1;
-                       }
-               }
                /* Just want the 8 most significant bits. */
                crc >>= 24;
 



Home | Main Index | Thread Index | Old Index