Deleted Added
full compact
if_vr.c (121816) if_vr.c (122625)
1/*
2 * Copyright (c) 1997, 1998
3 * Bill Paul <wpaul@ctr.columbia.edu>. 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

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

53 * The Rhine has a serious flaw in its transmit DMA mechanism:
54 * transmit buffers must be longword aligned. Unfortunately,
55 * FreeBSD doesn't guarantee that mbufs will be filled in starting
56 * at longword boundaries, so we have to do a buffer copy before
57 * transmission.
58 */
59
60#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1997, 1998
3 * Bill Paul <wpaul@ctr.columbia.edu>. 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

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

53 * The Rhine has a serious flaw in its transmit DMA mechanism:
54 * transmit buffers must be longword aligned. Unfortunately,
55 * FreeBSD doesn't guarantee that mbufs will be filled in starting
56 * at longword boundaries, so we have to do a buffer copy before
57 * transmission.
58 */
59
60#include <sys/cdefs.h>
61__FBSDID("$FreeBSD: head/sys/dev/vr/if_vr.c 121816 2003-10-31 18:32:15Z brooks $");
61__FBSDID("$FreeBSD: head/sys/dev/vr/if_vr.c 122625 2003-11-13 20:55:53Z obrien $");
62
63#include <sys/param.h>
64#include <sys/systm.h>
65#include <sys/sockio.h>
66#include <sys/mbuf.h>
67#include <sys/malloc.h>
68#include <sys/kernel.h>
69#include <sys/socket.h>

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

156#endif
157static int vr_mii_readreg (struct vr_softc *, struct vr_mii_frame *);
158static int vr_mii_writereg (struct vr_softc *, struct vr_mii_frame *);
159static int vr_miibus_readreg (device_t, int, int);
160static int vr_miibus_writereg (device_t, int, int, int);
161static void vr_miibus_statchg (device_t);
162
163static void vr_setcfg (struct vr_softc *, int);
62
63#include <sys/param.h>
64#include <sys/systm.h>
65#include <sys/sockio.h>
66#include <sys/mbuf.h>
67#include <sys/malloc.h>
68#include <sys/kernel.h>
69#include <sys/socket.h>

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

156#endif
157static int vr_mii_readreg (struct vr_softc *, struct vr_mii_frame *);
158static int vr_mii_writereg (struct vr_softc *, struct vr_mii_frame *);
159static int vr_miibus_readreg (device_t, int, int);
160static int vr_miibus_writereg (device_t, int, int, int);
161static void vr_miibus_statchg (device_t);
162
163static void vr_setcfg (struct vr_softc *, int);
164static u_int8_t vr_calchash (u_int8_t *);
164static u_int32_t vr_mchash (caddr_t);
165static void vr_setmulti (struct vr_softc *);
166static void vr_reset (struct vr_softc *);
167static int vr_list_rx_init (struct vr_softc *);
168static int vr_list_tx_init (struct vr_softc *);
169
170#ifdef VR_USEIOSPACE
171#define VR_RES SYS_RES_IOPORT
172#define VR_RID VR_PCI_LOIO

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

560 VR_UNLOCK(sc);
561
562 return;
563}
564
565/*
566 * Calculate CRC of a multicast group address, return the lower 6 bits.
567 */
165static void vr_setmulti (struct vr_softc *);
166static void vr_reset (struct vr_softc *);
167static int vr_list_rx_init (struct vr_softc *);
168static int vr_list_tx_init (struct vr_softc *);
169
170#ifdef VR_USEIOSPACE
171#define VR_RES SYS_RES_IOPORT
172#define VR_RID VR_PCI_LOIO

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

560 VR_UNLOCK(sc);
561
562 return;
563}
564
565/*
566 * Calculate CRC of a multicast group address, return the lower 6 bits.
567 */
568static u_int8_t vr_calchash(addr)
569 u_int8_t *addr;
568static u_int32_t
569vr_mchash(addr)
570 caddr_t addr;
570{
571{
571 u_int32_t crc, carry;
572 int i, j;
573 u_int8_t c;
572 u_int32_t crc, carry;
573 int idx, bit;
574 u_int8_t data;
574
575 /* Compute CRC for the address value. */
576 crc = 0xFFFFFFFF; /* initial value */
577
575
576 /* Compute CRC for the address value. */
577 crc = 0xFFFFFFFF; /* initial value */
578
578 for (i = 0; i < 6; i++) {
579 c = *(addr + i);
580 for (j = 0; j < 8; j++) {
581 carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01);
579 for (idx = 0; idx < 6; idx++) {
580 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) {
581 carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01);
582 crc <<= 1;
582 crc <<= 1;
583 c >>= 1;
584 if (carry)
585 crc = (crc ^ 0x04c11db6) | carry;
586 }
587 }
588
589 /* return the filter bit position */
590 return((crc >> 26) & 0x0000003F);
591}

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

619 /* first, zot all the existing hash bits */
620 CSR_WRITE_4(sc, VR_MAR0, 0);
621 CSR_WRITE_4(sc, VR_MAR1, 0);
622
623 /* now program new ones */
624 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
625 if (ifma->ifma_addr->sa_family != AF_LINK)
626 continue;
583 if (carry)
584 crc = (crc ^ 0x04c11db6) | carry;
585 }
586 }
587
588 /* return the filter bit position */
589 return((crc >> 26) & 0x0000003F);
590}

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

618 /* first, zot all the existing hash bits */
619 CSR_WRITE_4(sc, VR_MAR0, 0);
620 CSR_WRITE_4(sc, VR_MAR1, 0);
621
622 /* now program new ones */
623 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
624 if (ifma->ifma_addr->sa_family != AF_LINK)
625 continue;
627 h = vr_calchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
626 h = vr_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
628 if (h < 32)
629 hashes[0] |= (1 << h);
630 else
631 hashes[1] |= (1 << (h - 32));
632 mcnt++;
633 }
634
635 if (mcnt)

--- 1169 unchanged lines hidden ---
627 if (h < 32)
628 hashes[0] |= (1 << h);
629 else
630 hashes[1] |= (1 << (h - 32));
631 mcnt++;
632 }
633
634 if (mcnt)

--- 1169 unchanged lines hidden ---