if_re.c (121939) | if_re.c (122625) |
---|---|
1/* 2 * Copyright (c) 1997, 1998-2003 3 * Bill Paul <wpaul@windriver.com>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 92 unchanged lines hidden (view full) --- 101 * interrupt moderation using the timer interrupt registers, which 102 * significantly reduces TX interrupt load. There is also support 103 * for jumbo frames, however the 8169/8169S/8110S can not transmit 104 * jumbo frames larger than 7.5K, so the max MTU possible with this 105 * driver is 7500 bytes. 106 */ 107 108#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1997, 1998-2003 3 * Bill Paul <wpaul@windriver.com>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 92 unchanged lines hidden (view full) --- 101 * interrupt moderation using the timer interrupt registers, which 102 * significantly reduces TX interrupt load. There is also support 103 * for jumbo frames, however the 8169/8169S/8110S can not transmit 104 * jumbo frames larger than 7.5K, so the max MTU possible with this 105 * driver is 7500 bytes. 106 */ 107 108#include <sys/cdefs.h> |
109__FBSDID("$FreeBSD: head/sys/dev/re/if_re.c 121939 2003-11-03 09:22:18Z dfr $"); | 109__FBSDID("$FreeBSD: head/sys/dev/re/if_re.c 122625 2003-11-13 20:55:53Z obrien $"); |
110 111#include <sys/param.h> 112#include <sys/endian.h> 113#include <sys/systm.h> 114#include <sys/sockio.h> 115#include <sys/mbuf.h> 116#include <sys/malloc.h> 117#include <sys/kernel.h> --- 102 unchanged lines hidden (view full) --- 220static void re_read_eeprom (struct rl_softc *, caddr_t, int, int, int); 221static int re_gmii_readreg (device_t, int, int); 222static int re_gmii_writereg (device_t, int, int, int); 223 224static int re_miibus_readreg (device_t, int, int); 225static int re_miibus_writereg (device_t, int, int, int); 226static void re_miibus_statchg (device_t); 227 | 110 111#include <sys/param.h> 112#include <sys/endian.h> 113#include <sys/systm.h> 114#include <sys/sockio.h> 115#include <sys/mbuf.h> 116#include <sys/malloc.h> 117#include <sys/kernel.h> --- 102 unchanged lines hidden (view full) --- 220static void re_read_eeprom (struct rl_softc *, caddr_t, int, int, int); 221static int re_gmii_readreg (device_t, int, int); 222static int re_gmii_writereg (device_t, int, int, int); 223 224static int re_miibus_readreg (device_t, int, int); 225static int re_miibus_writereg (device_t, int, int, int); 226static void re_miibus_statchg (device_t); 227 |
228static u_int8_t re_calchash (caddr_t); | 228static u_int32_t re_mchash (caddr_t); |
229static void re_setmulti (struct rl_softc *); 230static void re_reset (struct rl_softc *); 231 232static int re_diag (struct rl_softc *); 233 234#ifdef RE_USEIOSPACE 235#define RL_RES SYS_RES_IOPORT 236#define RL_RID RL_PCI_LOIO --- 332 unchanged lines hidden (view full) --- 569 device_t dev; 570{ 571 return; 572} 573 574/* 575 * Calculate CRC of a multicast group address, return the upper 6 bits. 576 */ | 229static void re_setmulti (struct rl_softc *); 230static void re_reset (struct rl_softc *); 231 232static int re_diag (struct rl_softc *); 233 234#ifdef RE_USEIOSPACE 235#define RL_RES SYS_RES_IOPORT 236#define RL_RID RL_PCI_LOIO --- 332 unchanged lines hidden (view full) --- 569 device_t dev; 570{ 571 return; 572} 573 574/* 575 * Calculate CRC of a multicast group address, return the upper 6 bits. 576 */ |
577static u_int8_t 578re_calchash(addr) 579 caddr_t addr; | 577static u_int32_t 578re_mchash(addr) 579 caddr_t addr; |
580{ | 580{ |
581 u_int32_t crc, carry; 582 int i, j; 583 u_int8_t c; | 581 u_int32_t crc, carry; 582 int idx, bit; 583 u_int8_t data; |
584 585 /* Compute CRC for the address value. */ 586 crc = 0xFFFFFFFF; /* initial value */ 587 | 584 585 /* Compute CRC for the address value. */ 586 crc = 0xFFFFFFFF; /* initial value */ 587 |
588 for (i = 0; i < 6; i++) { 589 c = *(addr + i); 590 for (j = 0; j < 8; j++) { 591 carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01); | 588 for (idx = 0; idx < 6; idx++) { 589 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) { 590 carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01); |
592 crc <<= 1; | 591 crc <<= 1; |
593 c >>= 1; | |
594 if (carry) 595 crc = (crc ^ 0x04c11db6) | carry; 596 } 597 } 598 599 /* return the filter bit position */ 600 return(crc >> 26); 601} --- 27 unchanged lines hidden (view full) --- 629 /* first, zot all the existing hash bits */ 630 CSR_WRITE_4(sc, RL_MAR0, 0); 631 CSR_WRITE_4(sc, RL_MAR4, 0); 632 633 /* now program new ones */ 634 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 635 if (ifma->ifma_addr->sa_family != AF_LINK) 636 continue; | 592 if (carry) 593 crc = (crc ^ 0x04c11db6) | carry; 594 } 595 } 596 597 /* return the filter bit position */ 598 return(crc >> 26); 599} --- 27 unchanged lines hidden (view full) --- 627 /* first, zot all the existing hash bits */ 628 CSR_WRITE_4(sc, RL_MAR0, 0); 629 CSR_WRITE_4(sc, RL_MAR4, 0); 630 631 /* now program new ones */ 632 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 633 if (ifma->ifma_addr->sa_family != AF_LINK) 634 continue; |
637 h = re_calchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); | 635 h = re_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); |
638 if (h < 32) 639 hashes[0] |= (1 << h); 640 else 641 hashes[1] |= (1 << (h - 32)); 642 mcnt++; 643 } 644 645 if (mcnt) --- 1842 unchanged lines hidden --- | 636 if (h < 32) 637 hashes[0] |= (1 << h); 638 else 639 hashes[1] |= (1 << (h - 32)); 640 mcnt++; 641 } 642 643 if (mcnt) --- 1842 unchanged lines hidden --- |