if_ec.c revision 1.18 1 /* $NetBSD: if_ec.c,v 1.18 2010/04/05 07:19:32 joerg Exp $ */
2
3 /*
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matthew Fredette.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /*
33 * 3Com 3C400 device driver
34 */
35
36 #include <sys/cdefs.h>
37 __KERNEL_RCSID(0, "$NetBSD: if_ec.c,v 1.18 2010/04/05 07:19:32 joerg Exp $");
38
39 #include "opt_inet.h"
40 #include "opt_ns.h"
41 #include "rnd.h"
42
43 #include <sys/param.h>
44 #include <sys/systm.h>
45 #include <sys/errno.h>
46 #include <sys/ioctl.h>
47 #include <sys/mbuf.h>
48 #include <sys/socket.h>
49 #include <sys/syslog.h>
50 #include <sys/device.h>
51 #include <sys/endian.h>
52 #if NRND > 0
53 #include <sys/rnd.h>
54 #endif
55
56 #include <net/if.h>
57 #include <net/if_dl.h>
58 #include <net/if_types.h>
59
60 #include <net/if_ether.h>
61 #include <net/if_media.h>
62
63 #ifdef INET
64 #include <netinet/in.h>
65 #include <netinet/in_systm.h>
66 #include <netinet/in_var.h>
67 #include <netinet/ip.h>
68 #include <netinet/if_inarp.h>
69 #endif
70
71 #ifdef NS
72 #include <netns/ns.h>
73 #include <netns/ns_if.h>
74 #endif
75
76 #include <net/bpf.h>
77 #include <net/bpfdesc.h>
78
79 #include <machine/cpu.h>
80 #include <machine/autoconf.h>
81 #include <machine/idprom.h>
82 #include <machine/bus.h>
83 #include <machine/intr.h>
84
85 #include <sun2/dev/if_ecreg.h>
86
87 /*
88 * Interface softc.
89 */
90 struct ec_softc {
91 device_t sc_dev;
92 void *sc_ih;
93
94 struct ethercom sc_ethercom; /* ethernet common */
95 struct ifmedia sc_media; /* our supported media */
96
97 bus_space_tag_t sc_iot; /* bus space tag */
98 bus_space_handle_t sc_ioh; /* bus space handle */
99
100 u_char sc_jammed; /* nonzero if the net is jammed */
101 u_char sc_colliding; /* nonzero if the net is colliding */
102 uint32_t sc_backoff_seed; /* seed for the backoff PRNG */
103
104 #if NRND > 0
105 rndsource_element_t rnd_source;
106 #endif
107 };
108
109 /* Macros to read and write the CSR. */
110 #define ECREG_CSR_RD bus_space_read_2(sc->sc_iot, sc->sc_ioh, ECREG_CSR)
111 #define ECREG_CSR_WR(val) bus_space_write_2(sc->sc_iot, sc->sc_ioh, ECREG_CSR, val)
112
113 /* After this many collisions, the packet is dropped. */
114 #define EC_COLLISIONS_JAMMED 16
115
116 /*
117 * Various constants used in the backoff pseudorandom
118 * number generator.
119 */
120 #define EC_BACKOFF_PRNG_COLL_MAX 10
121 #define EC_BACKOFF_PRNG_MUL 1103515245
122 #define EC_BACKOFF_PRNG_ADD 12345
123 #define EC_BACKOFF_PRNG_MASK 0x7fffffff
124
125 /*
126 * Prototypes
127 */
128 int ec_intr(void *);
129 void ec_reset(struct ifnet *);
130 int ec_init(struct ifnet *);
131 int ec_ioctl(struct ifnet *, u_long, void *);
132 void ec_watchdog(struct ifnet *);
133 void ec_start(struct ifnet *);
134
135 void ec_recv(struct ec_softc *, int);
136 void ec_coll(struct ec_softc *);
137 void ec_copyin(struct ec_softc *, void *, int, size_t);
138 void ec_copyout(struct ec_softc *, const void *, int, size_t);
139
140 int ec_mediachange(struct ifnet *);
141 void ec_mediastatus(struct ifnet *, struct ifmediareq *);
142
143 int ec_match(device_t, cfdata_t, void *);
144 void ec_attach(device_t, device_t, void *);
145
146 CFATTACH_DECL_NEW(ec, sizeof(struct ec_softc),
147 ec_match, ec_attach, NULL, NULL);
148
149 /*
150 * Copy board memory to kernel.
151 */
152 void
153 ec_copyin(struct ec_softc *sc, void *p, int offset, size_t size)
154 {
155
156 bus_space_copyin(sc->sc_iot, sc->sc_ioh, offset, p, size);
157 }
158
159 /*
160 * Copy from kernel space to board memory.
161 */
162 void
163 ec_copyout(struct ec_softc *sc, const void *p, int offset, size_t size)
164 {
165
166 bus_space_copyout(sc->sc_iot, sc->sc_ioh, offset, p, size);
167 }
168
169 int
170 ec_match(device_t parent, cfdata_t cf, void *aux)
171 {
172 struct mbmem_attach_args *mbma = aux;
173 bus_space_handle_t bh;
174 bool matched;
175
176 /* No default Multibus address. */
177 if (mbma->mbma_paddr == -1)
178 return 0;
179
180 /* Make sure there is something there... */
181 if (bus_space_map(mbma->mbma_bustag, mbma->mbma_paddr, ECREG_BANK_SZ,
182 0, &bh))
183 return 0;
184 matched = (bus_space_peek_2(mbma->mbma_bustag, bh, 0, NULL) == 0);
185 bus_space_unmap(mbma->mbma_bustag, bh, ECREG_BANK_SZ);
186 if (!matched)
187 return 0;
188
189 /* Default interrupt priority. */
190 if (mbma->mbma_pri == -1)
191 mbma->mbma_pri = 3;
192
193 return 1;
194 }
195
196 void
197 ec_attach(device_t parent, device_t self, void *aux)
198 {
199 struct ec_softc *sc = device_private(self);
200 struct mbmem_attach_args *mbma = aux;
201 struct ifnet *ifp = &sc->sc_ethercom.ec_if;
202 uint8_t myaddr[ETHER_ADDR_LEN];
203
204 sc->sc_dev = self;
205
206 aprint_normal("\n");
207
208 /* Map in the board control regs. */
209 sc->sc_iot = mbma->mbma_bustag;
210 if (bus_space_map(mbma->mbma_bustag, mbma->mbma_paddr, ECREG_BANK_SZ,
211 0, &sc->sc_ioh))
212 panic("%s: can't map regs", __func__);
213
214 /* Reset the board. */
215 ECREG_CSR_WR(EC_CSR_RESET);
216 delay(160);
217
218 /*
219 * Copy out the board ROM Ethernet address,
220 * and use the non-vendor-ID part to seed
221 * our backoff pseudorandom number generator.
222 */
223 bus_space_read_region_1(sc->sc_iot, sc->sc_ioh,
224 ECREG_AROM, myaddr, ETHER_ADDR_LEN);
225 sc->sc_backoff_seed =
226 (myaddr[3] << 16) | (myaddr[4] << 8) | (myaddr[5]) | 1;
227
228 /* Initialize ifnet structure. */
229 strcpy(ifp->if_xname, device_xname(self));
230 ifp->if_softc = sc;
231 ifp->if_start = ec_start;
232 ifp->if_ioctl = ec_ioctl;
233 ifp->if_init = ec_init;
234 ifp->if_watchdog = ec_watchdog;
235 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS;
236 IFQ_SET_READY(&ifp->if_snd);
237
238 /* Initialize ifmedia structures. */
239 ifmedia_init(&sc->sc_media, 0, ec_mediachange, ec_mediastatus);
240 ifmedia_add(&sc->sc_media, IFM_ETHER|IFM_MANUAL, 0, NULL);
241 ifmedia_set(&sc->sc_media, IFM_ETHER|IFM_MANUAL);
242
243 /* Now we can attach the interface. */
244 if_attach(ifp);
245 idprom_etheraddr(myaddr);
246 ether_ifattach(ifp, myaddr);
247 aprint_normal_dev(self, "address %s\n", ether_sprintf(myaddr));
248
249 bus_intr_establish(mbma->mbma_bustag, mbma->mbma_pri, IPL_NET, 0,
250 ec_intr, sc);
251
252 #if NRND > 0
253 rnd_attach_source(&sc->rnd_source, device_xname(self),
254 RND_TYPE_NET, 0);
255 #endif
256 }
257
258 /*
259 * Reset interface.
260 */
261 void
262 ec_reset(struct ifnet *ifp)
263 {
264 int s;
265
266 s = splnet();
267 ec_init(ifp);
268 splx(s);
269 }
270
271
272 /*
273 * Initialize interface.
274 */
275 int
276 ec_init(struct ifnet *ifp)
277 {
278 struct ec_softc *sc = ifp->if_softc;
279
280 /* Reset the board. */
281 ECREG_CSR_WR(EC_CSR_RESET);
282 delay(160);
283
284 /* Set the Ethernet address. */
285 bus_space_write_region_1(sc->sc_iot, sc->sc_ioh,
286 ECREG_ARAM, CLLADDR(sc->sc_ethercom.ec_if.if_sadl), ETHER_ADDR_LEN);
287 ECREG_CSR_WR((ECREG_CSR_RD & EC_CSR_INTPA) | EC_CSR_AMSW);
288 ECREG_CSR_WR(ECREG_CSR_RD & 0);
289
290 /* Enable interrupts. */
291 ECREG_CSR_WR((ECREG_CSR_RD & EC_CSR_INTPA) |
292 EC_CSR_BBSW | EC_CSR_ABSW | EC_CSR_BINT | EC_CSR_AINT |
293 (ifp->if_flags & IFF_PROMISC ? EC_CSR_PROMISC : EC_CSR_PA));
294
295 /* Set flags appropriately. */
296 ifp->if_flags |= IFF_RUNNING;
297 ifp->if_flags &= ~IFF_OACTIVE;
298
299 /* Start output. */
300 ec_start(ifp);
301
302 return 0;
303 }
304
305 /*
306 * Start output on interface.
307 */
308 void
309 ec_start(struct ifnet *ifp)
310 {
311 struct ec_softc *sc = ifp->if_softc;
312 struct mbuf *m, *m0;
313 int s;
314 u_int count, realcount;
315 bus_size_t off;
316 static uint8_t padding[ETHER_MIN_LEN - ETHER_CRC_LEN] = {0};
317
318 s = splnet();
319
320 /* Don't do anything if output is active. */
321 if ((ifp->if_flags & IFF_OACTIVE) != 0) {
322 splx(s);
323 return;
324 }
325 /* Don't do anything if the output queue is empty. */
326 IFQ_DEQUEUE(&ifp->if_snd, m0);
327 if (m0 == NULL) {
328 splx(s);
329 return;
330 }
331
332 /* The BPF tap. */
333 bpf_mtap(ifp, m0);
334
335 /* Size the packet. */
336 count = EC_BUF_SZ - m0->m_pkthdr.len;
337
338 /* Copy the packet into the xmit buffer. */
339 realcount = MIN(count, EC_PKT_MAXTDOFF);
340 bus_space_write_2(sc->sc_iot, sc->sc_ioh, ECREG_TBUF, realcount);
341 for (off = realcount, m = m0; m != 0; off += m->m_len, m = m->m_next)
342 ec_copyout(sc, mtod(m, uint8_t *), ECREG_TBUF + off, m->m_len);
343 m_freem(m0);
344 if (count - realcount)
345 ec_copyout(sc, padding, ECREG_TBUF + off, count - realcount);
346
347 /* Enable the transmitter. */
348 ECREG_CSR_WR((ECREG_CSR_RD & EC_CSR_PA) |
349 EC_CSR_TBSW | EC_CSR_TINT | EC_CSR_JINT);
350 ifp->if_flags |= IFF_OACTIVE;
351
352 /* Done. */
353 splx(s);
354 }
355
356 /*
357 * Controller interrupt.
358 */
359 int
360 ec_intr(void *arg)
361 {
362 struct ec_softc *sc = arg;
363 struct ifnet *ifp = &sc->sc_ethercom.ec_if;
364 int recv_first;
365 int recv_second;
366 int retval;
367 struct mbuf *m0;
368
369 retval = 0;
370
371 /* Check for received packet(s). */
372 recv_first = recv_second = 0;
373 switch (ECREG_CSR_RD & (EC_CSR_BBSW | EC_CSR_ABSW | EC_CSR_RBBA)) {
374
375 case (EC_CSR_BBSW | EC_CSR_ABSW):
376 case (EC_CSR_BBSW | EC_CSR_ABSW | EC_CSR_RBBA):
377 /* Neither buffer is full. Is this a transmit interrupt?
378 * Acknowledge the interrupt ourselves. */
379 ECREG_CSR_WR(ECREG_CSR_RD &
380 (EC_CSR_TINT | EC_CSR_JINT | EC_CSR_PAMASK));
381 ECREG_CSR_WR((ECREG_CSR_RD & EC_CSR_INTPA) |
382 EC_CSR_BINT | EC_CSR_AINT);
383 break;
384
385 case EC_CSR_BBSW:
386 case (EC_CSR_BBSW | EC_CSR_RBBA):
387 /* Only the A buffer is full. */
388 recv_first = EC_CSR_AINT;
389 break;
390
391 case EC_CSR_ABSW:
392 case (EC_CSR_ABSW | EC_CSR_RBBA):
393 /* Only the B buffer is full. */
394 recv_first = EC_CSR_BINT;
395 break;
396
397 case 0:
398 /* Both the A buffer and the B buffer are full, and the A
399 * buffer is older than the B buffer. */
400 recv_first = EC_CSR_AINT;
401 recv_second = EC_CSR_BINT;
402 break;
403
404 case EC_CSR_RBBA:
405 /* Both the A buffer and the B buffer are full, and the B
406 * buffer is older than the A buffer. */
407 recv_first = EC_CSR_BINT;
408 recv_second = EC_CSR_AINT;
409 break;
410 }
411
412 /* Receive packets. */
413 if (recv_first) {
414
415 /* Acknowledge the interrupt. */
416 ECREG_CSR_WR(ECREG_CSR_RD &
417 ((EC_CSR_BINT | EC_CSR_AINT | EC_CSR_TINT | EC_CSR_JINT |
418 EC_CSR_PAMASK) ^ (recv_first | recv_second)));
419
420 /* Receive a packet. */
421 ec_recv(sc, recv_first);
422
423 /* Receive a packet. */
424 if (recv_second)
425 ec_recv(sc, recv_second);
426
427 retval++;
428 }
429 /* Check for a transmitted packet. */
430 if (ifp->if_flags & IFF_OACTIVE) {
431
432 /* If we got a collision. */
433 if (ECREG_CSR_RD & EC_CSR_JAM) {
434 ECREG_CSR_WR(ECREG_CSR_RD &
435 (EC_CSR_BINT | EC_CSR_AINT | EC_CSR_PAMASK));
436 sc->sc_ethercom.ec_if.if_collisions++;
437 retval++;
438 ec_coll(sc);
439
440 }
441 /* If we transmitted a packet. */
442 else if ((ECREG_CSR_RD & EC_CSR_TBSW) == 0) {
443 ECREG_CSR_WR(ECREG_CSR_RD &
444 (EC_CSR_BINT | EC_CSR_AINT | EC_CSR_PAMASK));
445 retval++;
446 sc->sc_ethercom.ec_if.if_opackets++;
447 sc->sc_jammed = 0;
448 ifp->if_flags &= ~IFF_OACTIVE;
449 IFQ_POLL(&ifp->if_snd, m0);
450 if (m0 != NULL)
451 ec_start(ifp);
452 }
453 } else {
454
455 /* Make sure we disable transmitter interrupts. */
456 ECREG_CSR_WR(ECREG_CSR_RD &
457 (EC_CSR_BINT | EC_CSR_AINT | EC_CSR_PAMASK));
458 }
459
460 return retval;
461 }
462
463 /*
464 * Read in a packet from the board.
465 */
466 void
467 ec_recv(struct ec_softc *sc, int intbit)
468 {
469 struct ifnet *ifp = &sc->sc_ethercom.ec_if;
470 struct mbuf *m0, *m, *newm;
471 bus_size_t buf;
472 uint16_t status;
473 uint16_t doff;
474 int length, total_length;
475
476 buf = EC_CSR_INT_BUF(intbit);
477
478 /* Read in the packet status. */
479 status = bus_space_read_2(sc->sc_iot, sc->sc_ioh, buf);
480 doff = status & EC_PKT_DOFF;
481
482 for (total_length = -1, m0 = NULL;;) {
483
484 /* Check for an error. */
485 if (status & (EC_PKT_FCSERR | EC_PKT_RGERR | EC_PKT_FRERR) ||
486 doff < EC_PKT_MINRDOFF ||
487 doff > EC_PKT_MAXRDOFF) {
488 printf("%s: garbled packet, status 0x%04x; dropping\n",
489 device_xname(sc->sc_dev), (unsigned int)status);
490 break;
491 }
492
493 /* Adjust for the header. */
494 total_length = doff - EC_PKT_RDOFF;
495 buf += EC_PKT_RDOFF;
496
497 /* XXX - sometimes the card reports a large data offset. */
498 if (total_length > (ETHER_MAX_LEN - ETHER_CRC_LEN)) {
499 #ifdef DEBUG
500 printf("%s: fixing too-large length of %d\n",
501 device_xname(sc->sc_dev), total_length);
502 #endif
503 total_length = (ETHER_MAX_LEN - ETHER_CRC_LEN);
504 }
505
506 MGETHDR(m0, M_DONTWAIT, MT_DATA);
507 if (m0 == NULL)
508 break;
509 m0->m_pkthdr.rcvif = ifp;
510 m0->m_pkthdr.len = total_length;
511 length = MHLEN;
512 m = m0;
513
514 while (total_length > 0) {
515 if (total_length >= MINCLSIZE) {
516 MCLGET(m, M_DONTWAIT);
517 if ((m->m_flags & M_EXT) == 0)
518 break;
519 length = MCLBYTES;
520 }
521 m->m_len = length = min(total_length, length);
522 ec_copyin(sc, mtod(m, uint8_t *), buf, length);
523 total_length -= length;
524 buf += length;
525
526 if (total_length > 0) {
527 MGET(newm, M_DONTWAIT, MT_DATA);
528 if (newm == NULL)
529 break;
530 length = MLEN;
531 m = m->m_next = newm;
532 }
533 }
534 break;
535 }
536
537 if (total_length == 0) {
538 ifp->if_ipackets++;
539
540 /*
541 * Check if there's a BPF listener on this interface.
542 * If so, hand off the raw packet to BPF.
543 */
544 bpf_mtap(ifp, m0);
545
546 /* Pass the packet up. */
547 (*ifp->if_input)(ifp, m0);
548
549 } else {
550 /* Something went wrong. */
551 if (m0 != NULL)
552 m_freem(m0);
553 ifp->if_ierrors++;
554 }
555
556 /* Give the receive buffer back to the card. */
557 buf = EC_CSR_INT_BUF(intbit);
558 bus_space_write_2(sc->sc_iot, sc->sc_ioh, buf, 0);
559 ECREG_CSR_WR((ECREG_CSR_RD & EC_CSR_INTPA) |
560 EC_CSR_INT_BSW(intbit) | intbit);
561 }
562
563 int
564 ec_mediachange(struct ifnet *ifp)
565 {
566
567 return 0;
568 }
569
570 void
571 ec_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
572 {
573
574 if ((ifp->if_flags & IFF_UP) == 0)
575 return;
576
577 ifmr->ifm_status = IFM_AVALID | IFM_ACTIVE;
578 }
579
580 /*
581 * Process an ioctl request. This code needs some work - it looks pretty ugly.
582 */
583 int
584 ec_ioctl(struct ifnet *ifp, u_long cmd, void *data)
585 {
586 struct ifaddr *ifa = (struct ifaddr *)data;
587 struct ifreq *ifr = (struct ifreq *)data;
588 struct ec_softc *sc = ifp->if_softc;
589 int s, error = 0;
590
591 s = splnet();
592
593 switch (cmd) {
594
595 case SIOCINITIFADDR:
596 ifp->if_flags |= IFF_UP;
597
598 switch (ifa->ifa_addr->sa_family) {
599 #ifdef INET
600 case AF_INET:
601 ec_init(ifp);
602 arp_ifinit(ifp, ifa);
603 break;
604 #endif
605 default:
606 ec_init(ifp);
607 break;
608 }
609 break;
610
611 case SIOCSIFFLAGS:
612 if ((error = ifioctl_common(ifp, cmd, data)) != 0)
613 break;
614 switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) {
615 case IFF_RUNNING:
616 /*
617 * If interface is marked down and it is running, then
618 * stop it.
619 */
620 ifp->if_flags &= ~IFF_RUNNING;
621 break;
622 case IFF_UP:
623 /*
624 * If interface is marked up and it is stopped, then
625 * start it.
626 */
627 ec_init(ifp);
628 break;
629 default:
630 /*
631 * Some other important flag might have changed, so
632 * reset.
633 */
634 ec_reset(ifp);
635 break;
636 }
637 break;
638
639 case SIOCGIFMEDIA:
640 case SIOCSIFMEDIA:
641 error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
642 break;
643
644 default:
645 error = ether_ioctl(ifp, cmd, data);
646 break;
647 }
648
649 splx(s);
650 return error;
651 }
652
653 /*
654 * Collision routine.
655 */
656 void
657 ec_coll(struct ec_softc *sc)
658 {
659 struct ifnet *ifp = &sc->sc_ethercom.ec_if;
660 u_short jams;
661 struct mbuf *m0;
662
663 if ((++sc->sc_colliding) >= EC_COLLISIONS_JAMMED) {
664 sc->sc_ethercom.ec_if.if_oerrors++;
665 if (!sc->sc_jammed)
666 printf("%s: ethernet jammed\n",
667 device_xname(sc->sc_dev));
668 sc->sc_jammed = 1;
669 sc->sc_colliding = 0;
670 ifp->if_flags &= ~IFF_OACTIVE;
671 IFQ_POLL(&ifp->if_snd, m0);
672 if (m0 != NULL)
673 ec_start(ifp);
674 } else {
675 jams = MAX(sc->sc_colliding, EC_BACKOFF_PRNG_COLL_MAX);
676 sc->sc_backoff_seed =
677 ((sc->sc_backoff_seed * EC_BACKOFF_PRNG_MUL) +
678 EC_BACKOFF_PRNG_ADD) & EC_BACKOFF_PRNG_MASK;
679 bus_space_write_2(sc->sc_iot, sc->sc_ioh, ECREG_BACKOFF,
680 -(((sc->sc_backoff_seed >> 8) & ~(-1 << jams)) + 1));
681 ECREG_CSR_WR((ECREG_CSR_RD & EC_CSR_INTPA) |
682 EC_CSR_JAM | EC_CSR_TINT | EC_CSR_JINT);
683 }
684 }
685
686 /*
687 * Device timeout routine.
688 */
689 void
690 ec_watchdog(struct ifnet *ifp)
691 {
692 struct ec_softc *sc = ifp->if_softc;
693
694 log(LOG_ERR, "%s: device timeout\n", device_xname(sc->sc_dev));
695 sc->sc_ethercom.ec_if.if_oerrors++;
696
697 ec_reset(ifp);
698 }
699