2 * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Herb Peyerl.
16 * 4. The name of Herb Peyerl may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * if_ep.c,v 1.19 1995/01/24 20:53:45 davidg Exp
34 * Modified from the FreeBSD 1.1.5.1 version by:
36 * INRIA - Sophia Antipolis, France
37 * avega@sophia.inria.fr
41 * $FreeBSD: src/sys/dev/ep/if_ep.c,v 1.95.2.3 2002/03/06 07:26:35 imp Exp $
42 * $DragonFly: src/sys/dev/netif/ep/if_ep.c,v 1.20 2005/06/14 14:44:42 joerg Exp $
44 * Promiscuous mode added and interrupt logic slightly changed
45 * to reduce the number of adapter failures. Transceiver select
46 * logic changed to use value from EEPROM. Autoconfiguration
50 * Chelindbank (Chelyabinsk, Russia)
51 * babkin@hq.icb.chel.su
55 * Pccard support for 3C589 by:
61 * MAINTAINER: Matthew N. Dodd <winter@jurai.net>
65 #include <sys/param.h>
66 #include <sys/kernel.h>
67 #include <sys/systm.h>
68 #include <sys/malloc.h>
70 #include <sys/socket.h>
71 #include <sys/sockio.h>
72 #include <sys/thread2.h>
74 #include <sys/module.h>
77 #include <machine/bus.h>
78 #include <machine/resource.h>
82 #include <net/ifq_var.h>
83 #include <net/if_arp.h>
84 #include <net/if_media.h>
85 #include <net/ethernet.h>
88 #include <netinet/in.h>
89 #include <netinet/if_ether.h>
91 #include <machine/clock.h>
95 #include "../elink_layer/elink.h"
97 /* Exported variables */
98 devclass_t ep_devclass;
101 static char * ep_conn_type[] = {"UTP", "AUI", "???", "BNC"};
102 static int if_media2ep_media[] = { 0, 0, 0, UTP, BNC, AUI };
105 static int ep_media2if_media[] =
106 { IFM_10_T, IFM_10_5, IFM_NONE, IFM_10_2, IFM_NONE };
109 static void ep_if_init (void *);
110 static int ep_if_ioctl(struct ifnet *, u_long, caddr_t, struct ucred *);
111 static void ep_if_start (struct ifnet *);
112 static void ep_if_watchdog (struct ifnet *);
114 /* if_media functions */
115 static int ep_ifmedia_upd (struct ifnet *);
116 static void ep_ifmedia_sts (struct ifnet *, struct ifmediareq *);
118 static void epstop (struct ep_softc *);
119 static void epread (struct ep_softc *);
120 static int eeprom_rdy (struct ep_softc *);
122 DECLARE_DUMMY_MODULE(if_ep);
124 #define EP_FTST(sc, f) (sc->stat & (f))
125 #define EP_FSET(sc, f) (sc->stat |= (f))
126 #define EP_FRST(sc, f) (sc->stat &= ~(f))
134 for (i = 0; is_eeprom_busy(BASE) && i < MAX_EEPROMBUSY; i++) {
137 if (i >= MAX_EEPROMBUSY) {
138 if_printf(&sc->arpcom.ac_if, "eeprom failed to come ready.\n");
145 * get_e: gets a 16 bits word from the EEPROM. we must have set the window
155 outw(BASE + EP_W0_EEPROM_COMMAND, (EEPROM_CMD_RD << sc->epb.cmd_off) | offset);
158 return (inw(BASE + EP_W0_EEPROM_DATA));
162 ep_get_macaddr(sc, addr)
163 struct ep_softc * sc;
167 u_int16_t * macaddr = (u_int16_t *)addr;
170 for(i = EEPROM_NODE_ADDR_0; i <= EEPROM_NODE_ADDR_2; i++) {
171 macaddr[i] = htons(get_e(sc, i));
178 ep_alloc(device_t dev)
180 struct ep_softc * sc = device_get_softc(dev);
185 sc->iobase = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid,
188 device_printf(dev, "No I/O space?!\n");
194 sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
196 device_printf(dev, "No irq?!\n");
201 if_initname(&sc->arpcom.ac_if,
202 device_get_name(dev), device_get_unit(dev));
203 sc->stat = 0; /* 16 bit access */
205 sc->ep_io_addr = rman_get_start(sc->iobase);
207 sc->ep_btag = rman_get_bustag(sc->iobase);
208 sc->ep_bhandle = rman_get_bushandle(sc->iobase);
210 sc->ep_connectors = 0;
211 sc->ep_connector = 0;
215 sc->epb.prod_id = get_e(sc, EEPROM_PROD_ID);
216 sc->epb.res_cfg = get_e(sc, EEPROM_RESOURCE_CFG);
224 struct ep_softc * sc;
229 config = inw(BASE + EP_W0_CONFIG_CTRL);
231 sc->ep_connectors |= AUI;
233 sc->ep_connectors |= BNC;
235 sc->ep_connectors |= UTP;
237 if (!(sc->ep_connectors & 7)) {
239 if_printf(&sc->arpcom.ac_if, "no connectors!\n");
243 * This works for most of the cards so we'll do it here.
244 * The cards that require something different can override
247 sc->ep_connector = inw(BASE + EP_W0_ADDRESS_CFG) >> ACF_CONNECTOR_BITS;
253 ep_free(device_t dev)
255 struct ep_softc * sc = device_get_softc(dev);
258 bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->iobase);
260 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq);
267 struct ep_softc * sc;
269 struct ifnet * ifp = NULL;
270 struct ifmedia * ifm = NULL;
272 uint8_t ether_addr[ETHER_ADDR_LEN];
277 ep_get_macaddr(sc, ether_addr);
280 * Setup the station address
282 p = (u_short*)ether_addr;
284 for (i = 0; i < 3; i++) {
285 outw(BASE + EP_W2_ADDR_0 + (i * 2), ntohs(p[i]));
288 ifp = &sc->arpcom.ac_if;
291 ifp->if_mtu = ETHERMTU;
292 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
293 ifp->if_start = ep_if_start;
294 ifp->if_ioctl = ep_if_ioctl;
295 ifp->if_watchdog = ep_if_watchdog;
296 ifp->if_init = ep_if_init;
297 ifq_set_maxlen(&ifp->if_snd, IFQ_MAXLEN);
298 ifq_set_ready(&ifp->if_snd);
300 if (!sc->epb.mii_trans) {
301 ifmedia_init(&sc->ifmedia, 0, ep_ifmedia_upd, ep_ifmedia_sts);
303 if (sc->ep_connectors & AUI)
304 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_5, 0, NULL);
305 if (sc->ep_connectors & UTP)
306 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_T, 0, NULL);
307 if (sc->ep_connectors & BNC)
308 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_2, 0, NULL);
309 if (!sc->ep_connectors)
310 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_NONE, 0, NULL);
312 ifmedia_set(&sc->ifmedia, IFM_ETHER|ep_media2if_media[sc->ep_connector]);
315 ifm->ifm_media = ifm->ifm_cur->ifm_media;
319 ether_ifattach(ifp, ether_addr);
321 #ifdef EP_LOCAL_STATS
322 sc->rx_no_first = sc->rx_no_mbuf = sc->rx_bpf_disc =
323 sc->rx_overrunf = sc->rx_overrunl = sc->tx_underrun = 0;
325 EP_FSET(sc, F_RX_FIRST);
326 sc->top = sc->mcur = 0;
332 * The order in here seems important. Otherwise we may not receive
339 struct ep_softc *sc = xsc;
340 struct ifnet *ifp = &sc->arpcom.ac_if;
348 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
351 outw(BASE + EP_COMMAND, STOP_TRANSCEIVER);
353 outw(BASE + EP_W4_MEDIA_TYPE, DISABLE_UTP);
356 /* Disable the card */
357 outw(BASE + EP_W0_CONFIG_CTRL, 0);
359 /* Enable the card */
360 outw(BASE + EP_W0_CONFIG_CTRL, ENABLE_DRQ_IRQ);
364 /* Reload the ether_addr. */
365 for (i = 0; i < 6; i++)
366 outb(BASE + EP_W2_ADDR_0 + i, sc->arpcom.ac_enaddr[i]);
368 outw(BASE + EP_COMMAND, RX_RESET);
369 outw(BASE + EP_COMMAND, TX_RESET);
370 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
372 /* Window 1 is operating window */
374 for (i = 0; i < 31; i++)
375 inb(BASE + EP_W1_TX_STATUS);
377 /* get rid of stray intr's */
378 outw(BASE + EP_COMMAND, ACK_INTR | 0xff);
380 outw(BASE + EP_COMMAND, SET_RD_0_MASK | S_5_INTS);
382 outw(BASE + EP_COMMAND, SET_INTR_MASK | S_5_INTS);
384 if (ifp->if_flags & IFF_PROMISC)
385 outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL |
386 FIL_GROUP | FIL_BRDCST | FIL_ALL);
388 outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL |
389 FIL_GROUP | FIL_BRDCST);
391 if (!sc->epb.mii_trans) {
395 outw(BASE + EP_COMMAND, RX_ENABLE);
396 outw(BASE + EP_COMMAND, TX_ENABLE);
398 ifp->if_flags |= IFF_RUNNING;
399 ifp->if_flags &= ~IFF_OACTIVE; /* just in case */
401 #ifdef EP_LOCAL_STATS
402 sc->rx_no_first = sc->rx_no_mbuf =
403 sc->rx_overrunf = sc->rx_overrunl = sc->tx_underrun = 0;
405 EP_FSET(sc, F_RX_FIRST);
408 sc->top = sc->mcur = 0;
410 outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH);
411 outw(BASE + EP_COMMAND, SET_TX_START_THRESH | 16);
414 * Store up a bunch of mbuf's for use later. (MAX_MBS). First we free up
415 * any that we had in case we're being called from intr or somewhere
425 static const char padmap[] = {0, 3, 2, 1};
431 struct ep_softc *sc = ifp->if_softc;
441 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
442 if (ifp->if_flags & IFF_OACTIVE) {
449 /* Sneak a peek at the next packet */
450 m = ifq_poll(&ifp->if_snd);
456 for (len = 0, top = m; m; m = m->m_next)
459 pad = padmap[len & 3];
462 * The 3c509 automatically pads short packets to minimum ethernet length,
463 * but we drop packets that are too large. Perhaps we should truncate
466 if (len + pad > ETHER_MAX_LEN) {
467 /* packet is obviously too large: toss it */
469 ifq_dequeue(&ifp->if_snd);
473 if (inw(BASE + EP_W1_FREE_TX) < len + pad + 4) {
474 /* no room in FIFO */
475 outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | (len + pad + 4));
477 if (inw(BASE + EP_W1_FREE_TX) < len + pad + 4) {
478 ifp->if_flags |= IFF_OACTIVE;
483 outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | EP_THRESH_DISABLE);
486 m = ifq_dequeue(&ifp->if_snd);
488 outw(BASE + EP_W1_TX_PIO_WR_1, len);
489 outw(BASE + EP_W1_TX_PIO_WR_1, 0x0); /* Second dword meaningless */
491 if (EP_FTST(sc, F_ACCESS_32_BITS)) {
492 for (top = m; m != 0; m = m->m_next) {
493 outsl(BASE + EP_W1_TX_PIO_WR_1, mtod(m, caddr_t),
496 outsb(BASE + EP_W1_TX_PIO_WR_1,
497 mtod(m, caddr_t) + (m->m_len & (~3)),
501 for (top = m; m != 0; m = m->m_next) {
502 outsw(BASE + EP_W1_TX_PIO_WR_1, mtod(m, caddr_t), m->m_len / 2);
504 outb(BASE + EP_W1_TX_PIO_WR_1,
505 *(mtod(m, caddr_t) + m->m_len - 1));
510 outb(BASE + EP_W1_TX_PIO_WR_1, 0); /* Padding */
519 * Is another packet coming in? We don't want to overflow the tiny RX
523 if (inw(BASE + EP_W1_RX_STATUS) & RX_BYTES_MASK) {
525 * we check if we have packets left, in that case we prepare to come
528 if (!ifq_is_empty(&ifp->if_snd))
529 outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | 8);
541 struct ep_softc *sc = arg;
542 struct ifnet *ifp = &sc->arpcom.ac_if;
546 * quick fix: Try to detect an interrupt when the card goes away.
548 if (sc->gone || inw(BASE + EP_STATUS) == 0xffff) {
552 outw(BASE + EP_COMMAND, SET_INTR_MASK); /* disable all Ints */
556 while ((status = inw(BASE + EP_STATUS)) & S_5_INTS) {
558 /* first acknowledge all interrupt sources */
559 outw(BASE + EP_COMMAND, ACK_INTR | (status & S_MASK));
561 if (status & (S_RX_COMPLETE | S_RX_EARLY))
563 if (status & S_TX_AVAIL) {
566 ifp->if_flags &= ~IFF_OACTIVE;
568 inw(BASE + EP_W1_FREE_TX);
571 if (status & S_CARD_FAILURE) {
573 #ifdef EP_LOCAL_STATS
575 if_printf(ifp, "\n\tStatus: %x\n", status);
577 printf("\tFIFO Diagnostic: %x\n", inw(BASE + EP_W4_FIFO_DIAG));
578 printf("\tStat: %x\n", sc->stat);
579 printf("\tIpackets=%d, Opackets=%d\n",
580 ifp->if_ipackets, ifp->if_opackets);
581 printf("\tNOF=%d, NOMB=%d, RXOF=%d, RXOL=%d, TXU=%d\n",
582 sc->rx_no_first, sc->rx_no_mbuf, sc->rx_overrunf,
583 sc->rx_overrunl, sc->tx_underrun);
587 if_printf(ifp, "Status: %x (input buffer overflow)\n", status);
596 if (status & S_TX_COMPLETE) {
598 /* we need ACK. we do it at the end */
600 * We need to read TX_STATUS until we get a 0 status in order to
601 * turn off the interrupt flag.
603 while ((status = inb(BASE + EP_W1_TX_STATUS)) & TXS_COMPLETE) {
604 if (status & TXS_SUCCES_INTR_REQ);
605 else if (status & (TXS_UNDERRUN | TXS_JABBER | TXS_MAX_COLLISION)) {
606 outw(BASE + EP_COMMAND, TX_RESET);
607 if (status & TXS_UNDERRUN) {
608 #ifdef EP_LOCAL_STATS
612 if (status & TXS_JABBER);
613 else /* TXS_MAX_COLLISION - we shouldn't get here */
614 ++ifp->if_collisions;
617 outw(BASE + EP_COMMAND, TX_ENABLE);
619 * To have a tx_avail_int but giving the chance to the
622 if (!ifq_is_empty(&ifp->if_snd))
623 outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | 8);
625 outb(BASE + EP_W1_TX_STATUS, 0x0); /* pops up the next
628 ifp->if_flags &= ~IFF_OACTIVE;
630 inw(BASE + EP_W1_FREE_TX);
632 } /* end TX_COMPLETE */
635 outw(BASE + EP_COMMAND, C_INTR_LATCH); /* ACK int Latch */
637 if ((status = inw(BASE + EP_STATUS)) & S_5_INTS)
641 outw(BASE + EP_COMMAND, SET_INTR_MASK | S_5_INTS);
648 struct mbuf *top, *mcur, *m;
652 short rx_fifo2, status;
655 ifp = &sc->arpcom.ac_if;
656 status = inw(BASE + EP_W1_RX_STATUS);
660 if (status & ERR_RX) {
662 if (status & ERR_RX_OVERRUN) {
664 * we can think the rx latency is actually greather than we
667 #ifdef EP_LOCAL_STATS
668 if (EP_FTST(sc, F_RX_FIRST))
676 rx_fifo = rx_fifo2 = status & RX_BYTES_MASK;
678 if (EP_FTST(sc, F_RX_FIRST)) {
679 m = m_getl(rx_fifo, MB_DONTWAIT, MT_DATA, M_PKTHDR, NULL);
682 sc->top = sc->mcur = top = m;
683 #define EROUND ((sizeof(struct ether_header) + 3) & ~3)
684 #define EOFF (EROUND - sizeof(struct ether_header))
687 /* Read what should be the header. */
688 insw(BASE + EP_W1_RX_PIO_RD_1,
689 mtod(top, caddr_t), sizeof(struct ether_header) / 2);
690 top->m_len = sizeof(struct ether_header);
691 rx_fifo -= sizeof(struct ether_header);
692 sc->cur_len = rx_fifo2;
694 /* come here if we didn't have a complete packet last time */
697 sc->cur_len += rx_fifo2;
700 /* Reads what is left in the RX FIFO */
701 while (rx_fifo > 0) {
702 lenthisone = min(rx_fifo, M_TRAILINGSPACE(m));
703 if (lenthisone == 0) { /* no room in this one */
705 m = m_getl(rx_fifo, MB_DONTWAIT, MT_DATA, 0, NULL);
710 lenthisone = min(rx_fifo, M_TRAILINGSPACE(m));
712 if (EP_FTST(sc, F_ACCESS_32_BITS)) { /* default for EISA configured cards*/
713 insl(BASE + EP_W1_RX_PIO_RD_1, mtod(m, caddr_t) + m->m_len,
715 m->m_len += (lenthisone & ~3);
717 insb(BASE + EP_W1_RX_PIO_RD_1,
718 mtod(m, caddr_t) + m->m_len,
720 m->m_len += (lenthisone & 3);
722 insw(BASE + EP_W1_RX_PIO_RD_1, mtod(m, caddr_t) + m->m_len,
724 m->m_len += lenthisone;
726 *(mtod(m, caddr_t) + m->m_len - 1) = inb(BASE + EP_W1_RX_PIO_RD_1);
728 rx_fifo -= lenthisone;
731 if (status & ERR_RX_INCOMPLETE) { /* we haven't received the complete
734 #ifdef EP_LOCAL_STATS
735 sc->rx_no_first++; /* to know how often we come here */
737 EP_FRST(sc, F_RX_FIRST);
738 if (!((status = inw(BASE + EP_W1_RX_STATUS)) & ERR_RX_INCOMPLETE)) {
739 /* we see if by now, the packet has completly arrived */
742 outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_NEXT_EARLY_THRESH);
745 outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK);
747 EP_FSET(sc, F_RX_FIRST);
748 top->m_pkthdr.rcvif = &sc->arpcom.ac_if;
749 top->m_pkthdr.len = sc->cur_len;
751 (*ifp->if_input)(ifp, top);
753 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
754 outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH);
758 outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK);
762 #ifdef EP_LOCAL_STATS
766 EP_FSET(sc, F_RX_FIRST);
767 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
768 outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH);
775 struct ep_softc * sc = ifp->if_softc;
779 outw(BASE + EP_COMMAND, STOP_TRANSCEIVER);
781 outw(BASE + EP_W4_MEDIA_TYPE, DISABLE_UTP);
784 switch (IFM_SUBTYPE(sc->ifmedia.ifm_media)) {
786 if (sc->ep_connectors & UTP) {
787 i = ACF_CONNECTOR_UTP;
789 outw(BASE + EP_W4_MEDIA_TYPE, ENABLE_UTP);
793 if (sc->ep_connectors & BNC) {
794 i = ACF_CONNECTOR_BNC;
795 outw(BASE + EP_COMMAND, START_TRANSCEIVER);
796 DELAY(DELAY_MULTIPLE * 1000);
800 if (sc->ep_connectors & AUI)
801 i = ACF_CONNECTOR_AUI;
804 i = sc->ep_connector;
805 if_printf(ifp, "strange connector type in EEPROM: "
811 j = inw(BASE + EP_W0_ADDRESS_CFG) & 0x3fff;
812 outw(BASE + EP_W0_ADDRESS_CFG, j | (i << ACF_CONNECTOR_BITS));
818 ep_ifmedia_sts(ifp, ifmr)
820 struct ifmediareq * ifmr;
822 struct ep_softc * sc = ifp->if_softc;
824 ifmr->ifm_active = sc->ifmedia.ifm_media;
830 ep_if_ioctl(ifp, cmd, data, cr)
836 struct ep_softc * sc = ifp->if_softc;
837 struct ifreq * ifr = (struct ifreq *)data;
844 if (((ifp->if_flags & IFF_UP) == 0) &&
845 (ifp->if_flags & IFF_RUNNING)) {
846 ifp->if_flags &= ~IFF_RUNNING;
849 /* reinitialize card on any parameter change */
855 bcopy((caddr_t) sc->sc_addr, (caddr_t) & ifr->ifr_data,
856 sizeof(sc->sc_addr));
862 * The Etherlink III has no programmable multicast
863 * filter. We always initialize the card to be
864 * promiscuous to multicast, since we're always a
865 * member of the ALL-SYSTEMS group, so there's no
866 * need to process SIOC*MULTI requests.
872 if (!sc->epb.mii_trans) {
873 error = ifmedia_ioctl(ifp, ifr, &sc->ifmedia, cmd);
879 error = ether_ioctl(ifp, cmd, data);
892 struct ep_softc *sc = ifp->if_softc;
895 if_printf(ifp, "watchdog\n");
897 log(LOG_ERR, "%s: watchdog\n", ifp->if_xname);
905 ifp->if_flags &= ~IFF_OACTIVE;
907 ep_intr(ifp->if_softc);
918 outw(BASE + EP_COMMAND, RX_DISABLE);
919 outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK);
920 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
921 outw(BASE + EP_COMMAND, TX_DISABLE);
922 outw(BASE + EP_COMMAND, STOP_TRANSCEIVER);
923 outw(BASE + EP_COMMAND, RX_RESET);
924 outw(BASE + EP_COMMAND, TX_RESET);
925 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
926 outw(BASE + EP_COMMAND, C_INTR_LATCH);
927 outw(BASE + EP_COMMAND, SET_RD_0_MASK);
928 outw(BASE + EP_COMMAND, SET_INTR_MASK);
929 outw(BASE + EP_COMMAND, SET_RX_FILTER);