Deleted Added
full compact
1/*
2 * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
3 * adapters. By David Greenman, 29-April-1993
4 *
5 * Copyright (C) 1993, David Greenman. This software may be used, modified,
6 * copied, distributed, and sold, in both source and binary form provided
7 * that the above copyright and these terms are retained. Under no
8 * circumstances is the author responsible for the proper functioning

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

15 *
16 * Thanks to Charles Hannum for proving to me with example code that the
17 * NE1000/2000 support could be added with minimal impact. Without
18 * this, I wouldn't have proceeded in this direction.
19 *
20 */
21
22/*
23 * $Id: if_ed.c,v 1.23 1993/11/22 11:08:14 davidg Exp $
24 */
25
26/*
27 * Modification history
28 *
29 * Revision 2.14 1993/11/22 10:55:30 davidg
30 * change all splnet's to splimp's
31 *

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

180 u_char txb_next_tx; /* pointer to next buffer ready to xmit */
181 u_short txb_len[8]; /* buffered xmit buffer lengths */
182 u_char tx_page_start; /* first page of TX buffer area */
183 u_char rec_page_start; /* first page of RX ring-buffer */
184 u_char rec_page_stop; /* last page of RX ring-buffer */
185 u_char next_packet; /* pointer to next unread RX packet */
186} ed_softc[NED];
187
188int ed_attach(struct isa_device *);
189void ed_init(int);
190void edintr(int);
191int ed_ioctl(struct ifnet *, int, caddr_t);
192int ed_probe(struct isa_device *);
193void ed_start(struct ifnet *);
194void ed_reset(int, int);
195void ed_watchdog(int);
196static void ed_get_packet(struct ed_softc *, char *, int /*u_short*/);
197static void ed_stop(int);
198
199static inline void ed_rint();
200static inline void ed_xmit();
201static inline char *ed_ring_copy();
202
203void ed_pio_readmem(), ed_pio_writemem();
204u_short ed_pio_write_mbufs();
205
206extern int ether_output();

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

1114 (ifp->if_flags & IFF_ALTPHYS)) ? "tranceiver disabled" : "");
1115
1116 /*
1117 * If BPF is in the kernel, call the attach for it
1118 */
1119#if NBPFILTER > 0
1120 bpfattach(&sc->bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
1121#endif
1122 return 1;
1123}
1124
1125/*
1126 * Reset interface.
1127 */
1128void
1129ed_reset(unit, uban)
1130 int unit;
1131 int uban; /* XXX */
1132{
1133 int s;
1134
1135 s = splimp();
1136
1137 /*
1138 * Stop interface and re-initialize.
1139 */

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

1169 while (((inb(sc->nic_addr + ED_P0_ISR) & ED_ISR_RST) == 0) && --n);
1170
1171}
1172
1173/*
1174 * Device timeout/watchdog routine. Entered if the device neglects to
1175 * generate an interrupt after a transmit has been started on it.
1176 */
1177void
1178ed_watchdog(unit)
1179 int unit;
1180{
1181 struct ed_softc *sc = &ed_softc[unit];
1182
1183 log(LOG_ERR, "ed%d: device timeout\n", unit);
1184 ++sc->arpcom.ac_if.if_oerrors;
1185
1186 ed_reset(unit, 0);
1187}
1188
1189/*
1190 * Initialize device.
1191 */
1192void
1193ed_init(unit)
1194 int unit;
1195{
1196 struct ed_softc *sc = &ed_softc[unit];
1197 struct ifnet *ifp = &sc->arpcom.ac_if;
1198 int i, s;
1199 u_char command;
1200

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

1413 * Start output on interface.
1414 * We make two assumptions here:
1415 * 1) that the current priority is set to splimp _before_ this code
1416 * is called *and* is returned to the appropriate priority after
1417 * return
1418 * 2) that the IFF_OACTIVE flag is checked before this code is called
1419 * (i.e. that the output part of the interface is idle)
1420 */
1421void
1422ed_start(ifp)
1423 struct ifnet *ifp;
1424{
1425 struct ed_softc *sc = &ed_softc[ifp->if_unit];
1426 struct mbuf *m0, *m;
1427 caddr_t buffer;
1428 int len;
1429

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

1669 * Really BAD...probably indicates that the ring pointers
1670 * are corrupted. Also seen on early rev chips under
1671 * high load - the byte order of the length gets switched.
1672 */
1673 log(LOG_ERR,
1674 "ed%d: NIC memory corrupt - invalid packet length %d\n",
1675 unit, len);
1676 ++sc->arpcom.ac_if.if_ierrors;
1677 ed_reset(unit, 0);
1678 return;
1679 }
1680
1681 /*
1682 * Update next packet pointer
1683 */
1684 sc->next_packet = packet_hdr.next_packet;
1685

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

1711 outb(sc->nic_addr + ED_P0_CR, ED_CR_PAGE_1|ED_CR_RD2|ED_CR_STA);
1712 }
1713 }
1714}
1715
1716/*
1717 * Ethernet interface interrupt processor
1718 */
1719void
1720edintr(unit)
1721 int unit;
1722{
1723 struct ed_softc *sc = &ed_softc[unit];
1724 u_char isr;
1725
1726 /*
1727 * Set NIC to page 0 registers

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

1834#ifdef DIAGNOSTIC
1835 log(LOG_WARNING,
1836 "ed%d: warning - receiver ring buffer overrun\n",
1837 unit);
1838#endif
1839 /*
1840 * Stop/reset/re-init NIC
1841 */
1842 ed_reset(unit, 0);
1843 } else {
1844
1845 /*
1846 * Receiver Error. One or more of: CRC error, frame
1847 * alignment error FIFO overrun, or missed packet.
1848 */
1849 if (isr & ED_ISR_RXE) {
1850 ++sc->arpcom.ac_if.if_ierrors;

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

2057 (((caddr_t)(start)+(off))) - (sc)->mem_end \
2058 + (sc)->mem_ring: \
2059 ((caddr_t)(start)+(off)) ))
2060
2061/*
2062 * Retreive packet from shared memory and send to the next level up via
2063 * ether_input(). If there is a BPF listener, give a copy to BPF, too.
2064 */
2065static void
2066ed_get_packet(sc, buf, len)
2067 struct ed_softc *sc;
2068 char *buf;
2069 u_short len;
2070{
2071 struct ether_header *eh;
2072 struct mbuf *m, *head = 0, *ed_ring_to_mbuf();
2073 u_short off;
2074 int resid;
2075 u_short etype;
2076 struct trailer_header trailer_header;
2077
2078 /* Allocate a header mbuf */
2079 MGETHDR(m, M_DONTWAIT, MT_DATA);
2080 if (m == 0)

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

2385 * Not waiting causes really bad things to happen - like the NIC
2386 * irrecoverably jamming the ISA bus.
2387 */
2388 while (((inb(sc->nic_addr + ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) && --maxwait);
2389
2390 if (!maxwait) {
2391 log(LOG_WARNING, "ed%d: remote transmit DMA failed to complete\n",
2392 sc->arpcom.ac_if.if_unit);
2393 ed_reset(sc->arpcom.ac_if.if_unit, 0);
2394 }
2395
2396 return(len);
2397}
2398
2399/*
2400 * Given a source and destination address, copy 'amount' of a packet from
2401 * the ring buffer into a linear destination buffer. Takes into account

--- 89 unchanged lines hidden ---