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 $
43 * Promiscuous mode added and interrupt logic slightly changed
44 * to reduce the number of adapter failures. Transceiver select
45 * logic changed to use value from EEPROM. Autoconfiguration
49 * Chelindbank (Chelyabinsk, Russia)
50 * babkin@hq.icb.chel.su
54 * Pccard support for 3C589 by:
60 * MAINTAINER: Matthew N. Dodd <winter@jurai.net>
64 #include <sys/param.h>
65 #include <sys/kernel.h>
66 #include <sys/systm.h>
67 #include <sys/malloc.h>
69 #include <sys/socket.h>
70 #include <sys/sockio.h>
71 #include <sys/module.h>
74 #include <sys/thread2.h>
77 #include <net/ifq_var.h>
78 #include <net/if_arp.h>
79 #include <net/if_media.h>
80 #include <net/ethernet.h>
83 #include <netinet/in.h>
84 #include <netinet/if_ether.h>
86 #include <machine/clock.h>
90 #include "../elink_layer/elink.h"
92 /* Exported variables */
93 devclass_t ep_devclass;
96 static char * ep_conn_type[] = {"UTP", "AUI", "???", "BNC"};
97 static int if_media2ep_media[] = { 0, 0, 0, UTP, BNC, AUI };
100 static int ep_media2if_media[] =
101 { IFM_10_T, IFM_10_5, IFM_NONE, IFM_10_2, IFM_NONE };
104 static void ep_if_init (void *);
105 static int ep_if_ioctl(struct ifnet *, u_long, caddr_t, struct ucred *);
106 static void ep_if_start (struct ifnet *);
107 static void ep_if_watchdog (struct ifnet *);
109 /* if_media functions */
110 static int ep_ifmedia_upd (struct ifnet *);
111 static void ep_ifmedia_sts (struct ifnet *, struct ifmediareq *);
113 static void epstop (struct ep_softc *);
114 static void epread (struct ep_softc *);
115 static int eeprom_rdy (struct ep_softc *);
117 DECLARE_DUMMY_MODULE(if_ep);
119 #define EP_FTST(sc, f) (sc->stat & (f))
120 #define EP_FSET(sc, f) (sc->stat |= (f))
121 #define EP_FRST(sc, f) (sc->stat &= ~(f))
124 eeprom_rdy(struct ep_softc *sc)
128 for (i = 0; is_eeprom_busy(BASE) && i < MAX_EEPROMBUSY; i++) {
131 if (i >= MAX_EEPROMBUSY) {
132 if_printf(&sc->arpcom.ac_if, "eeprom failed to come ready.\n");
139 * get_e: gets a 16 bits word from the EEPROM. we must have set the window
143 get_e(struct ep_softc *sc, int offset)
147 outw(BASE + EP_W0_EEPROM_COMMAND, (EEPROM_CMD_RD << sc->epb.cmd_off) | offset);
150 return (inw(BASE + EP_W0_EEPROM_DATA));
154 ep_get_macaddr(struct ep_softc *sc, uint8_t *addr)
157 u_int16_t * macaddr = (u_int16_t *)addr;
160 for(i = EEPROM_NODE_ADDR_0; i <= EEPROM_NODE_ADDR_2; i++) {
161 macaddr[i] = htons(get_e(sc, i));
168 ep_alloc(device_t dev)
170 struct ep_softc * sc = device_get_softc(dev);
175 sc->iobase = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid,
178 device_printf(dev, "No I/O space?!\n");
184 sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
186 device_printf(dev, "No irq?!\n");
191 if_initname(&sc->arpcom.ac_if,
192 device_get_name(dev), device_get_unit(dev));
193 sc->stat = 0; /* 16 bit access */
195 sc->ep_io_addr = rman_get_start(sc->iobase);
197 sc->ep_btag = rman_get_bustag(sc->iobase);
198 sc->ep_bhandle = rman_get_bushandle(sc->iobase);
200 sc->ep_connectors = 0;
201 sc->ep_connector = 0;
205 sc->epb.prod_id = get_e(sc, EEPROM_PROD_ID);
206 sc->epb.res_cfg = get_e(sc, EEPROM_RESOURCE_CFG);
213 ep_get_media(struct ep_softc *sc)
218 config = inw(BASE + EP_W0_CONFIG_CTRL);
220 sc->ep_connectors |= AUI;
222 sc->ep_connectors |= BNC;
224 sc->ep_connectors |= UTP;
226 if (!(sc->ep_connectors & 7)) {
228 if_printf(&sc->arpcom.ac_if, "no connectors!\n");
232 * This works for most of the cards so we'll do it here.
233 * The cards that require something different can override
236 sc->ep_connector = inw(BASE + EP_W0_ADDRESS_CFG) >> ACF_CONNECTOR_BITS;
242 ep_free(device_t dev)
244 struct ep_softc * sc = device_get_softc(dev);
247 bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->iobase);
249 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq);
255 ep_attach(struct ep_softc *sc)
257 struct ifnet * ifp = NULL;
258 struct ifmedia * ifm = NULL;
260 uint8_t ether_addr[ETHER_ADDR_LEN];
265 ep_get_macaddr(sc, ether_addr);
268 * Setup the station address
270 p = (u_short*)ether_addr;
272 for (i = 0; i < 3; i++) {
273 outw(BASE + EP_W2_ADDR_0 + (i * 2), ntohs(p[i]));
276 ifp = &sc->arpcom.ac_if;
279 ifp->if_mtu = ETHERMTU;
280 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
281 ifp->if_start = ep_if_start;
282 ifp->if_ioctl = ep_if_ioctl;
283 ifp->if_watchdog = ep_if_watchdog;
284 ifp->if_init = ep_if_init;
285 ifq_set_maxlen(&ifp->if_snd, IFQ_MAXLEN);
286 ifq_set_ready(&ifp->if_snd);
288 if (!sc->epb.mii_trans) {
289 ifmedia_init(&sc->ifmedia, 0, ep_ifmedia_upd, ep_ifmedia_sts);
291 if (sc->ep_connectors & AUI)
292 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_5, 0, NULL);
293 if (sc->ep_connectors & UTP)
294 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_T, 0, NULL);
295 if (sc->ep_connectors & BNC)
296 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_2, 0, NULL);
297 if (!sc->ep_connectors)
298 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_NONE, 0, NULL);
300 ifmedia_set(&sc->ifmedia, IFM_ETHER|ep_media2if_media[sc->ep_connector]);
303 ifm->ifm_media = ifm->ifm_cur->ifm_media;
307 ether_ifattach(ifp, ether_addr, NULL);
309 #ifdef EP_LOCAL_STATS
310 sc->rx_no_first = sc->rx_no_mbuf = sc->rx_bpf_disc =
311 sc->rx_overrunf = sc->rx_overrunl = sc->tx_underrun = 0;
313 EP_FSET(sc, F_RX_FIRST);
314 sc->top = sc->mcur = 0;
320 * The order in here seems important. Otherwise we may not receive
324 ep_if_init(void *xsc)
326 struct ep_softc *sc = xsc;
327 struct ifnet *ifp = &sc->arpcom.ac_if;
335 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
338 outw(BASE + EP_COMMAND, STOP_TRANSCEIVER);
340 outw(BASE + EP_W4_MEDIA_TYPE, DISABLE_UTP);
343 /* Disable the card */
344 outw(BASE + EP_W0_CONFIG_CTRL, 0);
346 /* Enable the card */
347 outw(BASE + EP_W0_CONFIG_CTRL, ENABLE_DRQ_IRQ);
351 /* Reload the ether_addr. */
352 for (i = 0; i < 6; i++)
353 outb(BASE + EP_W2_ADDR_0 + i, sc->arpcom.ac_enaddr[i]);
355 outw(BASE + EP_COMMAND, RX_RESET);
356 outw(BASE + EP_COMMAND, TX_RESET);
357 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
359 /* Window 1 is operating window */
361 for (i = 0; i < 31; i++)
362 inb(BASE + EP_W1_TX_STATUS);
364 /* get rid of stray intr's */
365 outw(BASE + EP_COMMAND, ACK_INTR | 0xff);
367 outw(BASE + EP_COMMAND, SET_RD_0_MASK | S_5_INTS);
369 outw(BASE + EP_COMMAND, SET_INTR_MASK | S_5_INTS);
371 if (ifp->if_flags & IFF_PROMISC)
372 outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL |
373 FIL_GROUP | FIL_BRDCST | FIL_ALL);
375 outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL |
376 FIL_GROUP | FIL_BRDCST);
378 if (!sc->epb.mii_trans) {
382 outw(BASE + EP_COMMAND, RX_ENABLE);
383 outw(BASE + EP_COMMAND, TX_ENABLE);
385 ifp->if_flags |= IFF_RUNNING;
386 ifp->if_flags &= ~IFF_OACTIVE; /* just in case */
388 #ifdef EP_LOCAL_STATS
389 sc->rx_no_first = sc->rx_no_mbuf =
390 sc->rx_overrunf = sc->rx_overrunl = sc->tx_underrun = 0;
392 EP_FSET(sc, F_RX_FIRST);
395 sc->top = sc->mcur = 0;
397 outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH);
398 outw(BASE + EP_COMMAND, SET_TX_START_THRESH | 16);
401 * Store up a bunch of mbuf's for use later. (MAX_MBS). First we free up
402 * any that we had in case we're being called from intr or somewhere
413 static const char padmap[] = {0, 3, 2, 1};
416 ep_if_start(struct ifnet *ifp)
418 struct ep_softc *sc = ifp->if_softc;
425 ifq_purge(&ifp->if_snd);
429 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
430 if (ifp->if_flags & IFF_OACTIVE) {
437 /* Sneak a peek at the next packet */
438 m = ifq_dequeue(&ifp->if_snd, NULL);
444 for (len = 0, top = m; m; m = m->m_next)
448 pad = padmap[len & 3];
451 * The 3c509 automatically pads short packets to minimum ethernet length,
452 * but we drop packets that are too large. Perhaps we should truncate
455 if (len + pad > ETHER_MAX_LEN) {
456 /* packet is obviously too large: toss it */
461 if (inw(BASE + EP_W1_FREE_TX) < len + pad + 4) {
462 /* no room in FIFO */
463 outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | (len + pad + 4));
465 if (inw(BASE + EP_W1_FREE_TX) < len + pad + 4) {
466 ifp->if_flags |= IFF_OACTIVE;
467 ifq_prepend(&ifp->if_snd, top);
472 outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | EP_THRESH_DISABLE);
475 outw(BASE + EP_W1_TX_PIO_WR_1, len);
476 outw(BASE + EP_W1_TX_PIO_WR_1, 0x0); /* Second dword meaningless */
478 if (EP_FTST(sc, F_ACCESS_32_BITS)) {
479 for (top = m; m != NULL; m = m->m_next) {
480 outsl(BASE + EP_W1_TX_PIO_WR_1, mtod(m, caddr_t),
483 outsb(BASE + EP_W1_TX_PIO_WR_1,
484 mtod(m, caddr_t) + (m->m_len & (~3)),
488 for (top = m; m != NULL; m = m->m_next) {
489 outsw(BASE + EP_W1_TX_PIO_WR_1, mtod(m, caddr_t), m->m_len / 2);
491 outb(BASE + EP_W1_TX_PIO_WR_1,
492 *(mtod(m, caddr_t) + m->m_len - 1));
497 outb(BASE + EP_W1_TX_PIO_WR_1, 0); /* Padding */
506 * Is another packet coming in? We don't want to overflow the tiny RX
510 if (inw(BASE + EP_W1_RX_STATUS) & RX_BYTES_MASK) {
512 * we check if we have packets left, in that case we prepare to come
515 if (!ifq_is_empty(&ifp->if_snd))
516 outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | 8);
527 struct ep_softc *sc = arg;
528 struct ifnet *ifp = &sc->arpcom.ac_if;
532 * quick fix: Try to detect an interrupt when the card goes away.
534 if (sc->gone || inw(BASE + EP_STATUS) == 0xffff) {
538 outw(BASE + EP_COMMAND, SET_INTR_MASK); /* disable all Ints */
542 while ((status = inw(BASE + EP_STATUS)) & S_5_INTS) {
544 /* first acknowledge all interrupt sources */
545 outw(BASE + EP_COMMAND, ACK_INTR | (status & S_MASK));
547 if (status & (S_RX_COMPLETE | S_RX_EARLY))
549 if (status & S_TX_AVAIL) {
552 ifp->if_flags &= ~IFF_OACTIVE;
554 inw(BASE + EP_W1_FREE_TX);
557 if (status & S_CARD_FAILURE) {
559 #ifdef EP_LOCAL_STATS
561 if_printf(ifp, "\n\tStatus: %x\n", status);
563 kprintf("\tFIFO Diagnostic: %x\n", inw(BASE + EP_W4_FIFO_DIAG));
564 kprintf("\tStat: %x\n", sc->stat);
565 kprintf("\tIpackets=%d, Opackets=%d\n",
566 ifp->if_ipackets, ifp->if_opackets);
567 kprintf("\tNOF=%d, NOMB=%d, RXOF=%d, RXOL=%d, TXU=%d\n",
568 sc->rx_no_first, sc->rx_no_mbuf, sc->rx_overrunf,
569 sc->rx_overrunl, sc->tx_underrun);
573 if_printf(ifp, "Status: %x (input buffer overflow)\n", status);
582 if (status & S_TX_COMPLETE) {
584 /* we need ACK. we do it at the end */
586 * We need to read TX_STATUS until we get a 0 status in order to
587 * turn off the interrupt flag.
589 while ((status = inb(BASE + EP_W1_TX_STATUS)) & TXS_COMPLETE) {
590 if (status & TXS_SUCCES_INTR_REQ);
591 else if (status & (TXS_UNDERRUN | TXS_JABBER | TXS_MAX_COLLISION)) {
592 outw(BASE + EP_COMMAND, TX_RESET);
593 if (status & TXS_UNDERRUN) {
594 #ifdef EP_LOCAL_STATS
598 if (status & TXS_JABBER);
599 else /* TXS_MAX_COLLISION - we shouldn't get here */
600 ++ifp->if_collisions;
603 outw(BASE + EP_COMMAND, TX_ENABLE);
605 * To have a tx_avail_int but giving the chance to the
608 if (!ifq_is_empty(&ifp->if_snd))
609 outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | 8);
611 outb(BASE + EP_W1_TX_STATUS, 0x0); /* pops up the next
614 ifp->if_flags &= ~IFF_OACTIVE;
616 inw(BASE + EP_W1_FREE_TX);
618 } /* end TX_COMPLETE */
621 outw(BASE + EP_COMMAND, C_INTR_LATCH); /* ACK int Latch */
623 if ((status = inw(BASE + EP_STATUS)) & S_5_INTS)
627 outw(BASE + EP_COMMAND, SET_INTR_MASK | S_5_INTS);
631 epread(struct ep_softc *sc)
633 struct mbuf *top, *mcur, *m;
637 short rx_fifo2, status;
640 ifp = &sc->arpcom.ac_if;
641 status = inw(BASE + EP_W1_RX_STATUS);
645 if (status & ERR_RX) {
647 if (status & ERR_RX_OVERRUN) {
649 * we can think the rx latency is actually greather than we
652 #ifdef EP_LOCAL_STATS
653 if (EP_FTST(sc, F_RX_FIRST))
661 rx_fifo = rx_fifo2 = status & RX_BYTES_MASK;
663 if (EP_FTST(sc, F_RX_FIRST)) {
664 m = m_getl(rx_fifo, MB_DONTWAIT, MT_DATA, M_PKTHDR, NULL);
667 sc->top = sc->mcur = top = m;
668 #define EROUND ((sizeof(struct ether_header) + 3) & ~3)
669 #define EOFF (EROUND - sizeof(struct ether_header))
672 /* Read what should be the header. */
673 insw(BASE + EP_W1_RX_PIO_RD_1,
674 mtod(top, caddr_t), sizeof(struct ether_header) / 2);
675 top->m_len = sizeof(struct ether_header);
676 rx_fifo -= sizeof(struct ether_header);
677 sc->cur_len = rx_fifo2;
679 /* come here if we didn't have a complete packet last time */
682 sc->cur_len += rx_fifo2;
685 /* Reads what is left in the RX FIFO */
686 while (rx_fifo > 0) {
687 lenthisone = min(rx_fifo, M_TRAILINGSPACE(m));
688 if (lenthisone == 0) { /* no room in this one */
690 m = m_getl(rx_fifo, MB_DONTWAIT, MT_DATA, 0, NULL);
695 lenthisone = min(rx_fifo, M_TRAILINGSPACE(m));
697 if (EP_FTST(sc, F_ACCESS_32_BITS)) { /* default for EISA configured cards*/
698 insl(BASE + EP_W1_RX_PIO_RD_1, mtod(m, caddr_t) + m->m_len,
700 m->m_len += (lenthisone & ~3);
702 insb(BASE + EP_W1_RX_PIO_RD_1,
703 mtod(m, caddr_t) + m->m_len,
705 m->m_len += (lenthisone & 3);
707 insw(BASE + EP_W1_RX_PIO_RD_1, mtod(m, caddr_t) + m->m_len,
709 m->m_len += lenthisone;
711 *(mtod(m, caddr_t) + m->m_len - 1) = inb(BASE + EP_W1_RX_PIO_RD_1);
713 rx_fifo -= lenthisone;
716 if (status & ERR_RX_INCOMPLETE) { /* we haven't received the complete
719 #ifdef EP_LOCAL_STATS
720 sc->rx_no_first++; /* to know how often we come here */
722 EP_FRST(sc, F_RX_FIRST);
723 if (!((status = inw(BASE + EP_W1_RX_STATUS)) & ERR_RX_INCOMPLETE)) {
724 /* we see if by now, the packet has completly arrived */
727 outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_NEXT_EARLY_THRESH);
730 outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK);
732 EP_FSET(sc, F_RX_FIRST);
733 top->m_pkthdr.rcvif = &sc->arpcom.ac_if;
734 top->m_pkthdr.len = sc->cur_len;
736 ifp->if_input(ifp, top);
738 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
739 outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH);
743 outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK);
747 #ifdef EP_LOCAL_STATS
751 EP_FSET(sc, F_RX_FIRST);
752 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
753 outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH);
757 ep_ifmedia_upd(struct ifnet *ifp)
759 struct ep_softc * sc = ifp->if_softc;
763 outw(BASE + EP_COMMAND, STOP_TRANSCEIVER);
765 outw(BASE + EP_W4_MEDIA_TYPE, DISABLE_UTP);
768 switch (IFM_SUBTYPE(sc->ifmedia.ifm_media)) {
770 if (sc->ep_connectors & UTP) {
771 i = ACF_CONNECTOR_UTP;
773 outw(BASE + EP_W4_MEDIA_TYPE, ENABLE_UTP);
777 if (sc->ep_connectors & BNC) {
778 i = ACF_CONNECTOR_BNC;
779 outw(BASE + EP_COMMAND, START_TRANSCEIVER);
780 DELAY(DELAY_MULTIPLE * 1000);
784 if (sc->ep_connectors & AUI)
785 i = ACF_CONNECTOR_AUI;
788 i = sc->ep_connector;
789 if_printf(ifp, "strange connector type in EEPROM: "
795 j = inw(BASE + EP_W0_ADDRESS_CFG) & 0x3fff;
796 outw(BASE + EP_W0_ADDRESS_CFG, j | (i << ACF_CONNECTOR_BITS));
802 ep_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
804 struct ep_softc * sc = ifp->if_softc;
806 ifmr->ifm_active = sc->ifmedia.ifm_media;
812 ep_if_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *cr)
814 struct ep_softc * sc = ifp->if_softc;
815 struct ifreq * ifr = (struct ifreq *)data;
822 if (((ifp->if_flags & IFF_UP) == 0) &&
823 (ifp->if_flags & IFF_RUNNING)) {
824 ifp->if_flags &= ~IFF_RUNNING;
827 /* reinitialize card on any parameter change */
833 bcopy((caddr_t) sc->sc_addr, (caddr_t) & ifr->ifr_data,
834 sizeof(sc->sc_addr));
840 * The Etherlink III has no programmable multicast
841 * filter. We always initialize the card to be
842 * promiscuous to multicast, since we're always a
843 * member of the ALL-SYSTEMS group, so there's no
844 * need to process SIOC*MULTI requests.
850 if (!sc->epb.mii_trans) {
851 error = ifmedia_ioctl(ifp, ifr, &sc->ifmedia, cmd);
857 error = ether_ioctl(ifp, cmd, data);
867 ep_if_watchdog(struct ifnet *ifp)
869 struct ep_softc *sc = ifp->if_softc;
872 if_printf(ifp, "watchdog\n");
874 log(LOG_ERR, "%s: watchdog\n", ifp->if_xname);
882 ifp->if_flags &= ~IFF_OACTIVE;
884 ep_intr(ifp->if_softc);
888 epstop(struct ep_softc *sc)
894 outw(BASE + EP_COMMAND, RX_DISABLE);
895 outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK);
896 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
897 outw(BASE + EP_COMMAND, TX_DISABLE);
898 outw(BASE + EP_COMMAND, STOP_TRANSCEIVER);
899 outw(BASE + EP_COMMAND, RX_RESET);
900 outw(BASE + EP_COMMAND, TX_RESET);
901 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
902 outw(BASE + EP_COMMAND, C_INTR_LATCH);
903 outw(BASE + EP_COMMAND, SET_RD_0_MASK);
904 outw(BASE + EP_COMMAND, SET_INTR_MASK);
905 outw(BASE + EP_COMMAND, SET_RX_FILTER);