Deleted Added
full compact
if_ie.c (47108) if_ie.c (48645)
1/*-
2 * Copyright (c) 1992, 1993, University of Vermont and State
3 * Agricultural College.
4 * Copyright (c) 1992, 1993, Garrett A. Wollman.
5 *
6 * Portions:
7 * Copyright (c) 1990, 1991, William F. Jolitz
8 * Copyright (c) 1990, The Regents of the University of California

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

42 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
44 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
46 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
47 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48 * SUCH DAMAGE.
49 *
1/*-
2 * Copyright (c) 1992, 1993, University of Vermont and State
3 * Agricultural College.
4 * Copyright (c) 1992, 1993, Garrett A. Wollman.
5 *
6 * Portions:
7 * Copyright (c) 1990, 1991, William F. Jolitz
8 * Copyright (c) 1990, The Regents of the University of California

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

42 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
44 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
46 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
47 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48 * SUCH DAMAGE.
49 *
50 * $Id: if_ie.c,v 1.59 1999/01/28 01:59:53 dillon Exp $
50 * $Id: if_ie.c,v 1.60 1999/05/13 12:21:41 bde Exp $
51 */
52
53/*
54 * Intel 82586 Ethernet chip
55 * Register, bit, and structure definitions.
56 *
57 * Written by GAW with reference to the Clarkson Packet Driver code for this
58 * chip written by Russ Nelson and others.

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

120#include <sys/socket.h>
121#include <sys/sockio.h>
122#include <sys/syslog.h>
123
124#include <net/if.h>
125#include <net/if_types.h>
126#include <net/if_dl.h>
127
51 */
52
53/*
54 * Intel 82586 Ethernet chip
55 * Register, bit, and structure definitions.
56 *
57 * Written by GAW with reference to the Clarkson Packet Driver code for this
58 * chip written by Russ Nelson and others.

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

120#include <sys/socket.h>
121#include <sys/sockio.h>
122#include <sys/syslog.h>
123
124#include <net/if.h>
125#include <net/if_types.h>
126#include <net/if_dl.h>
127
128#include "bpfilter.h"
128#include "bpf.h"
129
130#ifdef INET
131#include <netinet/in.h>
132#include <netinet/if_ether.h>
133#endif
134
135#ifdef IPX
136#include <netipx/ipx.h>

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

148#include <i386/isa/isa_device.h>
149#include <i386/isa/ic/i82586.h>
150#include <i386/isa/icu.h>
151#include <i386/isa/if_iereg.h>
152#include <i386/isa/if_ie507.h>
153#include <i386/isa/if_iee16.h>
154#include <i386/isa/elink.h>
155
129
130#ifdef INET
131#include <netinet/in.h>
132#include <netinet/if_ether.h>
133#endif
134
135#ifdef IPX
136#include <netipx/ipx.h>

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

148#include <i386/isa/isa_device.h>
149#include <i386/isa/ic/i82586.h>
150#include <i386/isa/icu.h>
151#include <i386/isa/if_iereg.h>
152#include <i386/isa/if_ie507.h>
153#include <i386/isa/if_iee16.h>
154#include <i386/isa/elink.h>
155
156#if NBPFILTER > 0
156#if NBPF > 0
157#include <net/bpf.h>
158#endif
159
160#ifdef DEBUG
161#define IED_RINT 0x01
162#define IED_TINT 0x02
163#define IED_RNR 0x04
164#define IED_CNA 0x08

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

837 ifp->if_ioctl = ieioctl;
838 ifp->if_type = IFT_ETHER;
839 ifp->if_addrlen = 6;
840 ifp->if_hdrlen = 14;
841
842 if (ie->hard_type == IE_EE16)
843 at_shutdown(ee16_shutdown, ie, SHUTDOWN_POST_SYNC);
844
157#include <net/bpf.h>
158#endif
159
160#ifdef DEBUG
161#define IED_RINT 0x01
162#define IED_TINT 0x02
163#define IED_RNR 0x04
164#define IED_CNA 0x08

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

837 ifp->if_ioctl = ieioctl;
838 ifp->if_type = IFT_ETHER;
839 ifp->if_addrlen = 6;
840 ifp->if_hdrlen = 14;
841
842 if (ie->hard_type == IE_EE16)
843 at_shutdown(ee16_shutdown, ie, SHUTDOWN_POST_SYNC);
844
845#if NBPFILTER > 0
845#if NBPF > 0
846 bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
847#endif
848
849 if_attach(ifp);
850 ether_ifattach(ifp);
851 return (1);
852}
853

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

1096 int i;
1097
1098 switch (ie->promisc) {
1099 case IFF_ALLMULTI:
1100 /*
1101 * Receiving all multicasts, but no unicasts except those
1102 * destined for us.
1103 */
846 bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
847#endif
848
849 if_attach(ifp);
850 ether_ifattach(ifp);
851 return (1);
852}
853

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

