Deleted Added
full compact
if_rl.c (51533) if_rl.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/pci/if_rl.c 51533 1999-09-22 06:08:11Z wpaul $
32 * $FreeBSD: head/sys/pci/if_rl.c 51583 1999-09-23 03:32:57Z wpaul $
33 */
34
35/*
36 * RealTek 8129/8139 PCI NIC driver
37 *
38 * Supports several extremely cheap PCI 10/100 adapters based on
39 * the RealTek chipset. Datasheets can be obtained from
40 * www.realtek.com.tw.

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

78 * filter.
79 *
80 * The 8129 chip is an older version of the 8139 that uses an external PHY
81 * chip. The 8129 has a serial MDIO interface for accessing the MII where
82 * the 8139 lets you directly access the on-board PHY registers. We need
83 * to select which interface to use depending on the chip type.
84 */
85
33 */
34
35/*
36 * RealTek 8129/8139 PCI NIC driver
37 *
38 * Supports several extremely cheap PCI 10/100 adapters based on
39 * the RealTek chipset. Datasheets can be obtained from
40 * www.realtek.com.tw.

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

78 * filter.
79 *
80 * The 8129 chip is an older version of the 8139 that uses an external PHY
81 * chip. The 8129 has a serial MDIO interface for accessing the MII where
82 * the 8139 lets you directly access the on-board PHY registers. We need
83 * to select which interface to use depending on the chip type.
84 */
85
86#include "bpf.h"
87
88#include <sys/param.h>
89#include <sys/systm.h>
90#include <sys/sockio.h>
91#include <sys/mbuf.h>
92#include <sys/malloc.h>
93#include <sys/kernel.h>
94#include <sys/socket.h>
95
96#include <net/if.h>
97#include <net/if_arp.h>
98#include <net/ethernet.h>
99#include <net/if_dl.h>
100#include <net/if_media.h>
101
86#include <sys/param.h>
87#include <sys/systm.h>
88#include <sys/sockio.h>
89#include <sys/mbuf.h>
90#include <sys/malloc.h>
91#include <sys/kernel.h>
92#include <sys/socket.h>
93
94#include <net/if.h>
95#include <net/if_arp.h>
96#include <net/ethernet.h>
97#include <net/if_dl.h>
98#include <net/if_media.h>
99
102#if NBPF > 0
103#include <net/bpf.h>
100#include <net/bpf.h>
104#endif
105
106#include <vm/vm.h> /* for vtophys */
107#include <vm/pmap.h> /* for vtophys */
108#include <machine/clock.h> /* for DELAY */
109#include <machine/bus_pio.h>
110#include <machine/bus_memio.h>
111#include <machine/bus.h>
112#include <machine/resource.h>

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

131 * uniprocessor systems though.
132 */
133#define RL_USEIOSPACE
134
135#include <pci/if_rlreg.h>
136
137#ifndef lint
138static const char rcsid[] =
101
102#include <vm/vm.h> /* for vtophys */
103#include <vm/pmap.h> /* for vtophys */
104#include <machine/clock.h> /* for DELAY */
105#include <machine/bus_pio.h>
106#include <machine/bus_memio.h>
107#include <machine/bus.h>
108#include <machine/resource.h>

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

127 * uniprocessor systems though.
128 */
129#define RL_USEIOSPACE
130
131#include <pci/if_rlreg.h>
132
133#ifndef lint
134static const char rcsid[] =
139 "$FreeBSD: head/sys/pci/if_rl.c 51533 1999-09-22 06:08:11Z wpaul $";
135 "$FreeBSD: head/sys/pci/if_rl.c 51583 1999-09-23 03:32:57Z wpaul $";
140#endif
141
142/*
143 * Various supported device vendors/types and their names.
144 */
145static struct rl_type rl_devs[] = {
146 { RT_VENDORID, RT_DEVICEID_8129,
147 "RealTek 8129 10/100BaseTX" },

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

958 ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
959
960 /*
961 * Call MI attach routines.
962 */
963 if_attach(ifp);
964 ether_ifattach(ifp);
965
136#endif
137
138/*
139 * Various supported device vendors/types and their names.
140 */
141static struct rl_type rl_devs[] = {
142 { RT_VENDORID, RT_DEVICEID_8129,
143 "RealTek 8129 10/100BaseTX" },

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

954 ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
955
956 /*
957 * Call MI attach routines.
958 */
959 if_attach(ifp);
960 ether_ifattach(ifp);
961
966#if NBPF > 0
967 bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
962 bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
968#endif
969
970fail:
971 splx(s);
972 return(error);
973}
974
975static int rl_detach(dev)
976 device_t dev;

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

1158 CSR_WRITE_2(sc, RL_CURRXADDR, cur_rx - 16);
1159
1160 if (m == NULL)
1161 continue;
1162
1163 eh = mtod(m, struct ether_header *);
1164 ifp->if_ipackets++;
1165
963
964fail:
965 splx(s);
966 return(error);
967}
968
969static int rl_detach(dev)
970 device_t dev;

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

