Deleted Added
full compact
if_pcn.c (129878) if_pcn.c (130270)
1/*
2 * Copyright (c) 2000 Berkeley Software Design, Inc.
3 * Copyright (c) 1997, 1998, 1999, 2000
4 * Bill Paul <wpaul@osd.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) 2000 Berkeley Software Design, Inc.
3 * Copyright (c) 1997, 1998, 1999, 2000
4 * Bill Paul <wpaul@osd.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/pci/if_pcn.c 129878 2004-05-30 20:00:41Z phk $");
35__FBSDID("$FreeBSD: head/sys/pci/if_pcn.c 130270 2004-06-09 14:34:04Z naddy $");
36
37/*
38 * AMD Am79c972 fast ethernet PCI NIC driver. Datatheets are available
39 * from http://www.amd.com.
40 *
41 * The AMD PCnet/PCI controllers are more advanced and functional
42 * versions of the venerable 7990 LANCE. The PCnet/PCI chips retain
43 * backwards compatibility with the LANCE and thus can be made

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

132static void pcn_ifmedia_sts (struct ifnet *, struct ifmediareq *);
133
134static int pcn_miibus_readreg (device_t, int, int);
135static int pcn_miibus_writereg (device_t, int, int, int);
136static void pcn_miibus_statchg (device_t);
137
138static void pcn_setfilt (struct ifnet *);
139static void pcn_setmulti (struct pcn_softc *);
36
37/*
38 * AMD Am79c972 fast ethernet PCI NIC driver. Datatheets are available
39 * from http://www.amd.com.
40 *
41 * The AMD PCnet/PCI controllers are more advanced and functional
42 * versions of the venerable 7990 LANCE. The PCnet/PCI chips retain
43 * backwards compatibility with the LANCE and thus can be made

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

132static void pcn_ifmedia_sts (struct ifnet *, struct ifmediareq *);
133
134static int pcn_miibus_readreg (device_t, int, int);
135static int pcn_miibus_writereg (device_t, int, int, int);
136static void pcn_miibus_statchg (device_t);
137
138static void pcn_setfilt (struct ifnet *);
139static void pcn_setmulti (struct pcn_softc *);
140static uint32_t pcn_mchash (const uint8_t *);
141static void pcn_reset (struct pcn_softc *);
142static int pcn_list_rx_init (struct pcn_softc *);
143static int pcn_list_tx_init (struct pcn_softc *);
144
145#ifdef PCN_USEIOSPACE
146#define PCN_RES SYS_RES_IOPORT
147#define PCN_RID PCN_PCI_LOIO
148#else

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

302 PCN_BCR_SETBIT(sc, PCN_BCR_DUPLEX, PCN_DUPLEX_FDEN);
303 } else {
304 PCN_BCR_CLRBIT(sc, PCN_BCR_DUPLEX, PCN_DUPLEX_FDEN);
305 }
306
307 return;
308}
309
140static void pcn_reset (struct pcn_softc *);
141static int pcn_list_rx_init (struct pcn_softc *);
142static int pcn_list_tx_init (struct pcn_softc *);
143
144#ifdef PCN_USEIOSPACE
145#define PCN_RES SYS_RES_IOPORT
146#define PCN_RID PCN_PCI_LOIO
147#else

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

301 PCN_BCR_SETBIT(sc, PCN_BCR_DUPLEX, PCN_DUPLEX_FDEN);
302 } else {
303 PCN_BCR_CLRBIT(sc, PCN_BCR_DUPLEX, PCN_DUPLEX_FDEN);
304 }
305
306 return;
307}
308
310#define DC_POLY 0xEDB88320
311
312static u_int32_t
313pcn_mchash(addr)
314 const uint8_t *addr;
315{
316 uint32_t crc;
317 int idx, bit;
318 uint8_t data;
319
320 /* Compute CRC for the address value. */
321 crc = 0xFFFFFFFF; /* initial value */
322
323 for (idx = 0; idx < 6; idx++) {
324 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1)
325 crc = (crc >> 1) ^ (((crc ^ data) & 1) ? DC_POLY : 0);
326 }
327
328 return ((crc >> 26) & 0x3F);
329}
330
331static void
332pcn_setmulti(sc)
333 struct pcn_softc *sc;
334{
335 struct ifnet *ifp;
336 struct ifmultiaddr *ifma;
337 u_int32_t h, i;
338 u_int16_t hashes[4] = { 0, 0, 0, 0 };

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

351 /* first, zot all the existing hash bits */
352 for (i = 0; i < 4; i++)
353 pcn_csr_write(sc, PCN_CSR_MAR0 + i, 0);
354
355 /* now program new ones */
356 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
357 if (ifma->ifma_addr->sa_family != AF_LINK)
358 continue;
309static void
310pcn_setmulti(sc)
311 struct pcn_softc *sc;
312{
313 struct ifnet *ifp;
314 struct ifmultiaddr *ifma;
315 u_int32_t h, i;
316 u_int16_t hashes[4] = { 0, 0, 0, 0 };

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

329 /* first, zot all the existing hash bits */
330 for (i = 0; i < 4; i++)
331 pcn_csr_write(sc, PCN_CSR_MAR0 + i, 0);
332
333 /* now program new ones */
334 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
335 if (ifma->ifma_addr->sa_family != AF_LINK)
336 continue;
359 h = pcn_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
337 h = ether_crc32_le(LLADDR((struct sockaddr_dl *)
338 ifma->ifma_addr), ETHER_ADDR_LEN) >> 26;
360 hashes[h >> 4] |= 1 << (h & 0xF);
361 }
362
363 for (i = 0; i < 4; i++)
364 pcn_csr_write(sc, PCN_CSR_MAR0 + i, hashes[i]);
365
366 PCN_CSR_CLRBIT(sc, PCN_CSR_EXTCTL1, PCN_EXTCTL1_SPND);
367

--- 1071 unchanged lines hidden ---
339 hashes[h >> 4] |= 1 << (h & 0xF);
340 }
341
342 for (i = 0; i < 4; i++)
343 pcn_csr_write(sc, PCN_CSR_MAR0 + i, hashes[i]);
344
345 PCN_CSR_CLRBIT(sc, PCN_CSR_EXTCTL1, PCN_EXTCTL1_SPND);
346

--- 1071 unchanged lines hidden ---