Deleted Added
sdiff udiff text old ( 155881 ) new ( 158663 )
full compact
1/* $NetBSD: am7990.c,v 1.68 2005/12/11 12:21:25 christos Exp $ */
2
3/*-
4 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace

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

67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69 * SUCH DAMAGE.
70 *
71 * @(#)if_le.c 8.2 (Berkeley) 11/16/93
72 */
73
74#include <sys/cdefs.h>
75__FBSDID("$FreeBSD: head/sys/dev/le/am7990.c 155881 2006-02-21 20:20:43Z marius $");
76
77#include <sys/param.h>
78#include <sys/bus.h>
79#include <sys/endian.h>
80#include <sys/lock.h>
81#include <sys/mbuf.h>
82#include <sys/mutex.h>
83#include <sys/socket.h>
84
85#include <net/bpf.h>
86#include <net/ethernet.h>
87#include <net/if.h>
88#include <net/if_arp.h>
89#include <net/if_dl.h>
90#include <net/if_media.h>
91#include <net/if_var.h>
92
93#include <dev/le/lancereg.h>
94#include <dev/le/lancevar.h>
95#include <dev/le/am7990reg.h>
96#include <dev/le/am7990var.h>
97
98static void am7990_meminit(struct lance_softc *);
99static void am7990_rint(struct lance_softc *);
100static void am7990_tint(struct lance_softc *);

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

210 sizeof(tmd));
211 }
212}
213
214static void
215am7990_rint(struct lance_softc *sc)
216{
217 struct ifnet *ifp = sc->sc_ifp;
218 struct lermd rmd;
219 int bix, rp;
220
221 bix = sc->sc_last_rd;
222
223 /* Process all buffers with valid data. */
224 for (;;) {
225 rp = LE_RMDADDR(sc, bix);
226 (*sc->sc_copyfromdesc)(sc, &rmd, rp, sizeof(rmd));
227
228 if (rmd.rmd1_bits & LE_R1_OWN)
229 break;
230
231 if (rmd.rmd1_bits & LE_R1_ERR) {
232 if (rmd.rmd1_bits & LE_R1_ENP) {
233#ifdef LEDEBUG
234 if ((rmd.rmd1_bits & LE_R1_OFLO) == 0) {
235 if (rmd.rmd1_bits & LE_R1_FRAM)
236 if_printf(ifp,
237 "framing error\n");
238 if (rmd.rmd1_bits & LE_R1_CRC)
239 if_printf(ifp,
240 "crc mismatch\n");
241 }
242#endif
243 } else {
244 if (rmd.rmd1_bits & LE_R1_OFLO)
245 if_printf(ifp, "overflow\n");
246 }
247 if (rmd.rmd1_bits & LE_R1_BUFF)
248 if_printf(ifp, "receive buffer error\n");
249 ifp->if_ierrors++;
250 } else if ((rmd.rmd1_bits & (LE_R1_STP | LE_R1_ENP)) !=
251 (LE_R1_STP | LE_R1_ENP)) {
252 if_printf(ifp, "dropping chained buffer\n");
253 ifp->if_ierrors++;
254 } else {
255#ifdef LEDEBUG
256 if (sc->sc_flags & LE_DEBUG)
257 am7990_recv_print(sc, sc->sc_last_rd);
258#endif
259 lance_read(sc, LE_RBUFADDR(sc, bix),
260 (int)rmd.rmd3 - ETHER_CRC_LEN);
261 }
262
263 rmd.rmd1_bits = LE_R1_OWN;
264 rmd.rmd2 = -LEBLEN | LE_XMD2_ONES;
265 rmd.rmd3 = 0;
266 (*sc->sc_copytodesc)(sc, &rmd, rp, sizeof(rmd));
267
268#ifdef LEDEBUG
269 if (sc->sc_flags & LE_DEBUG)
270 if_printf(ifp, "sc->sc_last_rd = %x, rmd: "
271 "ladr %04x, hadr %02x, flags %02x, "
272 "bcnt %04x, mcnt %04x\n",
273 sc->sc_last_rd, rmd.rmd0, rmd.rmd1_hadr,
274 rmd.rmd1_bits, rmd.rmd2, rmd.rmd3);
275#endif
276
277 if (++bix == sc->sc_nrbuf)
278 bix = 0;
279 }
280
281 sc->sc_last_rd = bix;
282}
283
284static void
285am7990_tint(struct lance_softc *sc)
286{

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

387 if ((isr & LE_C0_INTR) == 0) {
388 LE_UNLOCK(sc);
389 return;
390 }
391
392 /*
393 * Clear interrupt source flags and turn off interrupts. If we
394 * don't clear these flags before processing their sources we
395 * could completely miss some interrupt events as the the NIC
396 * can change these flags while we're in this handler. We turn
397 * of interrupts while processing them so we don't get another
398 * one while we still process the previous one in ifp->if_input()
399 * with the driver lock dropped.
400 */
401 (*sc->sc_wrcsr)(sc, LE_CSR0, isr & ~(LE_C0_INEA | LE_C0_TDMD |
402 LE_C0_STOP | LE_C0_STRT | LE_C0_INIT));
403
404 if (isr & LE_C0_ERR) {
405 if (isr & LE_C0_BABL) {
406#ifdef LEDEBUG
407 if_printf(ifp, "babble\n");

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

524 tmd.tmd1_bits = LE_T1_OWN | LE_T1_STP | LE_T1_ENP;
525 tmd.tmd2 = -len | LE_XMD2_ONES;
526 tmd.tmd3 = 0;
527
528 (*sc->sc_copytodesc)(sc, &tmd, rp, sizeof(tmd));
529
530#ifdef LEDEBUG
531 if (sc->sc_flags & LE_DEBUG)
532 am7990_xmit_print(sc, sc->sc_last_td);
533#endif
534
535 (*sc->sc_wrcsr)(sc, LE_CSR0, LE_C0_INEA | LE_C0_TDMD);
536 enq++;
537
538 if (++bix == sc->sc_ntbuf)
539 bix = 0;
540

--- 59 unchanged lines hidden ---