1096 int i;
1097
1098 switch (ie->promisc) {
1099 case IFF_ALLMULTI:
1100 /*
1101 * Receiving all multicasts, but no unicasts except those
1102 * destined for us.
1103 */
1104#if NBPFILTER > 0
1104#if NBPF > 0
1105 /* BPF gets this packet if anybody cares */
1106 *to_bpf = (ie->arpcom.ac_if.if_bpf != 0);
1107#endif
1108 if (eh->ether_dhost[0] & 1) {
1109 return (1);
1110 }
1111 if (ether_equal(eh->ether_dhost, ie->arpcom.ac_enaddr))
1112 return (1);
1113 return (0);
1114
1115 case IFF_PROMISC:
1116 /*
1117 * Receiving all packets. These need to be passed on to
1118 * BPF.
1119 */
1105 /* BPF gets this packet if anybody cares */
1106 *to_bpf = (ie->arpcom.ac_if.if_bpf != 0);
1107#endif
1108 if (eh->ether_dhost[0] & 1) {
1109 return (1);
1110 }
1111 if (ether_equal(eh->ether_dhost, ie->arpcom.ac_enaddr))
1112 return (1);
1113 return (0);
1114
1115 case IFF_PROMISC:
1116 /*
1117 * Receiving all packets. These need to be passed on to
1118 * BPF.
1119 */
1120#if NBPFILTER > 0
1120#if NBPF > 0
1121 *to_bpf = (ie->arpcom.ac_if.if_bpf != 0);
1122#endif
1123 /* If for us, accept and hand up to BPF */
1124 if (ether_equal(eh->ether_dhost, ie->arpcom.ac_enaddr))
1125 return (1);
1126
1121 *to_bpf = (ie->arpcom.ac_if.if_bpf != 0);
1122#endif
1123 /* If for us, accept and hand up to BPF */
1124 if (ether_equal(eh->ether_dhost, ie->arpcom.ac_enaddr))
1125 return (1);
1126
1127#if NBPFILTER > 0
1127#if NBPF > 0
1128 if (*to_bpf)
1129 *to_bpf = 2; /* we don't need to see it */
1130#endif
1131
1132 /*
1133 * Not a multicast, so BPF wants to see it but we don't.
1134 */
1135 if (!(eh->ether_dhost[0] & 1))
1136 return (1);
1137
1138 /*
1139 * If it's one of our multicast groups, accept it and pass
1140 * it up.
1141 */
1142 for (i = 0; i < ie->mcast_count; i++) {
1143 if (ether_equal(eh->ether_dhost,
1144 (u_char *)&ie->mcast_addrs[i])) {
1128 if (*to_bpf)
1129 *to_bpf = 2; /* we don't need to see it */
1130#endif
1131
1132 /*
1133 * Not a multicast, so BPF wants to see it but we don't.
1134 */
1135 if (!(eh->ether_dhost[0] & 1))
1136 return (1);
1137
1138 /*
1139 * If it's one of our multicast groups, accept it and pass
1140 * it up.
1141 */
1142 for (i = 0; i < ie->mcast_count; i++) {
1143 if (ether_equal(eh->ether_dhost,
1144 (u_char *)&ie->mcast_addrs[i])) {
1145#if NBPFILTER > 0
1145#if NBPF > 0
1146 if (*to_bpf)
1147 *to_bpf = 1;
1148#endif
1149 return (1);
1150 }
1151 }
1152 return (1);
1153
1154 case IFF_ALLMULTI | IFF_PROMISC:
1155 /*
1156 * Acting as a multicast router, and BPF running at the same
1157 * time. Whew! (Hope this is a fast machine...)
1158 */
1146 if (*to_bpf)
1147 *to_bpf = 1;
1148#endif
1149 return (1);
1150 }
1151 }
1152 return (1);
1153
1154 case IFF_ALLMULTI | IFF_PROMISC:
1155 /*
1156 * Acting as a multicast router, and BPF running at the same
1157 * time. Whew! (Hope this is a fast machine...)
1158 */
1159#if NBPFILTER > 0
1159#if NBPF > 0
1160 *to_bpf = (ie->arpcom.ac_if.if_bpf != 0);
1161#endif
1162 /* We want to see multicasts. */
1163 if (eh->ether_dhost[0] & 1)
1164 return (1);
1165
1166 /* We want to see our own packets */
1167 if (ether_equal(eh->ether_dhost, ie->arpcom.ac_enaddr))
1168 return (1);
1169
1170 /* Anything else goes to BPF but nothing else. */
1160 *to_bpf = (ie->arpcom.ac_if.if_bpf != 0);
1161#endif
1162 /* We want to see multicasts. */
1163 if (eh->ether_dhost[0] & 1)
1164 return (1);
1165
1166 /* We want to see our own packets */
1167 if (ether_equal(eh->ether_dhost, ie->arpcom.ac_enaddr))
1168 return (1);
1169
1170 /* Anything else goes to BPF but nothing else. */
1171#if NBPFILTER > 0
1171#if NBPF > 0
1172 if (*to_bpf)
1173 *to_bpf = 2;
1174#endif
1175 return (1);
1176
1177 default:
1178 /*
1179 * Only accept unicast packets destined for us, or
1180 * multicasts for groups that we belong to. For now, we
1181 * assume that the '586 will only return packets that we
1182 * asked it for. This isn't strictly true (it uses hashing
1183 * for the multicast filter), but it will do in this case,
1184 * and we want to get out of here as quickly as possible.
1185 */
1172 if (*to_bpf)
1173 *to_bpf = 2;
1174#endif
1175 return (1);
1176
1177 default:
1178 /*
1179 * Only accept unicast packets destined for us, or
1180 * multicasts for groups that we belong to. For now, we
1181 * assume that the '586 will only return packets that we
1182 * asked it for. This isn't strictly true (it uses hashing
1183 * for the multicast filter), but it will do in this case,
1184 * and we want to get out of here as quickly as possible.
1185 */
1186#if NBPFILTER > 0
1186#if NBPF > 0
1187 *to_bpf = (ie->arpcom.ac_if.if_bpf != 0);
1188#endif
1189 return (1);
1190 }
1191 return (0);
1192}
1193
1194/*

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

1415 */
1416static void
1417ie_readframe(int unit, struct ie_softc *ie, int num/* frame number to read */)
1418{
1419 struct ie_recv_frame_desc rfd;
1420 struct mbuf *m = 0;
1421 struct ether_header eh;
1422
1187 *to_bpf = (ie->arpcom.ac_if.if_bpf != 0);
1188#endif
1189 return (1);
1190 }
1191 return (0);
1192}
1193
1194/*

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

1415 */
1416static void
1417ie_readframe(int unit, struct ie_softc *ie, int num/* frame number to read */)
1418{
1419 struct ie_recv_frame_desc rfd;
1420 struct mbuf *m = 0;
1421 struct ether_header eh;
1422
1423#if NBPFILTER > 0
1423#if NBPF > 0
1424 int bpf_gets_it = 0;
1425
1426#endif
1427
1428 bcopy((v_caddr_t) (ie->rframes[num]), &rfd,
1429 sizeof(struct ie_recv_frame_desc));
1430
1431 /*
1432 * Immediately advance the RFD list, since we we have copied ours
1433 * now.
1434 */
1435 ie->rframes[num]->ie_fd_status = 0;
1436 ie->rframes[num]->ie_fd_last |= IE_FD_LAST;
1437 ie->rframes[ie->rftail]->ie_fd_last &= ~IE_FD_LAST;
1438 ie->rftail = (ie->rftail + 1) % ie->nframes;
1439 ie->rfhead = (ie->rfhead + 1) % ie->nframes;
1440
1441 if (rfd.ie_fd_status & IE_FD_OK) {
1424 int bpf_gets_it = 0;
1425
1426#endif
1427
1428 bcopy((v_caddr_t) (ie->rframes[num]), &rfd,
1429 sizeof(struct ie_recv_frame_desc));
1430
1431 /*
1432 * Immediately advance the RFD list, since we we have copied ours
1433 * now.
1434 */
1435 ie->rframes[num]->ie_fd_status = 0;
1436 ie->rframes[num]->ie_fd_last |= IE_FD_LAST;
1437 ie->rframes[ie->rftail]->ie_fd_last &= ~IE_FD_LAST;
1438 ie->rftail = (ie->rftail + 1) % ie->nframes;
1439 ie->rfhead = (ie->rfhead + 1) % ie->nframes;
1440
1441 if (rfd.ie_fd_status & IE_FD_OK) {
1442#if NBPFILTER > 0
1442#if NBPF > 0
1443 if (ieget(unit, ie, &m, &eh, &bpf_gets_it)) {
1444#else
1445 if (ieget(unit, ie, &m, &eh, (int *)0)) {
1446#endif
1447 ie->arpcom.ac_if.if_ierrors++; /* this counts as an
1448 * error */
1449 return;
1450 }

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

1461
1462 if (!m)
1463 return;
1464
1465 if (last_not_for_us) {
1466 m_freem(last_not_for_us);
1467 last_not_for_us = 0;
1468 }
1443 if (ieget(unit, ie, &m, &eh, &bpf_gets_it)) {
1444#else
1445 if (ieget(unit, ie, &m, &eh, (int *)0)) {
1446#endif
1447 ie->arpcom.ac_if.if_ierrors++; /* this counts as an
1448 * error */
1449 return;
1450 }

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

1461
1462 if (!m)
1463 return;
1464
1465 if (last_not_for_us) {
1466 m_freem(last_not_for_us);
1467 last_not_for_us = 0;
1468 }
1469#if NBPFILTER > 0
1469#if NBPF > 0
1470 /*
1471 * Check for a BPF filter; if so, hand it up. Note that we have to
1472 * stick an extra mbuf up front, because bpf_mtap expects to have
1473 * the ether header at the front. It doesn't matter that this
1474 * results in an ill-formatted mbuf chain, since BPF just looks at
1475 * the data. (It doesn't try to free the mbuf, tho' it will make a
1476 * copy for tcpdump.)
1477 */

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

1489 * A signal passed up from the filtering code indicating that the
1490 * packet is intended for BPF but not for the protocol machinery. We
1491 * can save a few cycles by not handing it off to them.
1492 */
1493 if (bpf_gets_it == 2) {
1494 last_not_for_us = m;
1495 return;
1496 }
1470 /*
1471 * Check for a BPF filter; if so, hand it up. Note that we have to
1472 * stick an extra mbuf up front, because bpf_mtap expects to have
1473 * the ether header at the front. It doesn't matter that this
1474 * results in an ill-formatted mbuf chain, since BPF just looks at
1475 * the data. (It doesn't try to free the mbuf, tho' it will make a
1476 * copy for tcpdump.)
1477 */

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

1489 * A signal passed up from the filtering code indicating that the
1490 * packet is intended for BPF but not for the protocol machinery. We
1491 * can save a few cycles by not handing it off to them.
1492 */
1493 if (bpf_gets_it == 2) {
1494 last_not_for_us = m;
1495 return;
1496 }
1497#endif /* NBPFILTER > 0 */
1497#endif /* NBPF > 0 */
1498 /*
1499 * In here there used to be code to check destination addresses upon
1500 * receipt of a packet. We have deleted that code, and replaced it
1501 * with code to check the address much earlier in the cycle, before
1502 * copying the data in; this saves us valuable cycles when operating
1503 * as a multicast router or when using BPF.
1504 */
1505

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

1573 bcopy(mtod(m, caddr_t), buffer, m->m_len);
1574 buffer += m->m_len;
1575 len += m->m_len;
1576 }
1577
1578 m_freem(m0);
1579 len = max(len, ETHER_MIN_LEN);
1580
1498 /*
1499 * In here there used to be code to check destination addresses upon
1500 * receipt of a packet. We have deleted that code, and replaced it
1501 * with code to check the address much earlier in the cycle, before
1502 * copying the data in; this saves us valuable cycles when operating
1503 * as a multicast router or when using BPF.
1504 */
1505

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

1573 bcopy(mtod(m, caddr_t), buffer, m->m_len);
1574 buffer += m->m_len;
1575 len += m->m_len;
1576 }
1577
1578 m_freem(m0);
1579 len = max(len, ETHER_MIN_LEN);
1580
1581#if NBPFILTER > 0
1581#if NBPF > 0
1582 /*
1583 * See if bpf is listening on this interface, let it see the
1584 * packet before we commit it to the wire.
1585 */
1586 if (ie->arpcom.ac_if.if_bpf)
1587 bpf_tap(&ie->arpcom.ac_if,
1588 (void *)ie->xmit_cbuffs[ie->xmit_count], len);
1589#endif

--- 845 unchanged lines hidden ---
1582 /*
1583 * See if bpf is listening on this interface, let it see the
1584 * packet before we commit it to the wire.
1585 */
1586 if (ie->arpcom.ac_if.if_bpf)
1587 bpf_tap(&ie->arpcom.ac_if,
1588 (void *)ie->xmit_cbuffs[ie->xmit_count], len);
1589#endif

--- 845 unchanged lines hidden ---