Deleted Added
full compact
if_vr.c (51533) if_vr.c (51583)
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

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

24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 *
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

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

24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * $FreeBSD: head/sys/dev/vr/if_vr.c 51533 1999-09-22 06:08:11Z wpaul $
32 * $FreeBSD: head/sys/dev/vr/if_vr.c 51583 1999-09-23 03:32:57Z wpaul $
33 */
34
35/*
36 * VIA Rhine fast ethernet PCI NIC driver
37 *
38 * Supports various network adapters based on the VIA Rhine
39 * and Rhine II PCI controllers, including the D-Link DFE530TX.
40 * Datasheets are available at http://www.via.com.tw.

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

54 *
55 * The Rhine has a serious flaw in its transmit DMA mechanism:
56 * transmit buffers must be longword aligned. Unfortunately,
57 * FreeBSD doesn't guarantee that mbufs will be filled in starting
58 * at longword boundaries, so we have to do a buffer copy before
59 * transmission.
60 */
61
33 */
34
35/*
36 * VIA Rhine fast ethernet PCI NIC driver
37 *
38 * Supports various network adapters based on the VIA Rhine
39 * and Rhine II PCI controllers, including the D-Link DFE530TX.
40 * Datasheets are available at http://www.via.com.tw.

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

54 *
55 * The Rhine has a serious flaw in its transmit DMA mechanism:
56 * transmit buffers must be longword aligned. Unfortunately,
57 * FreeBSD doesn't guarantee that mbufs will be filled in starting
58 * at longword boundaries, so we have to do a buffer copy before
59 * transmission.
60 */
61
62#include "bpf.h"
63
64#include <sys/param.h>
65#include <sys/systm.h>
66#include <sys/sockio.h>
67#include <sys/mbuf.h>
68#include <sys/malloc.h>
69#include <sys/kernel.h>
70#include <sys/socket.h>
71
72#include <net/if.h>
73#include <net/if_arp.h>
74#include <net/ethernet.h>
75#include <net/if_dl.h>
76#include <net/if_media.h>
77
62#include <sys/param.h>
63#include <sys/systm.h>
64#include <sys/sockio.h>
65#include <sys/mbuf.h>
66#include <sys/malloc.h>
67#include <sys/kernel.h>
68#include <sys/socket.h>
69
70#include <net/if.h>
71#include <net/if_arp.h>
72#include <net/ethernet.h>
73#include <net/if_dl.h>
74#include <net/if_media.h>
75
78#if NBPF > 0
79#include <net/bpf.h>
76#include <net/bpf.h>
80#endif
81
82#include "opt_bdg.h"
83#ifdef BRIDGE
84#include <net/bridge.h>
85#endif /* BRIDGE */
86
87#include <vm/vm.h> /* for vtophys */
88#include <vm/pmap.h> /* for vtophys */

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

104
105#include <pci/if_vrreg.h>
106
107/* "controller miibus0" required. See GENERIC if you get errors here. */
108#include "miibus_if.h"
109
110#ifndef lint
111static const char rcsid[] =
77
78#include "opt_bdg.h"
79#ifdef BRIDGE
80#include <net/bridge.h>
81#endif /* BRIDGE */
82
83#include <vm/vm.h> /* for vtophys */
84#include <vm/pmap.h> /* for vtophys */

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

100
101#include <pci/if_vrreg.h>
102
103/* "controller miibus0" required. See GENERIC if you get errors here. */
104#include "miibus_if.h"
105
106#ifndef lint
107static const char rcsid[] =
112 "$FreeBSD: head/sys/dev/vr/if_vr.c 51533 1999-09-22 06:08:11Z wpaul $";
108 "$FreeBSD: head/sys/dev/vr/if_vr.c 51583 1999-09-23 03:32:57Z wpaul $";
113#endif
114
115/*
116 * Various supported device vendors/types and their names.
117 */
118static struct vr_type vr_devs[] = {
119 { VIA_VENDORID, VIA_DEVICEID_RHINE,
120 "VIA VT3043 Rhine I 10/100BaseTX" },

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

805 callout_handle_init(&sc->vr_stat_ch);
806
807 /*
808 * Call MI attach routines.
809 */
810 if_attach(ifp);
811 ether_ifattach(ifp);
812
109#endif
110
111/*
112 * Various supported device vendors/types and their names.
113 */
114static struct vr_type vr_devs[] = {
115 { VIA_VENDORID, VIA_DEVICEID_RHINE,
116 "VIA VT3043 Rhine I 10/100BaseTX" },

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

801 callout_handle_init(&sc->vr_stat_ch);
802
803 /*
804 * Call MI attach routines.
805 */
806 if_attach(ifp);
807 ether_ifattach(ifp);
808
813#if NBPF > 0
814 bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
809 bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
815#endif
816
817fail:
818 splx(s);
819 return(error);
820}
821
822static int vr_detach(dev)
823 device_t dev;

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

1044 continue;
1045 }
1046 m_adj(m0, ETHER_ALIGN);
1047 m = m0;
1048
1049 ifp->if_ipackets++;
1050 eh = mtod(m, struct ether_header *);
1051
810
811fail:
812 splx(s);
813 return(error);
814}
815
816static int vr_detach(dev)
817 device_t dev;

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

