if_fe.c (121816) | if_fe.c (122625) |
---|---|
1/* 2 * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 3 * 4 * This software may be used, modified, copied, distributed, and sold, in 5 * both source and binary form provided that the above copyright, these 6 * terms and the following disclaimer are retained. The name of the author 7 * and/or the contributor may not be used to endorse or promote products 8 * derived from this software without specific prior written permission. --- 7 unchanged lines hidden (view full) --- 16 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION. 17 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 18 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 19 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 20 * SUCH DAMAGE. 21 */ 22 23#include <sys/cdefs.h> | 1/* 2 * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 3 * 4 * This software may be used, modified, copied, distributed, and sold, in 5 * both source and binary form provided that the above copyright, these 6 * terms and the following disclaimer are retained. The name of the author 7 * and/or the contributor may not be used to endorse or promote products 8 * derived from this software without specific prior written permission. --- 7 unchanged lines hidden (view full) --- 16 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION. 17 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 18 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 19 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 20 * SUCH DAMAGE. 21 */ 22 23#include <sys/cdefs.h> |
24__FBSDID("$FreeBSD: head/sys/dev/fe/if_fe.c 121816 2003-10-31 18:32:15Z brooks $"); | 24__FBSDID("$FreeBSD: head/sys/dev/fe/if_fe.c 122625 2003-11-13 20:55:53Z obrien $"); |
25 26/* 27 * 28 * Device driver for Fujitsu MB86960A/MB86965A based Ethernet cards. 29 * Contributed by M. Sekiguchi. <seki@sysrap.cs.fujitsu.co.jp> 30 * 31 * This version is intended to be a generic template for various 32 * MB86960A/MB86965A based Ethernet cards. It currently supports --- 2008 unchanged lines hidden (view full) --- 2041 (ETHER_MIN_LEN - ETHER_CRC_LEN - length) >> 1); 2042 } 2043 } 2044} 2045 2046/* 2047 * Compute hash value for an Ethernet address 2048 */ | 25 26/* 27 * 28 * Device driver for Fujitsu MB86960A/MB86965A based Ethernet cards. 29 * Contributed by M. Sekiguchi. <seki@sysrap.cs.fujitsu.co.jp> 30 * 31 * This version is intended to be a generic template for various 32 * MB86960A/MB86965A based Ethernet cards. It currently supports --- 2008 unchanged lines hidden (view full) --- 2041 (ETHER_MIN_LEN - ETHER_CRC_LEN - length) >> 1); 2042 } 2043 } 2044} 2045 2046/* 2047 * Compute hash value for an Ethernet address 2048 */ |
2049static int 2050fe_hash ( u_char * ep ) | 2049static u_int32_t 2050fe_mchash (caddr_t addr) |
2051{ | 2051{ |
2052#define FE_HASH_MAGIC_NUMBER 0xEDB88320L | 2052#define FE_POLY 0xEDB88320L |
2053 | 2053 |
2054 u_long hash = 0xFFFFFFFFL; 2055 int i, j; 2056 u_char b; 2057 u_long m; | 2054 u_long carry, crc = 0xFFFFFFFFL; 2055 int idx, bit; 2056 u_int8_t data; |
2058 | 2057 |
2059 for ( i = ETHER_ADDR_LEN; --i >= 0; ) { 2060 b = *ep++; 2061 for ( j = 8; --j >= 0; ) { 2062 m = hash; 2063 hash >>= 1; 2064 if ( ( m ^ b ) & 1 ) hash ^= FE_HASH_MAGIC_NUMBER; 2065 b >>= 1; | 2058 for ( idx = ETHER_ADDR_LEN; --idx >= 0; ) { 2059 for (data = *addr++, bit = 8; --bit >= 0; data >>= 1) { 2060 carry = crc; 2061 crc >>= 1; 2062 if ((carry ^ data) & 1) 2063 crc ^= FE_POLY; |
2066 } 2067 } | 2064 } 2065 } |
2068 return ( ( int )( hash >> 26 ) ); | 2066 return (crc >> 26); |
2069} 2070 2071/* 2072 * Compute the multicast address filter from the 2073 * list of multicast addresses we need to listen to. 2074 */ 2075static struct fe_filter 2076fe_mcaf ( struct fe_softc *sc ) 2077{ 2078 int index; 2079 struct fe_filter filter; 2080 struct ifmultiaddr *ifma; 2081 2082 filter = fe_filter_nothing; 2083 TAILQ_FOREACH(ifma, &sc->arpcom.ac_if.if_multiaddrs, ifma_link) { 2084 if (ifma->ifma_addr->sa_family != AF_LINK) 2085 continue; | 2067} 2068 2069/* 2070 * Compute the multicast address filter from the 2071 * list of multicast addresses we need to listen to. 2072 */ 2073static struct fe_filter 2074fe_mcaf ( struct fe_softc *sc ) 2075{ 2076 int index; 2077 struct fe_filter filter; 2078 struct ifmultiaddr *ifma; 2079 2080 filter = fe_filter_nothing; 2081 TAILQ_FOREACH(ifma, &sc->arpcom.ac_if.if_multiaddrs, ifma_link) { 2082 if (ifma->ifma_addr->sa_family != AF_LINK) 2083 continue; |
2086 index = fe_hash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); | 2084 index = fe_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); |
2087#ifdef FE_DEBUG 2088 printf("%s: hash(%6D) == %d\n", 2089 sc->sc_xname, enm->enm_addrlo , ":", index); 2090#endif 2091 2092 filter.data[index >> 3] |= 1 << (index & 7); 2093 } 2094 return ( filter ); --- 161 unchanged lines hidden --- | 2085#ifdef FE_DEBUG 2086 printf("%s: hash(%6D) == %d\n", 2087 sc->sc_xname, enm->enm_addrlo , ":", index); 2088#endif 2089 2090 filter.data[index >> 3] |= 1 << (index & 7); 2091 } 2092 return ( filter ); --- 161 unchanged lines hidden --- |