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 * $FreeBSD: src/sys/dev/vx/if_vx.c,v 1.25.2.6 2002/02/13 00:43:10 dillon Exp $
31 * $DragonFly: src/sys/dev/netif/vx/if_vx.c,v 1.2 2003/06/17 04:28:33 dillon Exp $
36 * Created from if_ep.c driver by Fred Gray (fgray@rice.edu) to support
41 * Modified from the FreeBSD 1.1.5.1 version by:
43 * INRIA - Sophia Antipolis, France
44 * avega@sophia.inria.fr
48 * Promiscuous mode added and interrupt logic slightly changed
49 * to reduce the number of adapter failures. Transceiver select
50 * logic changed to use value from EEPROM. Autoconfiguration
54 * Chelindbank (Chelyabinsk, Russia)
55 * babkin@hq.icb.chel.su
60 #if NVX < 4 /* These cost 4 bytes apiece, so give us 4 */
66 #include <sys/param.h>
67 #include <sys/systm.h>
68 #include <sys/sockio.h>
69 #include <sys/malloc.h>
71 #include <sys/socket.h>
75 #include <net/ethernet.h>
76 #include <net/if_arp.h>
80 #include <machine/clock.h>
82 #include <dev/vx/if_vxreg.h>
84 #define ETHER_MAX_LEN 1518
85 #define ETHER_ADDR_LEN 6
87 struct vx_softc *vx_softc[NVX];
89 u_long vx_count; /* both PCI and EISA */
91 static struct connector_entry {
94 } conn_tab[VX_CONNECTORS] = {
95 #define CONNECTOR_UTP 0
97 #define CONNECTOR_AUI 1
101 #define CONNECTOR_BNC 3
103 #define CONNECTOR_TX 4
105 #define CONNECTOR_FX 5
107 #define CONNECTOR_MII 6
112 /* struct vx_softc *vxalloc __P((int)); */
113 /* void *vxfree __P((struct vx_softc *)); */
114 /* int vxattach __P((struct vx_softc *)); */
115 static void vxtxstat __P((struct vx_softc *));
116 static int vxstatus __P((struct vx_softc *));
117 static void vxinit __P((void *));
118 static int vxioctl __P((struct ifnet *, u_long, caddr_t));
119 static void vxstart __P((struct ifnet *ifp));
120 static void vxwatchdog __P((struct ifnet *));
121 static void vxreset __P((struct vx_softc *));
122 /* void vxstop __P((struct vx_softc *)); */
123 static void vxread __P((struct vx_softc *));
124 static struct mbuf *vxget __P((struct vx_softc *, u_int));
125 static void vxmbuffill __P((void *));
126 static void vxmbufempty __P((struct vx_softc *));
127 static void vxsetfilter __P((struct vx_softc *));
128 static void vxgetlink __P((struct vx_softc *));
129 static void vxsetlink __P((struct vx_softc *));
130 /* int vxbusyeeprom __P((struct vx_softc *)); */
139 printf("vx%d: unit number too high.\n", unit);
143 if (vx_softc[unit]) {
144 printf("vx%d: already allocated.\n", unit);
148 sc = malloc(sizeof(struct vx_softc), M_DEVBUF, M_NOWAIT);
150 printf("vx%d: cannot malloc.\n", unit);
153 bzero(sc, sizeof(struct vx_softc));
154 callout_handle_init(&sc->ch);
165 vx_softc[sc->unit] = NULL;
174 struct ifnet *ifp = &sc->arpcom.ac_if;
178 outw(VX_COMMAND, GLOBAL_RESET);
184 * Read the station address from the eeprom
187 for (i = 0; i < 3; i++) {
189 if (vxbusyeeprom(sc))
191 outw(BASE + VX_W0_EEPROM_COMMAND, EEPROM_CMD_RD
192 | (EEPROM_OEM_ADDR_0 + i));
193 if (vxbusyeeprom(sc))
195 x = inw(BASE + VX_W0_EEPROM_DATA);
196 sc->arpcom.ac_enaddr[(i << 1)] = x >> 8;
197 sc->arpcom.ac_enaddr[(i << 1) + 1] = x;
200 printf(" address %6D\n", sc->arpcom.ac_enaddr, ":");
202 ifp->if_unit = sc->unit;
204 ifp->if_mtu = ETHERMTU;
205 ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
206 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
207 ifp->if_output = ether_output;
208 ifp->if_start = vxstart;
209 ifp->if_ioctl = vxioctl;
210 ifp->if_init = vxinit;
211 ifp->if_watchdog = vxwatchdog;
214 ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
216 sc->tx_start_thresh = 20; /* probably a good starting point. */
226 * The order in here seems important. Otherwise we may not receive
233 struct vx_softc *sc = (struct vx_softc *) xsc;
234 struct ifnet *ifp = &sc->arpcom.ac_if;
241 for (i = 0; i < 6; i++) /* Reload the ether_addr. */
242 outb(BASE + VX_W2_ADDR_0 + i, sc->arpcom.ac_enaddr[i]);
244 outw(BASE + VX_COMMAND, RX_RESET);
246 outw(BASE + VX_COMMAND, TX_RESET);
249 GO_WINDOW(1); /* Window 1 is operating window */
250 for (i = 0; i < 31; i++)
251 inb(BASE + VX_W1_TX_STATUS);
253 outw(BASE + VX_COMMAND,SET_RD_0_MASK | S_CARD_FAILURE |
254 S_RX_COMPLETE | S_TX_COMPLETE | S_TX_AVAIL);
255 outw(BASE + VX_COMMAND,SET_INTR_MASK | S_CARD_FAILURE |
256 S_RX_COMPLETE | S_TX_COMPLETE | S_TX_AVAIL);
259 * Attempt to get rid of any stray interrupts that occured during
260 * configuration. On the i386 this isn't possible because one may
261 * already be queued. However, a single stray interrupt is
264 outw(BASE + VX_COMMAND, ACK_INTR | 0xff);
269 outw(BASE + VX_COMMAND, RX_ENABLE);
270 outw(BASE + VX_COMMAND, TX_ENABLE);
272 vxmbuffill((caddr_t) sc);
274 /* Interface is now `running', with no output active. */
275 ifp->if_flags |= IFF_RUNNING;
276 ifp->if_flags &= ~IFF_OACTIVE;
278 /* Attempt to start output, if any. */
286 register struct ifnet *ifp = &sc->arpcom.ac_if;
288 GO_WINDOW(1); /* Window 1 is operating window */
289 outw(BASE + VX_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL | FIL_BRDCST |
291 ((ifp->if_flags & IFF_PROMISC) ? FIL_PROMISC : 0 ));
301 sc->vx_connectors = inw(BASE + VX_W3_RESET_OPT) & 0x7f;
302 for (n = 0, k = 0; k < VX_CONNECTORS; k++) {
303 if (sc->vx_connectors & conn_tab[k].bit) {
307 printf("%s", conn_tab[k].name);
311 if (sc->vx_connectors == 0) {
312 printf("no connectors!");
316 sc->vx_connector = (inl(BASE + VX_W3_INTERNAL_CFG)
317 & INTERNAL_CONNECTOR_MASK)
318 >> INTERNAL_CONNECTOR_BITS;
319 if (sc->vx_connector & 0x10) {
320 sc->vx_connector &= 0x0f;
321 printf("[*%s*]", conn_tab[(int)sc->vx_connector].name);
322 printf(": disable 'auto select' with DOS util!");
324 printf("[*%s*]", conn_tab[(int)sc->vx_connector].name);
332 register struct ifnet *ifp = &sc->arpcom.ac_if;
334 char *reason, *warning;
335 static short prev_flags;
336 static char prev_conn = -1;
338 if (prev_conn == -1) {
339 prev_conn = sc->vx_connector;
345 * Now behavior was slightly changed:
347 * if any of flags link[0-2] is used and its connector is
348 * physically present the following connectors are used:
350 * link0 - AUI * highest precedence
352 * link2 - UTP * lowest precedence
354 * If none of them is specified then
355 * connector specified in the EEPROM is used
356 * (if present on card or UTP if not).
359 i = sc->vx_connector; /* default in EEPROM */
363 if (ifp->if_flags & IFF_LINK0) {
364 if (sc->vx_connectors & conn_tab[CONNECTOR_AUI].bit) {
368 warning = "aui not present! (link0)";
370 } else if (ifp->if_flags & IFF_LINK1) {
371 if (sc->vx_connectors & conn_tab[CONNECTOR_BNC].bit) {
375 warning = "bnc not present! (link1)";
377 } else if (ifp->if_flags & IFF_LINK2) {
378 if (sc->vx_connectors & conn_tab[CONNECTOR_UTP].bit) {
382 warning = "utp not present! (link2)";
384 } else if ((sc->vx_connectors & conn_tab[(int)sc->vx_connector].bit) == 0) {
385 warning = "strange connector type in EEPROM.";
390 /* Avoid unnecessary message. */
391 k = (prev_flags ^ ifp->if_flags) & (IFF_LINK0 | IFF_LINK1 | IFF_LINK2);
392 if ((k != 0) || (prev_conn != i)) {
394 printf("vx%d: warning: %s\n", sc->unit, warning);
396 printf("vx%d: selected %s. (%s)\n",
397 sc->unit, conn_tab[i].name, reason);
400 /* Set the selected connector. */
402 j = inl(BASE + VX_W3_INTERNAL_CFG) & ~INTERNAL_CONNECTOR_MASK;
403 outl(BASE + VX_W3_INTERNAL_CFG, j | (i <<INTERNAL_CONNECTOR_BITS));
405 /* First, disable all. */
406 outw(BASE + VX_COMMAND, STOP_TRANSCEIVER);
409 outw(BASE + VX_W4_MEDIA_TYPE, 0);
411 /* Second, enable the selected one. */
415 outw(BASE + VX_W4_MEDIA_TYPE, ENABLE_UTP);
418 outw(BASE + VX_COMMAND, START_TRANSCEIVER);
424 outw(BASE + VX_W4_MEDIA_TYPE, LINKBEAT_ENABLE);
426 default: /* AUI and MII fall here */
431 prev_flags = ifp->if_flags;
439 register struct vx_softc *sc = vx_softc[ifp->if_unit];
440 register struct mbuf *m0;
443 /* Don't transmit if interface is busy or not running */
444 if ((sc->arpcom.ac_if.if_flags & (IFF_RUNNING|IFF_OACTIVE)) != IFF_RUNNING)
448 /* Sneak a peek at the next packet */
449 m0 = ifp->if_snd.ifq_head;
453 /* We need to use m->m_pkthdr.len, so require the header */
454 if ((m0->m_flags & M_PKTHDR) == 0)
455 panic("vxstart: no header mbuf");
456 len = m0->m_pkthdr.len;
461 * The 3c509 automatically pads short packets to minimum ethernet length,
462 * but we drop packets that are too large. Perhaps we should truncate
465 if (len + pad > ETHER_MAX_LEN) {
466 /* packet is obviously too large: toss it */
468 IF_DEQUEUE(&ifp->if_snd, m0);
473 if (inw(BASE + VX_W1_FREE_TX) < len + pad + 4) {
474 outw(BASE + VX_COMMAND, SET_TX_AVAIL_THRESH | ((len + pad + 4) >> 2));
475 /* not enough room in FIFO */
476 if (inw(BASE + VX_W1_FREE_TX) < len + pad + 4) { /* make sure */
477 ifp->if_flags |= IFF_OACTIVE;
482 outw(BASE + VX_COMMAND, SET_TX_AVAIL_THRESH | (8188 >> 2));
483 IF_DEQUEUE(&ifp->if_snd, m0);
484 if (m0 == NULL) { /* not really needed */
489 outw(BASE + VX_COMMAND, SET_TX_START_THRESH |
490 ((len / 4 + sc->tx_start_thresh) >> 2));
492 if (sc->arpcom.ac_if.if_bpf) {
493 bpf_mtap(&sc->arpcom.ac_if, m0);
497 * Do the output at splhigh() so that an interrupt from another device
498 * won't cause a FIFO underrun.
502 outl(BASE + VX_W1_TX_PIO_WR_1, len | TX_INDICATE);
506 outsl(BASE + VX_W1_TX_PIO_WR_1, mtod(m0, caddr_t), m0->m_len / 4);
508 outsb(BASE + VX_W1_TX_PIO_WR_1,
509 mtod(m0, caddr_t) + (m0->m_len & ~3) , m0->m_len & 3);
513 outb(BASE + VX_W1_TX_PIO_WR_1, 0); /* Padding */
521 if ((inw(BASE + VX_W1_RX_STATUS) & ERR_INCOMPLETE) == 0) {
522 /* We received a complete packet. */
524 if ((inw(BASE + VX_STATUS) & S_INTR_LATCH) == 0) {
526 * No interrupt, read the packet and continue
527 * Is this supposed to happen? Is my motherboard
532 /* Got an interrupt, return so that it gets serviced. */
535 /* Check if we are stuck and reset [see XXX comment] */
537 if (ifp->if_flags & IFF_DEBUG)
538 printf("vx%d: adapter reset\n", ifp->if_unit);
547 * XXX: The 3c509 card can get in a mode where both the fifo status bit
548 * FIFOS_RX_OVERRUN and the status bit ERR_INCOMPLETE are set
549 * We detect this situation and we reset the adapter.
550 * It happens at times when there is a lot of broadcast traffic
551 * on the cable (once in a blue moon).
560 * Check the FIFO status and act accordingly
563 fifost = inw(BASE + VX_W4_FIFO_DIAG);
566 if (fifost & FIFOS_RX_UNDERRUN) {
567 if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
568 printf("vx%d: RX underrun\n", sc->unit);
573 if (fifost & FIFOS_RX_STATUS_OVERRUN) {
574 if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
575 printf("vx%d: RX Status overrun\n", sc->unit);
579 if (fifost & FIFOS_RX_OVERRUN) {
580 if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
581 printf("vx%d: RX overrun\n", sc->unit);
585 if (fifost & FIFOS_TX_OVERRUN) {
586 if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
587 printf("vx%d: TX overrun\n", sc->unit);
602 * We need to read+write TX_STATUS until we get a 0 status
603 * in order to turn off the interrupt flag.
605 while ((i = inb(BASE + VX_W1_TX_STATUS)) & TXS_COMPLETE) {
606 outb(BASE + VX_W1_TX_STATUS, 0x0);
608 if (i & TXS_JABBER) {
609 ++sc->arpcom.ac_if.if_oerrors;
610 if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
611 printf("vx%d: jabber (%x)\n", sc->unit, i);
613 } else if (i & TXS_UNDERRUN) {
614 ++sc->arpcom.ac_if.if_oerrors;
615 if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
616 printf("vx%d: fifo underrun (%x) @%d\n",
617 sc->unit, i, sc->tx_start_thresh);
618 if (sc->tx_succ_ok < 100)
619 sc->tx_start_thresh = min(ETHER_MAX_LEN, sc->tx_start_thresh + 20);
622 } else if (i & TXS_MAX_COLLISION) {
623 ++sc->arpcom.ac_if.if_collisions;
624 outw(BASE + VX_COMMAND, TX_ENABLE);
625 sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
627 sc->tx_succ_ok = (sc->tx_succ_ok+1) & 127;
635 register short status;
636 struct vx_softc *sc = voidsc;
637 struct ifnet *ifp = &sc->arpcom.ac_if;
640 outw(BASE + VX_COMMAND, C_INTR_LATCH);
642 status = inw(BASE + VX_STATUS);
644 if ((status & (S_TX_COMPLETE | S_TX_AVAIL |
645 S_RX_COMPLETE | S_CARD_FAILURE)) == 0)
649 * Acknowledge any interrupts. It's important that we do this
650 * first, since there would otherwise be a race condition.
651 * Due to the i386 interrupt queueing, we may get spurious
652 * interrupts occasionally.
654 outw(BASE + VX_COMMAND, ACK_INTR | status);
656 if (status & S_RX_COMPLETE)
658 if (status & S_TX_AVAIL) {
660 sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
661 vxstart(&sc->arpcom.ac_if);
663 if (status & S_CARD_FAILURE) {
664 printf("vx%d: adapter failure (%x)\n", sc->unit, status);
669 if (status & S_TX_COMPLETE) {
676 /* no more interrupts */
684 struct ifnet *ifp = &sc->arpcom.ac_if;
686 struct ether_header *eh;
689 len = inw(BASE + VX_W1_RX_STATUS);
693 if (ifp->if_flags & IFF_DEBUG) {
694 int err = len & ERR_MASK;
697 if (len & ERR_INCOMPLETE)
698 s = "incomplete packet";
699 else if (err == ERR_OVERRUN)
700 s = "packet overrun";
701 else if (err == ERR_RUNT)
703 else if (err == ERR_ALIGNMENT)
705 else if (err == ERR_CRC)
707 else if (err == ERR_OVERSIZE)
708 s = "oversized packet";
709 else if (err == ERR_DRIBBLE)
713 printf("vx%d: %s\n", sc->unit, s);
716 if (len & ERR_INCOMPLETE)
724 len &= RX_BYTES_MASK; /* Lower 11 bits = RX bytes. */
726 /* Pull packet off interface. */
735 /* We assume the header fit entirely in one mbuf. */
736 eh = mtod(m, struct ether_header *);
739 * XXX: Some cards seem to be in promiscous mode all the time.
740 * we need to make sure we only get our own stuff always.
744 if ((eh->ether_dhost[0] & 1) == 0 /* !mcast and !bcast */
745 && bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN) != 0) {
750 m_adj(m, sizeof(struct ether_header));
751 ether_input(ifp, eh, m);
754 * In periods of high traffic we can actually receive enough
755 * packets so that the fifo overrun bit will be set at this point,
756 * even though we just read a packet. In this case we
757 * are not going to receive any more interrupts. We check for
758 * this condition and read again until the fifo is not full.
759 * We could simplify this test by not using vxstatus(), but
760 * rechecking the RX_STATUS register directly. This test could
761 * result in unnecessary looping in cases where there is a new
762 * packet but the fifo is not full, but it will not fix the
765 * Even with this improvement, we still get packet overrun errors
766 * which are hurting performance. Maybe when I get some more time
767 * I'll modify vxread() so that it can handle RX_EARLY interrupts.
770 len = inw(BASE + VX_W1_RX_STATUS);
771 /* Check if we are stuck and reset [see XXX comment] */
772 if (len & ERR_INCOMPLETE) {
773 if (ifp->if_flags & IFF_DEBUG)
774 printf("vx%d: adapter reset\n", sc->unit);
784 outw(BASE + VX_COMMAND, RX_DISCARD_TOP_PACK);
792 struct ifnet *ifp = &sc->arpcom.ac_if;
793 struct mbuf *top, **mp, *m;
797 m = sc->mb[sc->next_mb];
798 sc->mb[sc->next_mb] = 0;
800 MGETHDR(m, M_DONTWAIT, MT_DATA);
804 /* If the queue is no longer full, refill. */
805 if (sc->last_mb == sc->next_mb && sc->buffill_pending == 0) {
806 sc->ch = timeout(vxmbuffill, sc, 1);
807 sc->buffill_pending = 1;
809 /* Convert one of our saved mbuf's. */
810 sc->next_mb = (sc->next_mb + 1) % MAX_MBS;
811 m->m_data = m->m_pktdat;
812 m->m_flags = M_PKTHDR;
813 bzero(&m->m_pkthdr, sizeof(m->m_pkthdr));
815 m->m_pkthdr.rcvif = ifp;
816 m->m_pkthdr.len = totlen;
822 * We read the packet at splhigh() so that an interrupt from another
823 * device doesn't cause the card's buffer to overflow while we're
824 * reading it. We may still lose packets at other times.
829 * Since we don't set allowLargePackets bit in MacControl register,
830 * we can assume that totlen <= 1500bytes.
831 * The while loop will be performed iff we have a packet with
832 * MLEN < m_len < MINCLSIZE.
836 m = sc->mb[sc->next_mb];
837 sc->mb[sc->next_mb] = 0;
839 MGET(m, M_DONTWAIT, MT_DATA);
846 sc->next_mb = (sc->next_mb + 1) % MAX_MBS;
850 if (totlen >= MINCLSIZE) {
851 MCLGET(m, M_DONTWAIT);
852 if (m->m_flags & M_EXT)
855 len = min(totlen, len);
857 insl(BASE + VX_W1_RX_PIO_RD_1, mtod(m, u_int32_t *), len / 4);
859 insb(BASE + VX_W1_RX_PIO_RD_1, mtod(m, u_int8_t *) + (len & ~3),
868 outw(BASE +VX_COMMAND, RX_DISCARD_TOP_PACK);
877 vxioctl(ifp, cmd, data)
878 register struct ifnet *ifp;
882 struct vx_softc *sc = vx_softc[ifp->if_unit];
883 struct ifreq *ifr = (struct ifreq *) data;
891 ether_ioctl(ifp, cmd, data);
895 if ((ifp->if_flags & IFF_UP) == 0 &&
896 (ifp->if_flags & IFF_RUNNING) != 0) {
898 * If interface is marked up and it is stopped, then
902 ifp->if_flags &= ~IFF_RUNNING;
903 } else if ((ifp->if_flags & IFF_UP) != 0 &&
904 (ifp->if_flags & IFF_RUNNING) == 0) {
906 * If interface is marked up and it is stopped, then
912 * deal with flags changes:
913 * IFF_MULTICAST, IFF_PROMISC,
914 * IFF_LINK0, IFF_LINK1,
923 * Set the interface MTU.
925 if (ifr->ifr_mtu > ETHERMTU) {
928 ifp->if_mtu = ifr->ifr_mtu;
935 * Multicast list has changed; set the hardware filter
968 struct vx_softc *sc = vx_softc[ifp->if_unit];
970 if (ifp->if_flags & IFF_DEBUG)
971 printf("vx%d: device timeout\n", ifp->if_unit);
972 ifp->if_flags &= ~IFF_OACTIVE;
981 struct ifnet *ifp = &sc->arpcom.ac_if;
985 outw(BASE + VX_COMMAND, RX_DISABLE);
986 outw(BASE + VX_COMMAND, RX_DISCARD_TOP_PACK);
988 outw(BASE + VX_COMMAND, TX_DISABLE);
989 outw(BASE + VX_COMMAND, STOP_TRANSCEIVER);
991 outw(BASE + VX_COMMAND, RX_RESET);
993 outw(BASE + VX_COMMAND, TX_RESET);
995 outw(BASE + VX_COMMAND, C_INTR_LATCH);
996 outw(BASE + VX_COMMAND, SET_RD_0_MASK);
997 outw(BASE + VX_COMMAND, SET_INTR_MASK);
998 outw(BASE + VX_COMMAND, SET_RX_FILTER);
1005 struct vx_softc *sc;
1010 j = inw(BASE + VX_W0_EEPROM_COMMAND);
1011 if (j & EEPROM_BUSY)
1017 printf("vx%d: eeprom failed to come ready\n", sc->unit);
1027 struct vx_softc *sc = (struct vx_softc *) sp;
1033 if (sc->mb[i] == NULL)
1034 MGET(sc->mb[i], M_DONTWAIT, MT_DATA);
1035 if (sc->mb[i] == NULL)
1037 i = (i + 1) % MAX_MBS;
1038 } while (i != sc->next_mb);
1040 /* If the queue was not filled, try again. */
1041 if (sc->last_mb != sc->next_mb) {
1042 sc->ch = timeout(vxmbuffill, sc, 1);
1043 sc->buffill_pending = 1;
1045 sc->buffill_pending = 0;
1052 struct vx_softc *sc;
1057 for (i = 0; i < MAX_MBS; i++) {
1063 sc->last_mb = sc->next_mb = 0;
1064 if (sc->buffill_pending != 0)
1065 untimeout(vxmbuffill, sc, sc->ch);