1038 continue;
1039 }
1040 m_adj(m0, ETHER_ALIGN);
1041 m = m0;
1042
1043 ifp->if_ipackets++;
1044 eh = mtod(m, struct ether_header *);
1045
1052#if NBPF > 0
1053 /*
1054 * Handle BPF listeners. Let the BPF user see the packet, but
1055 * don't pass it up to the ether_input() layer unless it's
1056 * a broadcast packet, multicast packet, matches our ethernet
1057 * address or the interface is in promiscuous mode.
1058 */
1059 if (ifp->if_bpf) {
1060 bpf_mtap(ifp, m);
1061 if (ifp->if_flags & IFF_PROMISC &&
1062 (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
1063 ETHER_ADDR_LEN) &&
1064 (eh->ether_dhost[0] & 1) == 0)) {
1065 m_freem(m);
1066 continue;
1067 }
1068 }
1046 /*
1047 * Handle BPF listeners. Let the BPF user see the packet, but
1048 * don't pass it up to the ether_input() layer unless it's
1049 * a broadcast packet, multicast packet, matches our ethernet
1050 * address or the interface is in promiscuous mode.
1051 */
1052 if (ifp->if_bpf) {
1053 bpf_mtap(ifp, m);
1054 if (ifp->if_flags & IFF_PROMISC &&
1055 (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
1056 ETHER_ADDR_LEN) &&
1057 (eh->ether_dhost[0] & 1) == 0)) {
1058 m_freem(m);
1059 continue;
1060 }
1061 }
1069#endif /* NBPF>0 */
1062
1070#ifdef BRIDGE
1071 if (do_bridge) {
1072 struct ifnet *bdg_ifp;
1073 bdg_ifp = bridge_in(m);
1074 if (bdg_ifp != BDG_LOCAL && bdg_ifp != BDG_DROP)
1075 bdg_forward(&m, bdg_ifp);
1076 if (((bdg_ifp != BDG_LOCAL) && (bdg_ifp != BDG_BCAST) &&
1077 (bdg_ifp != BDG_MCAST)) || bdg_ifp == BDG_DROP) {

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

1380 sc->vr_cdata.vr_tx_free = cur_tx->vr_nextdesc;
1381
1382 /* Pack the data into the descriptor. */
1383 vr_encap(sc, cur_tx, m_head);
1384
1385 if (cur_tx != start_tx)
1386 VR_TXOWN(cur_tx) = VR_TXSTAT_OWN;
1387
1063#ifdef BRIDGE
1064 if (do_bridge) {
1065 struct ifnet *bdg_ifp;
1066 bdg_ifp = bridge_in(m);
1067 if (bdg_ifp != BDG_LOCAL && bdg_ifp != BDG_DROP)
1068 bdg_forward(&m, bdg_ifp);
1069 if (((bdg_ifp != BDG_LOCAL) && (bdg_ifp != BDG_BCAST) &&
1070 (bdg_ifp != BDG_MCAST)) || bdg_ifp == BDG_DROP) {

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

1373 sc->vr_cdata.vr_tx_free = cur_tx->vr_nextdesc;
1374
1375 /* Pack the data into the descriptor. */
1376 vr_encap(sc, cur_tx, m_head);
1377
1378 if (cur_tx != start_tx)
1379 VR_TXOWN(cur_tx) = VR_TXSTAT_OWN;
1380
1388#if NBPF > 0
1389 /*
1390 * If there's a BPF listener, bounce a copy of this frame
1391 * to him.
1392 */
1393 if (ifp->if_bpf)
1394 bpf_mtap(ifp, cur_tx->vr_mbuf);
1381 /*
1382 * If there's a BPF listener, bounce a copy of this frame
1383 * to him.
1384 */
1385 if (ifp->if_bpf)
1386 bpf_mtap(ifp, cur_tx->vr_mbuf);
1395#endif
1387
1396 VR_TXOWN(cur_tx) = VR_TXSTAT_OWN;
1397 VR_SETBIT16(sc, VR_COMMAND, /*VR_CMD_TX_ON|*/VR_CMD_TX_GO);
1398 }
1399
1400 /*
1401 * If there are no frames queued, bail.
1402 */
1403 if (cur_tx == NULL)

--- 268 unchanged lines hidden ---
1388 VR_TXOWN(cur_tx) = VR_TXSTAT_OWN;
1389 VR_SETBIT16(sc, VR_COMMAND, /*VR_CMD_TX_ON|*/VR_CMD_TX_GO);
1390 }
1391
1392 /*
1393 * If there are no frames queued, bail.
1394 */
1395 if (cur_tx == NULL)

--- 268 unchanged lines hidden ---