Use ether_crc32_be().
This commit is contained in:
parent
288883fca7
commit
692e54c43d
|
@ -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 @@ dp8390_getmcaf(ec, af)
|
|||
{
|
||||
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 @@ dp8390_getmcaf(ec, af)
|
|||
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;
|
||||
|
||||
|
|
|
@ -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_init_txdescs __P((struct ex_softc *));
|
|||
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 @@ ex_init(sc)
|
|||
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
|
||||
|
|
|
@ -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_writereg __P((struct device *, int, int, int));
|
|||
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 @@ rl_phy_statchg(v)
|
|||
/* 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.
|
||||
|
|
Loading…
Reference in New Issue