Deleted Added
full compact
if_nge.c (129879) if_nge.c (130270)
1/*
2 * Copyright (c) 2001 Wind River Systems
3 * Copyright (c) 1997, 1998, 1999, 2000, 2001
4 * Bill Paul <wpaul@bsdi.com>. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 18 unchanged lines hidden (view full) ---

27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
1/*
2 * Copyright (c) 2001 Wind River Systems
3 * Copyright (c) 1997, 1998, 1999, 2000, 2001
4 * Bill Paul <wpaul@bsdi.com>. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 18 unchanged lines hidden (view full) ---

27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/dev/nge/if_nge.c 129879 2004-05-30 20:08:47Z phk $");
35__FBSDID("$FreeBSD: head/sys/dev/nge/if_nge.c 130270 2004-06-09 14:34:04Z naddy $");
36
37/*
38 * National Semiconductor DP83820/DP83821 gigabit ethernet driver
39 * for FreeBSD. Datasheets are available from:
40 *
41 * http://www.national.com/ds/DP/DP83820.pdf
42 * http://www.national.com/ds/DP/DP83821.pdf
43 *

--- 136 unchanged lines hidden (view full) ---

180static int nge_mii_readreg(struct nge_softc *, struct nge_mii_frame *);
181static int nge_mii_writereg(struct nge_softc *, struct nge_mii_frame *);
182
183static int nge_miibus_readreg(device_t, int, int);
184static int nge_miibus_writereg(device_t, int, int, int);
185static void nge_miibus_statchg(device_t);
186
187static void nge_setmulti(struct nge_softc *);
36
37/*
38 * National Semiconductor DP83820/DP83821 gigabit ethernet driver
39 * for FreeBSD. Datasheets are available from:
40 *
41 * http://www.national.com/ds/DP/DP83820.pdf
42 * http://www.national.com/ds/DP/DP83821.pdf
43 *

--- 136 unchanged lines hidden (view full) ---

180static int nge_mii_readreg(struct nge_softc *, struct nge_mii_frame *);
181static int nge_mii_writereg(struct nge_softc *, struct nge_mii_frame *);
182
183static int nge_miibus_readreg(device_t, int, int);
184static int nge_miibus_writereg(device_t, int, int, int);
185static void nge_miibus_statchg(device_t);
186
187static void nge_setmulti(struct nge_softc *);
188static uint32_t nge_mchash(const uint8_t *);
189static void nge_reset(struct nge_softc *);
190static int nge_list_rx_init(struct nge_softc *);
191static int nge_list_tx_init(struct nge_softc *);
192
193#ifdef NGE_USEIOSPACE
194#define NGE_RES SYS_RES_IOPORT
195#define NGE_RID NGE_PCI_LOIO
196#else

--- 470 unchanged lines hidden (view full) ---

667 NGE_SETBIT(sc, NGE_CFG, NGE_CFG_MODE_1000);
668 } else {
669 NGE_CLRBIT(sc, NGE_CFG, NGE_CFG_MODE_1000);
670 }
671 }
672 return;
673}
674
188static void nge_reset(struct nge_softc *);
189static int nge_list_rx_init(struct nge_softc *);
190static int nge_list_tx_init(struct nge_softc *);
191
192#ifdef NGE_USEIOSPACE
193#define NGE_RES SYS_RES_IOPORT
194#define NGE_RID NGE_PCI_LOIO
195#else

--- 470 unchanged lines hidden (view full) ---

666 NGE_SETBIT(sc, NGE_CFG, NGE_CFG_MODE_1000);
667 } else {
668 NGE_CLRBIT(sc, NGE_CFG, NGE_CFG_MODE_1000);
669 }
670 }
671 return;
672}
673
675static u_int32_t
676nge_mchash(addr)
677 const uint8_t *addr;
678{
679 uint32_t crc, carry;
680 int idx, bit;
681 uint8_t data;
682
683 /* Compute CRC for the address value. */
684 crc = 0xFFFFFFFF; /* initial value */
685
686 for (idx = 0; idx < 6; idx++) {
687 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) {
688 carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01);
689 crc <<= 1;
690 if (carry)
691 crc = (crc ^ 0x04c11db6) | carry;
692 }
693 }
694
695 /*
696 * return the filter bit position
697 */
698
699 return((crc >> 21) & 0x00000FFF);
700}
701
702static void
703nge_setmulti(sc)
704 struct nge_softc *sc;
705{
706 struct ifnet *ifp;
707 struct ifmultiaddr *ifma;
708 u_int32_t h = 0, i, filtsave;
709 int bit, index;

--- 29 unchanged lines hidden (view full) ---

739 * From the 11 bits returned by the crc routine, the top 7
740 * bits represent the 16-bit word in the mcast hash table
741 * that needs to be updated, and the lower 4 bits represent
742 * which bit within that byte needs to be set.
743 */
744 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
745 if (ifma->ifma_addr->sa_family != AF_LINK)
746 continue;
674static void
675nge_setmulti(sc)
676 struct nge_softc *sc;
677{
678 struct ifnet *ifp;
679 struct ifmultiaddr *ifma;
680 u_int32_t h = 0, i, filtsave;
681 int bit, index;

--- 29 unchanged lines hidden (view full) ---

711 * From the 11 bits returned by the crc routine, the top 7
712 * bits represent the 16-bit word in the mcast hash table
713 * that needs to be updated, and the lower 4 bits represent
714 * which bit within that byte needs to be set.
715 */
716 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
717 if (ifma->ifma_addr->sa_family != AF_LINK)
718 continue;
747 h = nge_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
719 h = ether_crc32_be(LLADDR((struct sockaddr_dl *)
720 ifma->ifma_addr), ETHER_ADDR_LEN) >> 21;
748 index = (h >> 4) & 0x7F;
749 bit = h & 0xF;
750 CSR_WRITE_4(sc, NGE_RXFILT_CTL,
751 NGE_FILTADDR_MCAST_LO + (index * 2));
752 NGE_SETBIT(sc, NGE_RXFILT_DATA, (1 << bit));
753 }
754
755 CSR_WRITE_4(sc, NGE_RXFILT_CTL, filtsave);

--- 1533 unchanged lines hidden ---
721 index = (h >> 4) & 0x7F;
722 bit = h & 0xF;
723 CSR_WRITE_4(sc, NGE_RXFILT_CTL,
724 NGE_FILTADDR_MCAST_LO + (index * 2));
725 NGE_SETBIT(sc, NGE_RXFILT_DATA, (1 << bit));
726 }
727
728 CSR_WRITE_4(sc, NGE_RXFILT_CTL, filtsave);

--- 1533 unchanged lines hidden ---