Deleted Added
full compact
if_bge.c (129879) if_bge.c (130270)
1/*
2 * Copyright (c) 2001 Wind River Systems
3 * Copyright (c) 1997, 1998, 1999, 2001
4 * Bill Paul <wpaul@windriver.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, 2001
4 * Bill Paul <wpaul@windriver.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/bge/if_bge.c 129879 2004-05-30 20:08:47Z phk $");
35__FBSDID("$FreeBSD: head/sys/dev/bge/if_bge.c 130270 2004-06-09 14:34:04Z naddy $");
36
37/*
38 * Broadcom BCM570x family gigabit ethernet driver for FreeBSD.
39 *
40 * The Broadcom BCM5700 is based on technology originally developed by
41 * Alteon Networks as part of the Tigon I and Tigon II gigabit ethernet
42 * MAC chips. The BCM5700, sometimes refered to as the Tigon III, has
43 * two on-board MIPS R4000 CPUs and can have as much as 16MB of external

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

206static void bge_watchdog (struct ifnet *);
207static void bge_shutdown (device_t);
208static int bge_ifmedia_upd (struct ifnet *);
209static void bge_ifmedia_sts (struct ifnet *, struct ifmediareq *);
210
211static u_int8_t bge_eeprom_getbyte (struct bge_softc *, int, u_int8_t *);
212static int bge_read_eeprom (struct bge_softc *, caddr_t, int, int);
213
36
37/*
38 * Broadcom BCM570x family gigabit ethernet driver for FreeBSD.
39 *
40 * The Broadcom BCM5700 is based on technology originally developed by
41 * Alteon Networks as part of the Tigon I and Tigon II gigabit ethernet
42 * MAC chips. The BCM5700, sometimes refered to as the Tigon III, has
43 * two on-board MIPS R4000 CPUs and can have as much as 16MB of external

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

206static void bge_watchdog (struct ifnet *);
207static void bge_shutdown (device_t);
208static int bge_ifmedia_upd (struct ifnet *);
209static void bge_ifmedia_sts (struct ifnet *, struct ifmediareq *);
210
211static u_int8_t bge_eeprom_getbyte (struct bge_softc *, int, u_int8_t *);
212static int bge_read_eeprom (struct bge_softc *, caddr_t, int, int);
213
214static uint32_t bge_mchash (const uint8_t *);
215static void bge_setmulti (struct bge_softc *);
216
217static void bge_handle_events (struct bge_softc *);
218static int bge_alloc_jumbo_mem (struct bge_softc *);
219static void bge_free_jumbo_mem (struct bge_softc *);
220static void *bge_jalloc (struct bge_softc *);
221static void bge_jfree (void *, void *);
222static int bge_newbuf_std (struct bge_softc *, int, struct mbuf *);

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

1128 CSR_WRITE_4(sc, BGE_MBX_TX_NIC_PROD0_LO, 0);
1129 /* 5700 b2 errata */
1130 if (sc->bge_chiprev == BGE_CHIPREV_5700_BX)
1131 CSR_WRITE_4(sc, BGE_MBX_TX_NIC_PROD0_LO, 0);
1132
1133 return(0);
1134}
1135
214static void bge_setmulti (struct bge_softc *);
215
216static void bge_handle_events (struct bge_softc *);
217static int bge_alloc_jumbo_mem (struct bge_softc *);
218static void bge_free_jumbo_mem (struct bge_softc *);
219static void *bge_jalloc (struct bge_softc *);
220static void bge_jfree (void *, void *);
221static int bge_newbuf_std (struct bge_softc *, int, struct mbuf *);

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

1127 CSR_WRITE_4(sc, BGE_MBX_TX_NIC_PROD0_LO, 0);
1128 /* 5700 b2 errata */
1129 if (sc->bge_chiprev == BGE_CHIPREV_5700_BX)
1130 CSR_WRITE_4(sc, BGE_MBX_TX_NIC_PROD0_LO, 0);
1131
1132 return(0);
1133}
1134
1136#define BGE_POLY 0xEDB88320
1137
1138static uint32_t
1139bge_mchash(addr)
1140 const uint8_t *addr;
1141{
1142 uint32_t crc;
1143 int idx, bit;
1144 uint8_t data;
1145
1146 /* Compute CRC for the address value. */
1147 crc = 0xFFFFFFFF; /* initial value */
1148
1149 for (idx = 0; idx < 6; idx++) {
1150 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1)
1151 crc = (crc >> 1) ^ (((crc ^ data) & 1) ? BGE_POLY : 0);
1152 }
1153
1154 return(crc & 0x7F);
1155}
1156
1157static void
1158bge_setmulti(sc)
1159 struct bge_softc *sc;
1160{
1161 struct ifnet *ifp;
1162 struct ifmultiaddr *ifma;
1163 u_int32_t hashes[4] = { 0, 0, 0, 0 };
1164 int h, i;

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

1176 /* First, zot all the existing filters. */
1177 for (i = 0; i < 4; i++)
1178 CSR_WRITE_4(sc, BGE_MAR0 + (i * 4), 0);
1179
1180 /* Now program new ones. */
1181 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
1182 if (ifma->ifma_addr->sa_family != AF_LINK)
1183 continue;
1135static void
1136bge_setmulti(sc)
1137 struct bge_softc *sc;
1138{
1139 struct ifnet *ifp;
1140 struct ifmultiaddr *ifma;
1141 u_int32_t hashes[4] = { 0, 0, 0, 0 };
1142 int h, i;

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

1154 /* First, zot all the existing filters. */
1155 for (i = 0; i < 4; i++)
1156 CSR_WRITE_4(sc, BGE_MAR0 + (i * 4), 0);
1157
1158 /* Now program new ones. */
1159 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
1160 if (ifma->ifma_addr->sa_family != AF_LINK)
1161 continue;
1184 h = bge_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
1162 h = ether_crc32_le(LLADDR((struct sockaddr_dl *)
1163 ifma->ifma_addr), ETHER_ADDR_LEN) & 0x7F;
1185 hashes[(h & 0x60) >> 5] |= 1 << (h & 0x1F);
1186 }
1187
1188 for (i = 0; i < 4; i++)
1189 CSR_WRITE_4(sc, BGE_MAR0 + (i * 4), hashes[i]);
1190
1191 return;
1192}

--- 2442 unchanged lines hidden ---
1164 hashes[(h & 0x60) >> 5] |= 1 << (h & 0x1F);
1165 }
1166
1167 for (i = 0; i < 4; i++)
1168 CSR_WRITE_4(sc, BGE_MAR0 + (i * 4), hashes[i]);
1169
1170 return;
1171}

--- 2442 unchanged lines hidden ---