1152 CSR_WRITE_2(sc, RL_CURRXADDR, cur_rx - 16);
1153
1154 if (m == NULL)
1155 continue;
1156
1157 eh = mtod(m, struct ether_header *);
1158 ifp->if_ipackets++;
1159
1166#if NBPF > 0
1167 /*
1168 * Handle BPF listeners. Let the BPF user see the packet, but
1169 * don't pass it up to the ether_input() layer unless it's
1170 * a broadcast packet, multicast packet, matches our ethernet
1171 * address or the interface is in promiscuous mode.
1172 */
1173 if (ifp->if_bpf) {
1174 bpf_mtap(ifp, m);
1175 if (ifp->if_flags & IFF_PROMISC &&
1176 (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
1177 ETHER_ADDR_LEN) &&
1178 (eh->ether_dhost[0] & 1) == 0)) {
1179 m_freem(m);
1180 continue;
1181 }
1182 }
1160 /*
1161 * Handle BPF listeners. Let the BPF user see the packet, but
1162 * don't pass it up to the ether_input() layer unless it's
1163 * a broadcast packet, multicast packet, matches our ethernet
1164 * address or the interface is in promiscuous mode.
1165 */
1166 if (ifp->if_bpf) {
1167 bpf_mtap(ifp, m);
1168 if (ifp->if_flags & IFF_PROMISC &&
1169 (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
1170 ETHER_ADDR_LEN) &&
1171 (eh->ether_dhost[0] & 1) == 0)) {
1172 m_freem(m);
1173 continue;
1174 }
1175 }
1183#endif
1176
1184 /* Remove header from mbuf and pass it on. */
1185 m_adj(m, sizeof(struct ether_header));
1186 ether_input(ifp, eh, m);
1187 }
1188
1189 return;
1190}
1191

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

1366
1367 while(RL_CUR_TXMBUF(sc) == NULL) {
1368 IF_DEQUEUE(&ifp->if_snd, m_head);
1369 if (m_head == NULL)
1370 break;
1371
1372 rl_encap(sc, m_head);
1373
1177 /* Remove header from mbuf and pass it on. */
1178 m_adj(m, sizeof(struct ether_header));
1179 ether_input(ifp, eh, m);
1180 }
1181
1182 return;
1183}
1184

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

1359
1360 while(RL_CUR_TXMBUF(sc) == NULL) {
1361 IF_DEQUEUE(&ifp->if_snd, m_head);
1362 if (m_head == NULL)
1363 break;
1364
1365 rl_encap(sc, m_head);
1366
1374#if NBPF > 0
1375 /*
1376 * If there's a BPF listener, bounce a copy of this frame
1377 * to him.
1378 */
1379 if (ifp->if_bpf)
1380 bpf_mtap(ifp, RL_CUR_TXMBUF(sc));
1367 /*
1368 * If there's a BPF listener, bounce a copy of this frame
1369 * to him.
1370 */
1371 if (ifp->if_bpf)
1372 bpf_mtap(ifp, RL_CUR_TXMBUF(sc));
1381#endif
1373
1382 /*
1383 * Transmit the frame.
1384 */
1385 CSR_WRITE_4(sc, RL_CUR_TXADDR(sc),
1386 vtophys(mtod(RL_CUR_TXMBUF(sc), caddr_t)));
1387 CSR_WRITE_4(sc, RL_CUR_TXSTAT(sc),
1388 RL_TX_EARLYTHRESH | RL_CUR_TXMBUF(sc)->m_pkthdr.len);
1389

--- 262 unchanged lines hidden ---
1374 /*
1375 * Transmit the frame.
1376 */
1377 CSR_WRITE_4(sc, RL_CUR_TXADDR(sc),
1378 vtophys(mtod(RL_CUR_TXMBUF(sc), caddr_t)));
1379 CSR_WRITE_4(sc, RL_CUR_TXSTAT(sc),
1380 RL_TX_EARLYTHRESH | RL_CUR_TXMBUF(sc)->m_pkthdr.len);
1381

--- 262 unchanged lines hidden ---