Optimize the address CRC routines a bit.

This commit is contained in:
mycroft 1998-03-29 22:08:03 +00:00
parent 2ad26b801c
commit fe7f32954b
3 changed files with 15 additions and 15 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: am7990.c,v 1.40 1998/01/12 09:23:14 thorpej Exp $ */
/* $NetBSD: am7990.c,v 1.41 1998/03/29 22:08:03 mycroft Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -1175,7 +1175,7 @@ am7990_setladrf(ac, af)
{
struct ifnet *ifp = &ac->ec_if;
struct ether_multi *enm;
register u_char *cp, c;
register u_char *cp;
register u_int32_t crc;
register int i, len;
struct ether_multistep step;
@ -1209,14 +1209,13 @@ am7990_setladrf(ac, af)
cp = enm->enm_addrlo;
crc = 0xffffffff;
for (len = sizeof(enm->enm_addrlo); --len >= 0;) {
c = *cp++;
crc ^= (*cp++) << 0;
for (i = 8; --i >= 0;) {
if ((crc & 0x01) ^ (c & 0x01)) {
if (crc & 0x01) {
crc >>= 1;
crc ^= 0xedb88320;
} else
crc >>= 1;
c >>= 1;
}
}
/* Just want the 6 most significant bits. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: lemac.c,v 1.3 1998/01/12 09:23:28 thorpej Exp $ */
/* $NetBSD: lemac.c,v 1.4 1998/03/29 22:08:03 mycroft Exp $ */
/*-
* Copyright (c) 1994, 1995, 1997 Matt Thomas <matt@3am-software.com>
@ -458,11 +458,13 @@ lemac_multicast_op(
const u_char *mca,
int enable)
{
u_int idx, bit, data, crc = 0xFFFFFFFFUL;
u_int idx, bit, crc = 0xFFFFFFFFUL;
for (idx = 0; idx < 6; idx++)
for (data = *mca++, bit = 0; bit < 8; bit++, data >>= 1)
crc = (crc >> 1) ^ (((crc ^ data) & 1) ? LEMAC_CRC32_POLY : 0);
for (idx = 0; idx < 6; idx++) {
crc ^= (*mca++) << 0;
for (bit = 0; bit < 8; bit++)
crc = (crc >> 1) ^ ((crc & 1) ? LEMAC_CRC32_POLY : 0);
}
/*
* The following two lines convert the N bit index into a longword index
* and a longword mask.

View File

@ -1,4 +1,4 @@
/* $NetBSD: mb86960.c,v 1.21 1998/03/22 04:25:36 enami Exp $ */
/* $NetBSD: mb86960.c,v 1.22 1998/03/29 22:08:03 mycroft Exp $ */
/*
* All Rights Reserved, Copyright (C) Fujitsu Limited 1995
@ -1557,7 +1557,7 @@ mb86960_getmcaf(ec, af)
{
struct ifnet *ifp = &ec->ec_if;
struct ether_multi *enm;
register u_char *cp, c;
register u_char *cp;
register u_long crc;
register int i, len;
struct ether_multistep step;
@ -1592,14 +1592,13 @@ mb86960_getmcaf(ec, af)
cp = enm->enm_addrlo;
crc = 0xffffffff;
for (len = sizeof(enm->enm_addrlo); --len >= 0;) {
c = *cp++;
crc ^= (*cp++) << 0;
for (i = 8; --i >= 0;) {
if ((crc & 0x01) ^ (c & 0x01)) {
if (crc & 0x01) {
crc >>= 1;
crc ^= 0xedb88320;
} else
crc >>= 1;
c >>= 1;
}
}
/* Just want the 6 most significant bits. */