if_qn.c revision 1.5 1 1.5 veego /* $NetBSD: if_qn.c,v 1.5 1996/04/21 21:11:50 veego Exp $ */
2 1.1 chopps
3 1.1 chopps /*
4 1.1 chopps * Copyright (c) 1995 Mika Kortelainen
5 1.1 chopps * All rights reserved.
6 1.1 chopps *
7 1.1 chopps * Redistribution and use in source and binary forms, with or without
8 1.1 chopps * modification, are permitted provided that the following conditions
9 1.1 chopps * are met:
10 1.1 chopps * 1. Redistributions of source code must retain the above copyright
11 1.1 chopps * notice, this list of conditions and the following disclaimer.
12 1.1 chopps * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 chopps * notice, this list of conditions and the following disclaimer in the
14 1.1 chopps * documentation and/or other materials provided with the distribution.
15 1.1 chopps * 3. All advertising materials mentioning features or use of this software
16 1.1 chopps * must display the following acknowledgement:
17 1.1 chopps * This product includes software developed by Mika Kortelainen
18 1.1 chopps * 4. The name of the author may not be used to endorse or promote products
19 1.1 chopps * derived from this software without specific prior written permission
20 1.1 chopps *
21 1.1 chopps * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 1.1 chopps * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.1 chopps * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.1 chopps * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.1 chopps * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.1 chopps * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.1 chopps * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.1 chopps * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.1 chopps * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.1 chopps * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.1 chopps *
32 1.1 chopps * Thanks for Aspecs Oy (Finland) for the data book for the NIC used
33 1.1 chopps * in this card and also many thanks for the Resource Management Force
34 1.1 chopps * (QuickNet card manufacturer) and especially Daniel Koch for providing
35 1.1 chopps * me with the necessary 'inside' information to write the driver.
36 1.1 chopps *
37 1.1 chopps * This is partly based on other code:
38 1.2 jtc * - if_ed.c: basic function structure for Ethernet driver and now also
39 1.2 jtc * qn_put() is done similarly, i.e. no extra packet buffers.
40 1.1 chopps *
41 1.1 chopps * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
42 1.1 chopps * adapters.
43 1.1 chopps *
44 1.1 chopps * Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
45 1.1 chopps *
46 1.1 chopps * Copyright (C) 1993, David Greenman. This software may be used,
47 1.1 chopps * modified, copied, distributed, and sold, in both source and binary
48 1.1 chopps * form provided that the above copyright and these terms are retained.
49 1.1 chopps * Under no circumstances is the author responsible for the proper
50 1.1 chopps * functioning of this software, nor does the author assume any
51 1.1 chopps * responsibility for damages incurred with its use.
52 1.1 chopps *
53 1.1 chopps * - if_es.c: used as an example of -current driver
54 1.1 chopps *
55 1.1 chopps * Copyright (c) 1995 Michael L. Hitch
56 1.1 chopps * All rights reserved.
57 1.1 chopps *
58 1.2 jtc * - if_fe.c: some ideas for error handling for qn_rint() which might
59 1.2 jtc * have fixed those random lock ups, too.
60 1.2 jtc *
61 1.2 jtc * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
62 1.2 jtc *
63 1.1 chopps *
64 1.1 chopps * TODO:
65 1.1 chopps * - add multicast support
66 1.1 chopps */
67 1.1 chopps
68 1.1 chopps #include "qn.h"
69 1.1 chopps #if NQN > 0
70 1.1 chopps
71 1.1 chopps #define QN_DEBUG
72 1.2 jtc #define QN_DEBUG1_no /* hides some old tests */
73 1.1 chopps
74 1.1 chopps #include "bpfilter.h"
75 1.1 chopps
76 1.1 chopps /*
77 1.2 jtc * Fujitsu MB86950 Ethernet Controller (as used in the QuickNet QN2000
78 1.2 jtc * Ethernet card)
79 1.1 chopps */
80 1.1 chopps
81 1.1 chopps #include <sys/param.h>
82 1.1 chopps #include <sys/systm.h>
83 1.1 chopps #include <sys/mbuf.h>
84 1.1 chopps #include <sys/buf.h>
85 1.1 chopps #include <sys/device.h>
86 1.1 chopps #include <sys/protosw.h>
87 1.1 chopps #include <sys/socket.h>
88 1.1 chopps #include <sys/syslog.h>
89 1.1 chopps #include <sys/ioctl.h>
90 1.1 chopps #include <sys/errno.h>
91 1.1 chopps
92 1.1 chopps #include <net/if.h>
93 1.1 chopps #include <net/netisr.h>
94 1.1 chopps #include <net/route.h>
95 1.1 chopps
96 1.1 chopps #ifdef INET
97 1.1 chopps #include <netinet/in.h>
98 1.1 chopps #include <netinet/in_systm.h>
99 1.1 chopps #include <netinet/in_var.h>
100 1.1 chopps #include <netinet/ip.h>
101 1.1 chopps #include <netinet/if_ether.h>
102 1.1 chopps #endif
103 1.1 chopps
104 1.1 chopps #ifdef NS
105 1.1 chopps #include <netns/ns.h>
106 1.1 chopps #include <netns/ns_if.h>
107 1.1 chopps #endif
108 1.1 chopps
109 1.1 chopps #include <machine/cpu.h>
110 1.1 chopps #include <machine/mtpr.h>
111 1.1 chopps #include <amiga/amiga/device.h>
112 1.1 chopps #include <amiga/amiga/isr.h>
113 1.1 chopps #include <amiga/dev/zbusvar.h>
114 1.1 chopps #include <amiga/dev/if_qnreg.h>
115 1.1 chopps
116 1.1 chopps
117 1.2 jtc #define ETHER_MIN_LEN 60
118 1.2 jtc #define ETHER_MAX_LEN 1514
119 1.2 jtc #define ETHER_HDR_SIZE 14
120 1.2 jtc #define NIC_R_MASK (R_INT_PKT_RDY | R_INT_ALG_ERR |\
121 1.2 jtc R_INT_CRC_ERR | R_INT_OVR_FLO)
122 1.2 jtc #define MAX_PACKETS 30 /* max number of packets read per interrupt */
123 1.1 chopps
124 1.1 chopps /*
125 1.1 chopps * Ethernet software status per interface
126 1.1 chopps *
127 1.1 chopps * Each interface is referenced by a network interface structure,
128 1.1 chopps * qn_if, which the routing code uses to locate the interface.
129 1.1 chopps * This structure contains the output queue for the interface, its address, ...
130 1.1 chopps */
131 1.1 chopps struct qn_softc {
132 1.1 chopps struct device sc_dev;
133 1.1 chopps struct isr sc_isr;
134 1.1 chopps struct arpcom sc_arpcom; /* Common ethernet structures */
135 1.1 chopps u_char volatile *sc_base;
136 1.1 chopps u_char volatile *sc_nic_base;
137 1.1 chopps u_short volatile *nic_fifo;
138 1.1 chopps u_short volatile *nic_r_status;
139 1.1 chopps u_short volatile *nic_t_status;
140 1.1 chopps u_short volatile *nic_r_mask;
141 1.1 chopps u_short volatile *nic_t_mask;
142 1.1 chopps u_short volatile *nic_r_mode;
143 1.1 chopps u_short volatile *nic_t_mode;
144 1.1 chopps u_short volatile *nic_reset;
145 1.1 chopps u_short volatile *nic_len;
146 1.1 chopps u_char transmit_pending;
147 1.1 chopps #if NBPFILTER > 0
148 1.1 chopps caddr_t sc_bpf;
149 1.1 chopps #endif
150 1.1 chopps } qn_softc[NQN];
151 1.1 chopps
152 1.1 chopps #if NBPFILTER > 0
153 1.1 chopps #include <net/bpf.h>
154 1.1 chopps #include <net/bpfdesc.h>
155 1.1 chopps #endif
156 1.1 chopps
157 1.1 chopps
158 1.1 chopps int qnmatch __P((struct device *, void *, void *));
159 1.1 chopps void qnattach __P((struct device *, struct device *, void *));
160 1.5 veego int qnintr __P((void *));
161 1.1 chopps int qnioctl __P((struct ifnet *, u_long, caddr_t));
162 1.1 chopps void qnstart __P((struct ifnet *));
163 1.1 chopps void qnwatchdog __P((int));
164 1.1 chopps void qnreset __P((struct qn_softc *));
165 1.1 chopps void qninit __P((struct qn_softc *));
166 1.1 chopps void qnstop __P((struct qn_softc *));
167 1.1 chopps static u_short qn_put __P((u_short volatile *, struct mbuf *));
168 1.2 jtc static void qn_rint __P((struct qn_softc *, u_short));
169 1.1 chopps static void qn_flush __P((struct qn_softc *));
170 1.5 veego static void inline word_copy_from_card __P((u_short volatile *, u_short *, u_short));
171 1.5 veego static void inline word_copy_to_card __P((u_short *, u_short volatile *, u_short));
172 1.5 veego static void qn_get_packet __P((struct qn_softc *, u_short));
173 1.2 jtc #ifdef QN_DEBUG1
174 1.2 jtc static void qn_dump __P((struct qn_softc *));
175 1.2 jtc #endif
176 1.1 chopps
177 1.4 thorpej struct cfattach qn_ca = {
178 1.4 thorpej sizeof(struct qn_softc), qnmatch, qnattach
179 1.4 thorpej };
180 1.4 thorpej
181 1.4 thorpej struct cfdriver qn_cd = {
182 1.4 thorpej NULL, "qn", DV_IFNET
183 1.1 chopps };
184 1.1 chopps
185 1.2 jtc
186 1.1 chopps int
187 1.1 chopps qnmatch(parent, match, aux)
188 1.1 chopps struct device *parent;
189 1.1 chopps void *match, *aux;
190 1.1 chopps {
191 1.1 chopps struct zbus_args *zap;
192 1.1 chopps
193 1.1 chopps zap = (struct zbus_args *)aux;
194 1.1 chopps
195 1.1 chopps /* RMF QuickNet QN2000 EtherNet card */
196 1.1 chopps if (zap->manid == 2011 && zap->prodid == 2)
197 1.1 chopps return (1);
198 1.1 chopps
199 1.1 chopps return (0);
200 1.1 chopps }
201 1.1 chopps
202 1.1 chopps /*
203 1.1 chopps * Interface exists: make available by filling in network interface
204 1.1 chopps * record. System will initialize the interface when it is ready
205 1.1 chopps * to accept packets.
206 1.1 chopps */
207 1.1 chopps void
208 1.1 chopps qnattach(parent, self, aux)
209 1.1 chopps struct device *parent, *self;
210 1.1 chopps void *aux;
211 1.1 chopps {
212 1.1 chopps struct zbus_args *zap;
213 1.1 chopps struct qn_softc *sc = (struct qn_softc *)self;
214 1.1 chopps struct ifnet *ifp = &sc->sc_arpcom.ac_if;
215 1.1 chopps
216 1.1 chopps zap = (struct zbus_args *)aux;
217 1.1 chopps
218 1.1 chopps sc->sc_base = zap->va;
219 1.1 chopps sc->sc_nic_base = sc->sc_base + QUICKNET_NIC_BASE;
220 1.1 chopps sc->nic_fifo = (u_short volatile *)(sc->sc_nic_base + NIC_BMPR0);
221 1.1 chopps sc->nic_len = (u_short volatile *)(sc->sc_nic_base + NIC_BMPR2);
222 1.1 chopps sc->nic_t_status = (u_short volatile *)(sc->sc_nic_base + NIC_DLCR0);
223 1.1 chopps sc->nic_r_status = (u_short volatile *)(sc->sc_nic_base + NIC_DLCR2);
224 1.1 chopps sc->nic_t_mask = (u_short volatile *)(sc->sc_nic_base + NIC_DLCR1);
225 1.1 chopps sc->nic_r_mask = (u_short volatile *)(sc->sc_nic_base + NIC_DLCR3);
226 1.1 chopps sc->nic_t_mode = (u_short volatile *)(sc->sc_nic_base + NIC_DLCR4);
227 1.1 chopps sc->nic_r_mode = (u_short volatile *)(sc->sc_nic_base + NIC_DLCR5);
228 1.1 chopps sc->nic_reset = (u_short volatile *)(sc->sc_nic_base + NIC_DLCR6);
229 1.1 chopps sc->transmit_pending = 0;
230 1.1 chopps
231 1.1 chopps /*
232 1.1 chopps * The ethernet address of the board (1st three bytes are the vendor
233 1.1 chopps * address, the rest is the serial number of the board).
234 1.1 chopps */
235 1.1 chopps sc->sc_arpcom.ac_enaddr[0] = 0x5c;
236 1.1 chopps sc->sc_arpcom.ac_enaddr[1] = 0x5c;
237 1.1 chopps sc->sc_arpcom.ac_enaddr[2] = 0x00;
238 1.1 chopps sc->sc_arpcom.ac_enaddr[3] = (zap->serno >> 16) & 0xff;
239 1.1 chopps sc->sc_arpcom.ac_enaddr[4] = (zap->serno >> 8) & 0xff;
240 1.1 chopps sc->sc_arpcom.ac_enaddr[5] = zap->serno & 0xff;
241 1.1 chopps
242 1.1 chopps /* set interface to stopped condition (reset) */
243 1.1 chopps qnstop(sc);
244 1.1 chopps
245 1.1 chopps ifp->if_unit = sc->sc_dev.dv_unit;
246 1.4 thorpej ifp->if_name = qn_cd.cd_name;
247 1.1 chopps ifp->if_ioctl = qnioctl;
248 1.1 chopps ifp->if_watchdog = qnwatchdog;
249 1.1 chopps ifp->if_output = ether_output;
250 1.1 chopps ifp->if_start = qnstart;
251 1.1 chopps /* XXX IFF_MULTICAST */
252 1.1 chopps ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS;
253 1.1 chopps ifp->if_mtu = ETHERMTU;
254 1.1 chopps
255 1.1 chopps /* Attach the interface. */
256 1.1 chopps if_attach(ifp);
257 1.1 chopps ether_ifattach(ifp);
258 1.1 chopps
259 1.1 chopps #ifdef QN_DEBUG
260 1.1 chopps printf(": hardware address %s\n", ether_sprintf(sc->sc_arpcom.ac_enaddr));
261 1.1 chopps #endif
262 1.1 chopps
263 1.1 chopps #if NBPFILTER > 0
264 1.1 chopps bpfattach(&sc->sc_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
265 1.1 chopps #endif
266 1.1 chopps
267 1.1 chopps sc->sc_isr.isr_intr = qnintr;
268 1.1 chopps sc->sc_isr.isr_arg = sc;
269 1.1 chopps sc->sc_isr.isr_ipl = 2;
270 1.1 chopps add_isr(&sc->sc_isr);
271 1.1 chopps }
272 1.1 chopps
273 1.1 chopps /*
274 1.1 chopps * Initialize device
275 1.1 chopps *
276 1.1 chopps */
277 1.1 chopps void
278 1.1 chopps qninit(sc)
279 1.1 chopps struct qn_softc *sc;
280 1.1 chopps {
281 1.1 chopps struct ifnet *ifp = &sc->sc_arpcom.ac_if;
282 1.1 chopps u_short i;
283 1.2 jtc static retry = 0;
284 1.1 chopps
285 1.2 jtc *sc->nic_r_mask = NIC_R_MASK;
286 1.2 jtc *sc->nic_t_mode = NO_LOOPBACK;
287 1.1 chopps
288 1.1 chopps if (sc->sc_arpcom.ac_if.if_flags & IFF_PROMISC) {
289 1.1 chopps *sc->nic_r_mode = PROMISCUOUS_MODE;
290 1.1 chopps log(LOG_INFO, "qn: Promiscuous mode (not tested)\n");
291 1.1 chopps } else
292 1.1 chopps *sc->nic_r_mode = NORMAL_MODE;
293 1.1 chopps
294 1.1 chopps /* Set physical ethernet address. */
295 1.1 chopps for (i = 0; i < ETHER_ADDR_LEN; i++)
296 1.2 jtc *((u_short volatile *)(sc->sc_nic_base+
297 1.2 jtc QNET_HARDWARE_ADDRESS+2*i)) =
298 1.1 chopps ((((u_short)sc->sc_arpcom.ac_enaddr[i]) << 8) |
299 1.1 chopps sc->sc_arpcom.ac_enaddr[i]);
300 1.1 chopps
301 1.1 chopps ifp->if_flags |= IFF_RUNNING;
302 1.1 chopps ifp->if_flags &= ~IFF_OACTIVE;
303 1.2 jtc sc->transmit_pending = 0;
304 1.1 chopps
305 1.1 chopps qn_flush(sc);
306 1.1 chopps
307 1.2 jtc /* QuickNet magic. Done ONLY once, otherwise a lockup occurs. */
308 1.2 jtc if (retry == 0) {
309 1.2 jtc *((u_short volatile *)(sc->sc_nic_base + QNET_MAGIC)) = 0;
310 1.2 jtc retry = 1;
311 1.2 jtc }
312 1.2 jtc
313 1.1 chopps /* Enable data link controller. */
314 1.1 chopps *sc->nic_reset = ENABLE_DLC;
315 1.1 chopps
316 1.1 chopps /* Attempt to start output, if any. */
317 1.1 chopps qnstart(ifp);
318 1.1 chopps }
319 1.1 chopps
320 1.1 chopps /*
321 1.1 chopps * Device timeout/watchdog routine. Entered if the device neglects to
322 1.1 chopps * generate an interrupt after a transmit has been started on it.
323 1.1 chopps */
324 1.1 chopps void
325 1.1 chopps qnwatchdog(unit)
326 1.1 chopps int unit;
327 1.1 chopps {
328 1.4 thorpej struct qn_softc *sc = qn_cd.cd_devs[unit];
329 1.1 chopps
330 1.2 jtc log(LOG_INFO, "qn: device timeout (watchdog)\n");
331 1.1 chopps ++sc->sc_arpcom.ac_if.if_oerrors;
332 1.1 chopps
333 1.1 chopps qnreset(sc);
334 1.1 chopps }
335 1.1 chopps
336 1.1 chopps /*
337 1.2 jtc * Flush card's buffer RAM.
338 1.1 chopps */
339 1.1 chopps static void
340 1.1 chopps qn_flush(sc)
341 1.1 chopps struct qn_softc *sc;
342 1.1 chopps {
343 1.2 jtc #if 1
344 1.1 chopps /* Read data until bus read error (i.e. buffer empty). */
345 1.2 jtc while (!(*sc->nic_r_status & R_BUS_RD_ERR))
346 1.1 chopps (void)(*sc->nic_fifo);
347 1.2 jtc #else
348 1.2 jtc /* Read data twice to clear some internal pipelines. */
349 1.2 jtc (void)(*sc->nic_fifo);
350 1.2 jtc (void)(*sc->nic_fifo);
351 1.1 chopps #endif
352 1.1 chopps
353 1.1 chopps /* Clear bus read error. */
354 1.1 chopps *sc->nic_r_status = R_BUS_RD_ERR;
355 1.1 chopps }
356 1.1 chopps
357 1.1 chopps /*
358 1.2 jtc * Reset the interface.
359 1.1 chopps *
360 1.1 chopps */
361 1.1 chopps void
362 1.1 chopps qnreset(sc)
363 1.1 chopps struct qn_softc *sc;
364 1.1 chopps {
365 1.1 chopps int s;
366 1.1 chopps
367 1.3 mycroft s = splnet();
368 1.1 chopps qnstop(sc);
369 1.1 chopps qninit(sc);
370 1.1 chopps splx(s);
371 1.1 chopps }
372 1.1 chopps
373 1.1 chopps /*
374 1.2 jtc * Take interface offline.
375 1.1 chopps */
376 1.1 chopps void
377 1.1 chopps qnstop(sc)
378 1.1 chopps struct qn_softc *sc;
379 1.1 chopps {
380 1.1 chopps
381 1.1 chopps /* Stop the interface. */
382 1.2 jtc *sc->nic_reset = DISABLE_DLC;
383 1.2 jtc delay(200);
384 1.2 jtc *sc->nic_t_status = CLEAR_T_ERR;
385 1.2 jtc *sc->nic_t_mask = CLEAR_T_MASK;
386 1.2 jtc *sc->nic_r_status = CLEAR_R_ERR;
387 1.2 jtc *sc->nic_r_mask = CLEAR_R_MASK;
388 1.2 jtc
389 1.2 jtc /* Turn DMA off */
390 1.2 jtc *((u_short volatile *)(sc->sc_nic_base + NIC_BMPR4)) = 0;
391 1.1 chopps
392 1.2 jtc /* Accept no packets. */
393 1.2 jtc *sc->nic_r_mode = 0;
394 1.2 jtc *sc->nic_t_mode = 0;
395 1.1 chopps
396 1.1 chopps qn_flush(sc);
397 1.1 chopps }
398 1.1 chopps
399 1.1 chopps /*
400 1.1 chopps * Start output on interface. Get another datagram to send
401 1.1 chopps * off the interface queue, and copy it to the
402 1.1 chopps * interface before starting the output.
403 1.1 chopps *
404 1.1 chopps * This assumes that it is called inside a critical section...
405 1.1 chopps *
406 1.1 chopps */
407 1.1 chopps void
408 1.1 chopps qnstart(ifp)
409 1.1 chopps struct ifnet *ifp;
410 1.1 chopps {
411 1.4 thorpej struct qn_softc *sc = qn_cd.cd_devs[ifp->if_unit];
412 1.1 chopps struct mbuf *m;
413 1.1 chopps u_short len;
414 1.2 jtc int timout = 60000;
415 1.2 jtc
416 1.1 chopps
417 1.2 jtc if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
418 1.1 chopps return;
419 1.1 chopps
420 1.1 chopps IF_DEQUEUE(&sc->sc_arpcom.ac_if.if_snd, m);
421 1.1 chopps if (m == 0)
422 1.1 chopps return;
423 1.1 chopps
424 1.1 chopps #if NBPFILTER > 0
425 1.1 chopps /*
426 1.1 chopps * If bpf is listening on this interface, let it
427 1.1 chopps * see the packet before we commit it to the wire
428 1.1 chopps *
429 1.1 chopps * (can't give the copy in QuickNet card RAM to bpf, because
430 1.1 chopps * that RAM is not visible to the host but is read from FIFO)
431 1.1 chopps *
432 1.1 chopps */
433 1.1 chopps log(LOG_INFO, "NBPFILTER... no-one has tested this with qn.\n");
434 1.1 chopps if (sc->sc_bpf)
435 1.1 chopps bpf_mtap(sc->sc_bpf, m);
436 1.1 chopps #endif
437 1.1 chopps len = qn_put(sc->nic_fifo, m);
438 1.2 jtc m_freem(m);
439 1.1 chopps
440 1.1 chopps /*
441 1.2 jtc * Really transmit the packet.
442 1.1 chopps */
443 1.1 chopps
444 1.2 jtc /* Set packet length (byte-swapped). */
445 1.1 chopps len = ((len >> 8) & 0x0007) | TRANSMIT_START | ((len & 0x00ff) << 8);
446 1.1 chopps *sc->nic_len = len;
447 1.1 chopps
448 1.2 jtc /* Wait for the packet to really leave. */
449 1.2 jtc while (!(*sc->nic_t_status & T_TMT_OK) && --timout) {
450 1.2 jtc if ((timout % 10000) == 0)
451 1.2 jtc log(LOG_INFO, "qn: timout...\n");
452 1.2 jtc }
453 1.2 jtc
454 1.1 chopps if (timout == 0)
455 1.1 chopps /* Maybe we should try to recover from this one? */
456 1.2 jtc /* But now, let's just fall thru and hope the best... */
457 1.2 jtc log(LOG_INFO, "qn: transmit timout (fatal?)\n");
458 1.1 chopps
459 1.1 chopps sc->transmit_pending = 1;
460 1.1 chopps *sc->nic_t_mask = INT_TMT_OK | INT_SIXTEEN_COL;
461 1.1 chopps
462 1.1 chopps sc->sc_arpcom.ac_if.if_flags |= IFF_OACTIVE;
463 1.1 chopps ifp->if_timer = 2;
464 1.1 chopps }
465 1.1 chopps
466 1.1 chopps /*
467 1.1 chopps * Memory copy, copies word at a time
468 1.1 chopps */
469 1.1 chopps static void inline
470 1.1 chopps word_copy_from_card(card, b, len)
471 1.1 chopps u_short volatile *card;
472 1.1 chopps u_short *b, len;
473 1.1 chopps {
474 1.1 chopps register u_short l = len/2;
475 1.1 chopps
476 1.1 chopps while (l--)
477 1.1 chopps *b++ = *card;
478 1.1 chopps }
479 1.1 chopps
480 1.1 chopps static void inline
481 1.1 chopps word_copy_to_card(a, card, len)
482 1.5 veego u_short *a;
483 1.1 chopps u_short volatile *card;
484 1.5 veego u_short len;
485 1.1 chopps {
486 1.1 chopps register u_short l = len/2;
487 1.1 chopps
488 1.1 chopps while (l--)
489 1.1 chopps *card = *a++;
490 1.1 chopps }
491 1.1 chopps
492 1.1 chopps /*
493 1.1 chopps * Copy packet from mbuf to the board memory
494 1.1 chopps *
495 1.1 chopps * Uses an extra buffer/extra memory copy,
496 1.1 chopps * unless the whole packet fits in one mbuf.
497 1.1 chopps *
498 1.1 chopps */
499 1.1 chopps static u_short
500 1.1 chopps qn_put(addr, m)
501 1.1 chopps u_short volatile *addr;
502 1.1 chopps struct mbuf *m;
503 1.1 chopps {
504 1.5 veego u_short *data, savebyte[2];
505 1.2 jtc int len, wantbyte;
506 1.2 jtc u_short totlen;
507 1.2 jtc
508 1.2 jtc totlen = wantbyte = 0;
509 1.2 jtc
510 1.2 jtc for (; m != NULL; m = m->m_next) {
511 1.5 veego data = mtod(m, u_short *);
512 1.2 jtc len = m->m_len;
513 1.2 jtc totlen += len;
514 1.2 jtc if (len > 0) {
515 1.2 jtc /* Finish the last word. */
516 1.2 jtc if (wantbyte) {
517 1.2 jtc savebyte[1] = *data;
518 1.2 jtc *addr = *((u_short *)savebyte);
519 1.2 jtc data++;
520 1.2 jtc len--;
521 1.2 jtc wantbyte = 0;
522 1.2 jtc }
523 1.2 jtc /* Output contiguous words. */
524 1.2 jtc if (len > 1) {
525 1.2 jtc word_copy_to_card(data, addr, len);
526 1.2 jtc data += len & ~1;
527 1.2 jtc len &= 1;
528 1.2 jtc }
529 1.2 jtc /* Save last byte, if necessary. */
530 1.2 jtc if (len == 1) {
531 1.2 jtc savebyte[0] = *data;
532 1.2 jtc wantbyte = 1;
533 1.2 jtc }
534 1.2 jtc }
535 1.2 jtc }
536 1.1 chopps
537 1.2 jtc if (wantbyte) {
538 1.2 jtc savebyte[1] = 0;
539 1.2 jtc *addr = *((u_short *)savebyte);
540 1.2 jtc }
541 1.1 chopps
542 1.2 jtc if(totlen < ETHER_MIN_LEN) {
543 1.2 jtc /*
544 1.2 jtc * Fill the rest of the packet with zeros.
545 1.2 jtc * N.B.: This is required! Otherwise MB86950 fails.
546 1.2 jtc */
547 1.2 jtc for(len = totlen + 1; len < ETHER_MIN_LEN; len += 2)
548 1.2 jtc *addr = (u_short)0x0000;
549 1.2 jtc totlen = ETHER_MIN_LEN;
550 1.1 chopps }
551 1.1 chopps
552 1.2 jtc return (totlen);
553 1.1 chopps }
554 1.1 chopps
555 1.1 chopps /*
556 1.2 jtc * Copy packet from board RAM.
557 1.1 chopps *
558 1.1 chopps * Trailers not supported.
559 1.1 chopps *
560 1.1 chopps */
561 1.1 chopps static void
562 1.1 chopps qn_get_packet(sc, len)
563 1.1 chopps struct qn_softc *sc;
564 1.1 chopps u_short len;
565 1.1 chopps {
566 1.1 chopps register u_short volatile *nic_fifo_ptr = sc->nic_fifo;
567 1.1 chopps struct ether_header *eh;
568 1.2 jtc struct mbuf *m, *dst, *head = NULL;
569 1.1 chopps register u_short len1;
570 1.1 chopps u_short amount;
571 1.1 chopps
572 1.1 chopps /* Allocate header mbuf. */
573 1.1 chopps MGETHDR(m, M_DONTWAIT, MT_DATA);
574 1.2 jtc if (m == NULL)
575 1.1 chopps goto bad;
576 1.1 chopps
577 1.2 jtc /*
578 1.2 jtc * Round len to even value.
579 1.2 jtc */
580 1.2 jtc if (len & 1)
581 1.2 jtc len++;
582 1.2 jtc
583 1.1 chopps m->m_pkthdr.rcvif = &sc->sc_arpcom.ac_if;
584 1.1 chopps m->m_pkthdr.len = len;
585 1.1 chopps m->m_len = 0;
586 1.1 chopps head = m;
587 1.1 chopps
588 1.1 chopps eh = mtod(head, struct ether_header *);
589 1.1 chopps
590 1.1 chopps word_copy_from_card(nic_fifo_ptr,
591 1.1 chopps mtod(head, u_short *),
592 1.1 chopps sizeof(struct ether_header));
593 1.1 chopps
594 1.1 chopps head->m_len += sizeof(struct ether_header);
595 1.1 chopps len -= sizeof(struct ether_header);
596 1.1 chopps
597 1.1 chopps while (len > 0) {
598 1.1 chopps len1 = len;
599 1.1 chopps
600 1.1 chopps amount = M_TRAILINGSPACE(m);
601 1.1 chopps if (amount == 0) {
602 1.2 jtc /* Allocate another mbuf. */
603 1.1 chopps dst = m;
604 1.1 chopps MGET(m, M_DONTWAIT, MT_DATA);
605 1.2 jtc if (m == NULL)
606 1.1 chopps goto bad;
607 1.1 chopps
608 1.1 chopps if (len1 >= MINCLSIZE)
609 1.1 chopps MCLGET(m, M_DONTWAIT);
610 1.1 chopps
611 1.1 chopps m->m_len = 0;
612 1.1 chopps dst->m_next = m;
613 1.1 chopps
614 1.1 chopps amount = M_TRAILINGSPACE(m);
615 1.1 chopps }
616 1.1 chopps
617 1.2 jtc if (amount < len1)
618 1.1 chopps len1 = amount;
619 1.2 jtc
620 1.1 chopps word_copy_from_card(nic_fifo_ptr,
621 1.1 chopps (u_short *)(mtod(m, caddr_t) + m->m_len),
622 1.2 jtc len1);
623 1.1 chopps m->m_len += len1;
624 1.1 chopps len -= len1;
625 1.1 chopps }
626 1.1 chopps
627 1.1 chopps #if NBPFILTER > 0
628 1.1 chopps log(LOG_INFO, "qn: Beware, an untested code section\n");
629 1.1 chopps if (sc->sc_bpf) {
630 1.1 chopps bpf_mtap(sc->sc_bpf, head);
631 1.1 chopps
632 1.1 chopps /*
633 1.1 chopps * The interface cannot be in promiscuous mode if there are
634 1.1 chopps * no BPF listeners. And in prom. mode we have to check
635 1.1 chopps * if the packet is really ours...
636 1.1 chopps */
637 1.1 chopps if ((sc->sc_arpcom.ac_if.if_flags & IFF_PROMISC) &&
638 1.1 chopps (eh->ether_dhost[0] & 1) == 0 && /* not bcast or mcast */
639 1.1 chopps bcmp(eh->ether_dhost,
640 1.1 chopps sc->sc_arpcom.ac_enaddr,
641 1.1 chopps ETHER_ADDR_LEN) != 0) {
642 1.1 chopps m_freem(head);
643 1.1 chopps return;
644 1.1 chopps }
645 1.1 chopps }
646 1.1 chopps #endif
647 1.1 chopps
648 1.1 chopps m_adj(head, sizeof(struct ether_header));
649 1.1 chopps ether_input(&sc->sc_arpcom.ac_if, eh, head);
650 1.1 chopps return;
651 1.1 chopps
652 1.1 chopps bad:
653 1.2 jtc if (head) {
654 1.1 chopps m_freem(head);
655 1.2 jtc log(LOG_INFO, "qn_get_packet: mbuf alloc failed\n");
656 1.2 jtc }
657 1.1 chopps }
658 1.1 chopps
659 1.1 chopps /*
660 1.1 chopps * Ethernet interface receiver interrupt.
661 1.1 chopps */
662 1.1 chopps static void
663 1.2 jtc qn_rint(sc, rstat)
664 1.1 chopps struct qn_softc *sc;
665 1.2 jtc u_short rstat;
666 1.1 chopps {
667 1.1 chopps int i;
668 1.1 chopps u_short len, status;
669 1.1 chopps
670 1.2 jtc /* Clear the status register. */
671 1.2 jtc *sc->nic_r_status = CLEAR_R_ERR;
672 1.2 jtc
673 1.1 chopps /*
674 1.2 jtc * Was there some error?
675 1.2 jtc * Some of them are senseless because they are masked off.
676 1.2 jtc * XXX
677 1.1 chopps */
678 1.2 jtc if (rstat & 0x0101) {
679 1.1 chopps #ifdef QN_DEBUG
680 1.2 jtc log(LOG_INFO, "Overflow\n");
681 1.1 chopps #endif
682 1.2 jtc ++sc->sc_arpcom.ac_if.if_ierrors;
683 1.2 jtc }
684 1.2 jtc if (rstat & 0x0202) {
685 1.1 chopps #ifdef QN_DEBUG
686 1.2 jtc log(LOG_INFO, "CRC Error\n");
687 1.1 chopps #endif
688 1.2 jtc ++sc->sc_arpcom.ac_if.if_ierrors;
689 1.2 jtc }
690 1.2 jtc if (rstat & 0x0404) {
691 1.1 chopps #ifdef QN_DEBUG
692 1.2 jtc log(LOG_INFO, "Alignment error\n");
693 1.1 chopps #endif
694 1.2 jtc ++sc->sc_arpcom.ac_if.if_ierrors;
695 1.2 jtc }
696 1.2 jtc if (rstat & 0x0808) {
697 1.2 jtc /* Short packet (these may occur and are
698 1.2 jtc * no reason to worry about - or maybe
699 1.2 jtc * they are?).
700 1.2 jtc */
701 1.1 chopps #ifdef QN_DEBUG
702 1.2 jtc log(LOG_INFO, "Short packet\n");
703 1.1 chopps #endif
704 1.2 jtc ++sc->sc_arpcom.ac_if.if_ierrors;
705 1.2 jtc }
706 1.2 jtc if (rstat & 0x4040) {
707 1.1 chopps #ifdef QN_DEBUG
708 1.2 jtc log(LOG_INFO, "Bus read error\n");
709 1.1 chopps #endif
710 1.2 jtc ++sc->sc_arpcom.ac_if.if_ierrors;
711 1.2 jtc qnreset(sc);
712 1.2 jtc }
713 1.1 chopps
714 1.2 jtc /*
715 1.2 jtc * Read at most MAX_PACKETS packets per interrupt
716 1.2 jtc */
717 1.2 jtc for (i = 0; i < MAX_PACKETS; i++) {
718 1.2 jtc if (*sc->nic_r_mode & RM_BUF_EMP)
719 1.2 jtc /* Buffer empty. */
720 1.2 jtc break;
721 1.1 chopps
722 1.2 jtc /*
723 1.2 jtc * Read the first word: upper byte contains useful
724 1.2 jtc * information.
725 1.2 jtc */
726 1.2 jtc status = *sc->nic_fifo;
727 1.2 jtc if ((status & 0x7000) != 0x2000) {
728 1.2 jtc log(LOG_INFO, "qn: ERROR: status=%04x\n", status);
729 1.2 jtc continue;
730 1.2 jtc }
731 1.2 jtc
732 1.2 jtc /*
733 1.2 jtc * Read packet length (byte-swapped).
734 1.2 jtc * CRC is stripped off by the NIC.
735 1.2 jtc */
736 1.2 jtc len = *sc->nic_fifo;
737 1.2 jtc len = ((len << 8) & 0xff00) | ((len >> 8) & 0x00ff);
738 1.1 chopps
739 1.2 jtc #ifdef QN_DEBUG
740 1.2 jtc if (len > ETHER_MAX_LEN || len < ETHER_HDR_SIZE) {
741 1.2 jtc log(LOG_WARNING,
742 1.2 jtc "%s: received a %s packet? (%u bytes)\n",
743 1.2 jtc sc->sc_dev.dv_xname,
744 1.2 jtc len < ETHER_HDR_SIZE ? "partial" : "big", len);
745 1.2 jtc ++sc->sc_arpcom.ac_if.if_ierrors;
746 1.2 jtc continue;
747 1.1 chopps }
748 1.2 jtc #endif
749 1.2 jtc #ifdef QN_DEBUG
750 1.2 jtc if (len < ETHER_MIN_LEN)
751 1.2 jtc log(LOG_WARNING,
752 1.2 jtc "%s: received a short packet? (%u bytes)\n",
753 1.2 jtc sc->sc_dev.dv_xname, len);
754 1.2 jtc #endif
755 1.2 jtc
756 1.2 jtc /* Read the packet. */
757 1.2 jtc qn_get_packet(sc, len);
758 1.2 jtc
759 1.2 jtc ++sc->sc_arpcom.ac_if.if_ipackets;
760 1.1 chopps }
761 1.1 chopps
762 1.2 jtc #ifdef QN_DEBUG
763 1.2 jtc /* This print just to see whether MAX_PACKETS is large enough. */
764 1.2 jtc if (i == MAX_PACKETS)
765 1.2 jtc log(LOG_INFO, "used all the %d loops\n", MAX_PACKETS);
766 1.2 jtc #endif
767 1.1 chopps }
768 1.1 chopps
769 1.1 chopps /*
770 1.1 chopps * Our interrupt routine
771 1.1 chopps */
772 1.1 chopps int
773 1.5 veego qnintr(arg)
774 1.5 veego void *arg;
775 1.1 chopps {
776 1.5 veego struct qn_softc *sc = arg;
777 1.2 jtc u_short tint, rint, tintmask;
778 1.2 jtc char return_tintmask = 0;
779 1.1 chopps
780 1.1 chopps /*
781 1.1 chopps * If the driver has not been initialized, just return immediately.
782 1.1 chopps * This also happens if there is no QuickNet board present.
783 1.1 chopps */
784 1.1 chopps if (sc->sc_base == NULL)
785 1.1 chopps return (0);
786 1.1 chopps
787 1.1 chopps /* Get interrupt statuses and masks. */
788 1.2 jtc rint = (*sc->nic_r_status) & NIC_R_MASK;
789 1.1 chopps tintmask = *sc->nic_t_mask;
790 1.2 jtc tint = (*sc->nic_t_status) & tintmask;
791 1.2 jtc if (tint == 0 && rint == 0)
792 1.1 chopps return (0);
793 1.1 chopps
794 1.2 jtc /* Disable interrupts so that we won't miss anything. */
795 1.1 chopps *sc->nic_r_mask = CLEAR_R_MASK;
796 1.2 jtc *sc->nic_t_mask = CLEAR_T_MASK;
797 1.1 chopps
798 1.1 chopps /*
799 1.1 chopps * Handle transmitter interrupts. Some of them are not asked for
800 1.1 chopps * but do happen, anyway.
801 1.1 chopps */
802 1.2 jtc
803 1.2 jtc if (tint != 0) {
804 1.2 jtc /* Clear transmit interrupt status. */
805 1.1 chopps *sc->nic_t_status = CLEAR_T_ERR;
806 1.2 jtc
807 1.1 chopps if (sc->transmit_pending && (tint & T_TMT_OK)) {
808 1.1 chopps sc->transmit_pending = 0;
809 1.1 chopps /*
810 1.1 chopps * Update total number of successfully
811 1.1 chopps * transmitted packets.
812 1.1 chopps */
813 1.1 chopps sc->sc_arpcom.ac_if.if_opackets++;
814 1.1 chopps }
815 1.1 chopps
816 1.1 chopps if (tint & T_SIXTEEN_COL) {
817 1.1 chopps /*
818 1.1 chopps * 16 collision (i.e., packet lost).
819 1.1 chopps */
820 1.1 chopps log(LOG_INFO, "qn: 16 collision - packet lost\n");
821 1.2 jtc #ifdef QN_DEBUG1
822 1.2 jtc qn_dump(sc);
823 1.2 jtc #endif
824 1.1 chopps sc->sc_arpcom.ac_if.if_oerrors++;
825 1.1 chopps sc->sc_arpcom.ac_if.if_collisions += 16;
826 1.1 chopps sc->transmit_pending = 0;
827 1.1 chopps }
828 1.1 chopps
829 1.1 chopps if (sc->transmit_pending) {
830 1.1 chopps log(LOG_INFO, "qn:still pending...\n");
831 1.2 jtc
832 1.2 jtc /* Must return transmission interrupt mask. */
833 1.2 jtc return_tintmask = 1;
834 1.1 chopps } else {
835 1.1 chopps sc->sc_arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
836 1.1 chopps
837 1.1 chopps /* Clear watchdog timer. */
838 1.1 chopps sc->sc_arpcom.ac_if.if_timer = 0;
839 1.1 chopps }
840 1.2 jtc } else
841 1.2 jtc return_tintmask = 1;
842 1.1 chopps
843 1.1 chopps /*
844 1.1 chopps * Handle receiver interrupts.
845 1.1 chopps */
846 1.2 jtc if (rint != 0)
847 1.2 jtc qn_rint(sc, rint);
848 1.1 chopps
849 1.1 chopps if ((sc->sc_arpcom.ac_if.if_flags & IFF_OACTIVE) == 0)
850 1.1 chopps qnstart(&sc->sc_arpcom.ac_if);
851 1.2 jtc else if (return_tintmask == 1)
852 1.2 jtc *sc->nic_t_mask = tintmask;
853 1.2 jtc
854 1.2 jtc /* Set receive interrupt mask back. */
855 1.2 jtc *sc->nic_r_mask = NIC_R_MASK;
856 1.1 chopps
857 1.1 chopps return (1);
858 1.1 chopps }
859 1.1 chopps
860 1.1 chopps /*
861 1.1 chopps * Process an ioctl request. This code needs some work - it looks pretty ugly.
862 1.1 chopps * I somehow think that this is quite a common excuse... ;-)
863 1.1 chopps */
864 1.1 chopps int
865 1.1 chopps qnioctl(ifp, command, data)
866 1.1 chopps register struct ifnet *ifp;
867 1.1 chopps u_long command;
868 1.1 chopps caddr_t data;
869 1.1 chopps {
870 1.4 thorpej struct qn_softc *sc = qn_cd.cd_devs[ifp->if_unit];
871 1.1 chopps register struct ifaddr *ifa = (struct ifaddr *)data;
872 1.1 chopps #if 0
873 1.1 chopps struct ifreg *ifr = (struct ifreg *)data;
874 1.1 chopps #endif
875 1.1 chopps int s, error = 0;
876 1.1 chopps
877 1.3 mycroft s = splnet();
878 1.1 chopps
879 1.1 chopps switch (command) {
880 1.1 chopps
881 1.1 chopps case SIOCSIFADDR:
882 1.1 chopps ifp->if_flags |= IFF_UP;
883 1.1 chopps
884 1.1 chopps switch (ifa->ifa_addr->sa_family) {
885 1.1 chopps #ifdef INET
886 1.1 chopps case AF_INET:
887 1.2 jtc qnstop(sc);
888 1.1 chopps qninit(sc);
889 1.1 chopps arp_ifinit(&sc->sc_arpcom, ifa);
890 1.1 chopps break;
891 1.1 chopps #endif
892 1.1 chopps #ifdef NS
893 1.1 chopps case AF_NS:
894 1.1 chopps {
895 1.1 chopps register struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr);
896 1.1 chopps
897 1.1 chopps if (ns_nullhost(*ina))
898 1.1 chopps ina->x_host =
899 1.5 veego *(union ns_host *)(sc->sc_arpcom.ac_enaddr);
900 1.1 chopps else
901 1.1 chopps bcopy(ina->x_host.c_host,
902 1.1 chopps sc->sc_arpcom.ac_enaddr,
903 1.1 chopps sizeof(sc->sc_arpcom.ac_enaddr));
904 1.2 jtc qnstop(sc);
905 1.1 chopps qninit(sc);
906 1.1 chopps break;
907 1.1 chopps }
908 1.1 chopps #endif
909 1.1 chopps default:
910 1.1 chopps log(LOG_INFO, "qn:sa_family:default (not tested)\n");
911 1.2 jtc qnstop(sc);
912 1.1 chopps qninit(sc);
913 1.1 chopps break;
914 1.1 chopps }
915 1.1 chopps break;
916 1.1 chopps
917 1.1 chopps case SIOCSIFFLAGS:
918 1.1 chopps if ((ifp->if_flags & IFF_UP) == 0 &&
919 1.1 chopps (ifp->if_flags & IFF_RUNNING) != 0) {
920 1.1 chopps /*
921 1.1 chopps * If interface is marked down and it is running, then
922 1.1 chopps * stop it.
923 1.1 chopps */
924 1.2 jtc #ifdef QN_DEBUG1
925 1.2 jtc qn_dump(sc);
926 1.2 jtc #endif
927 1.1 chopps qnstop(sc);
928 1.1 chopps ifp->if_flags &= ~IFF_RUNNING;
929 1.1 chopps } else if ((ifp->if_flags & IFF_UP) != 0 &&
930 1.2 jtc (ifp->if_flags & IFF_RUNNING) == 0) {
931 1.1 chopps /*
932 1.1 chopps * If interface is marked up and it is stopped, then
933 1.1 chopps * start it.
934 1.1 chopps */
935 1.1 chopps qninit(sc);
936 1.2 jtc } else {
937 1.1 chopps /*
938 1.1 chopps * Something else... we won't do anything so we won't
939 1.1 chopps * break anything (hope so).
940 1.1 chopps */
941 1.2 jtc #ifdef QN_DEBUG1
942 1.2 jtc log(LOG_INFO, "Else branch...\n");
943 1.2 jtc #endif
944 1.1 chopps }
945 1.1 chopps break;
946 1.1 chopps
947 1.1 chopps case SIOCADDMULTI:
948 1.1 chopps case SIOCDELMULTI:
949 1.1 chopps log(LOG_INFO, "qnioctl: multicast not done yet\n");
950 1.1 chopps #if 0
951 1.1 chopps error = (command == SIOCADDMULTI) ?
952 1.1 chopps ether_addmulti(ifr, &sc->sc_arpcom) :
953 1.1 chopps ether_delmulti(ifr, &sc->sc_arpcom);
954 1.1 chopps
955 1.1 chopps if (error == ENETRESET) {
956 1.1 chopps /*
957 1.1 chopps * Multicast list has changed; set the hardware filter
958 1.1 chopps * accordingly.
959 1.1 chopps */
960 1.1 chopps log(LOG_INFO, "qnioctl: multicast not done yet\n");
961 1.1 chopps error = 0;
962 1.1 chopps }
963 1.1 chopps #else
964 1.1 chopps error = EINVAL;
965 1.1 chopps #endif
966 1.1 chopps break;
967 1.1 chopps
968 1.1 chopps default:
969 1.1 chopps log(LOG_INFO, "qnioctl: default\n");
970 1.1 chopps error = EINVAL;
971 1.1 chopps }
972 1.1 chopps
973 1.2 jtc splx(s);
974 1.1 chopps return (error);
975 1.1 chopps }
976 1.2 jtc
977 1.2 jtc /*
978 1.2 jtc * Dump some register information.
979 1.2 jtc */
980 1.2 jtc #ifdef QN_DEBUG1
981 1.2 jtc static void
982 1.2 jtc qn_dump(sc)
983 1.2 jtc struct qn_softc *sc;
984 1.2 jtc {
985 1.2 jtc
986 1.2 jtc log(LOG_INFO, "t_status : %04x\n", *sc->nic_t_status);
987 1.2 jtc log(LOG_INFO, "t_mask : %04x\n", *sc->nic_t_mask);
988 1.2 jtc log(LOG_INFO, "t_mode : %04x\n", *sc->nic_t_mode);
989 1.2 jtc log(LOG_INFO, "r_status : %04x\n", *sc->nic_r_status);
990 1.2 jtc log(LOG_INFO, "r_mask : %04x\n", *sc->nic_r_mask);
991 1.2 jtc log(LOG_INFO, "r_mode : %04x\n", *sc->nic_r_mode);
992 1.2 jtc log(LOG_INFO, "pending : %02x\n", sc->transmit_pending);
993 1.2 jtc log(LOG_INFO, "if_flags : %04x\n", sc->sc_arpcom.ac_if.if_flags);
994 1.2 jtc }
995 1.2 jtc #endif
996 1.1 chopps
997 1.1 chopps #endif /* NQN > 0 */
998