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.14 2004/09/15 01:09:23 joerg 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
58 #include <sys/param.h>
59 #include <sys/systm.h>
60 #include <sys/sockio.h>
61 #include <sys/malloc.h>
63 #include <sys/socket.h>
64 #include <sys/linker_set.h>
65 #include <sys/module.h>
69 #include <net/ethernet.h>
70 #include <net/if_arp.h>
72 #include <machine/bus_pio.h>
73 #include <machine/bus.h>
77 #include <machine/clock.h>
81 #define ETHER_MAX_LEN 1518
82 #define ETHER_ADDR_LEN 6
84 DECLARE_DUMMY_MODULE(if_vx);
86 static struct connector_entry {
89 } conn_tab[VX_CONNECTORS] = {
90 #define CONNECTOR_UTP 0
92 #define CONNECTOR_AUI 1
96 #define CONNECTOR_BNC 3
98 #define CONNECTOR_TX 4
100 #define CONNECTOR_FX 5
102 #define CONNECTOR_MII 6
107 /* int vxattach (struct vx_softc *); */
108 static void vxtxstat (struct vx_softc *);
109 static int vxstatus (struct vx_softc *);
110 static void vxinit (void *);
111 static int vxioctl (struct ifnet *, u_long, caddr_t, struct ucred *);
112 static void vxstart (struct ifnet *ifp);
113 static void vxwatchdog (struct ifnet *);
114 static void vxreset (struct vx_softc *);
115 /* void vxstop (struct vx_softc *); */
116 static void vxread (struct vx_softc *);
117 static struct mbuf *vxget (struct vx_softc *, u_int);
118 static void vxmbuffill (void *);
119 static void vxmbufempty (struct vx_softc *);
120 static void vxsetfilter (struct vx_softc *);
121 static void vxgetlink (struct vx_softc *);
122 static void vxsetlink (struct vx_softc *);
123 /* int vxbusyeeprom (struct vx_softc *); */
129 struct ifnet *ifp = &sc->arpcom.ac_if;
132 callout_init(&sc->vx_timer);
134 CSR_WRITE_2(sc, VX_COMMAND, GLOBAL_RESET);
140 * Read the station address from the eeprom
143 for (i = 0; i < 3; i++) {
145 if (vxbusyeeprom(sc))
147 CSR_WRITE_2(sc, VX_W0_EEPROM_COMMAND, EEPROM_CMD_RD
148 | (EEPROM_OEM_ADDR_0 + i));
149 if (vxbusyeeprom(sc))
151 x = CSR_READ_2(sc, VX_W0_EEPROM_DATA);
152 sc->arpcom.ac_enaddr[(i << 1)] = x >> 8;
153 sc->arpcom.ac_enaddr[(i << 1) + 1] = x;
156 if_initname(ifp, "vx", sc->unit);
157 ifp->if_mtu = ETHERMTU;
158 ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
159 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
160 ifp->if_start = vxstart;
161 ifp->if_ioctl = vxioctl;
162 ifp->if_init = vxinit;
163 ifp->if_watchdog = vxwatchdog;
166 ether_ifattach(ifp, sc->arpcom.ac_enaddr);
168 sc->tx_start_thresh = 20; /* probably a good starting point. */
178 * The order in here seems important. Otherwise we may not receive
185 struct vx_softc *sc = (struct vx_softc *) xsc;
186 struct ifnet *ifp = &sc->arpcom.ac_if;
193 for (i = 0; i < 6; i++) /* Reload the ether_addr. */
194 CSR_WRITE_1(sc, VX_W2_ADDR_0 + i, sc->arpcom.ac_enaddr[i]);
196 CSR_WRITE_2(sc, VX_COMMAND, RX_RESET);
198 CSR_WRITE_2(sc, VX_COMMAND, TX_RESET);
201 GO_WINDOW(1); /* Window 1 is operating window */
202 for (i = 0; i < 31; i++)
203 CSR_READ_1(sc, VX_W1_TX_STATUS);
205 CSR_WRITE_2(sc, VX_COMMAND,SET_RD_0_MASK | S_CARD_FAILURE |
206 S_RX_COMPLETE | S_TX_COMPLETE | S_TX_AVAIL);
207 CSR_WRITE_2(sc, VX_COMMAND,SET_INTR_MASK | S_CARD_FAILURE |
208 S_RX_COMPLETE | S_TX_COMPLETE | S_TX_AVAIL);
211 * Attempt to get rid of any stray interrupts that occured during
212 * configuration. On the i386 this isn't possible because one may
213 * already be queued. However, a single stray interrupt is
216 CSR_WRITE_2(sc, VX_COMMAND, ACK_INTR | 0xff);
221 CSR_WRITE_2(sc, VX_COMMAND, RX_ENABLE);
222 CSR_WRITE_2(sc, VX_COMMAND, TX_ENABLE);
224 vxmbuffill((caddr_t) sc);
226 /* Interface is now `running', with no output active. */
227 ifp->if_flags |= IFF_RUNNING;
228 ifp->if_flags &= ~IFF_OACTIVE;
230 /* Attempt to start output, if any. */
238 struct ifnet *ifp = &sc->arpcom.ac_if;
240 GO_WINDOW(1); /* Window 1 is operating window */
241 CSR_WRITE_2(sc, VX_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL | FIL_BRDCST |
243 ((ifp->if_flags & IFF_PROMISC) ? FIL_PROMISC : 0 ));
253 sc->vx_connectors = CSR_READ_2(sc, VX_W3_RESET_OPT) & 0x7f;
254 for (n = 0, k = 0; k < VX_CONNECTORS; k++) {
255 if (sc->vx_connectors & conn_tab[k].bit) {
259 printf("%s", conn_tab[k].name);
263 if (sc->vx_connectors == 0) {
264 printf("no connectors!");
268 sc->vx_connector = (CSR_READ_4(sc, VX_W3_INTERNAL_CFG)
269 & INTERNAL_CONNECTOR_MASK)
270 >> INTERNAL_CONNECTOR_BITS;
271 if (sc->vx_connector & 0x10) {
272 sc->vx_connector &= 0x0f;
273 printf("[*%s*]", conn_tab[(int)sc->vx_connector].name);
274 printf(": disable 'auto select' with DOS util!");
276 printf("[*%s*]", conn_tab[(int)sc->vx_connector].name);
284 struct ifnet *ifp = &sc->arpcom.ac_if;
286 char *reason, *warning;
287 static short prev_flags;
288 static char prev_conn = -1;
290 if (prev_conn == -1) {
291 prev_conn = sc->vx_connector;
297 * Now behavior was slightly changed:
299 * if any of flags link[0-2] is used and its connector is
300 * physically present the following connectors are used:
302 * link0 - AUI * highest precedence
304 * link2 - UTP * lowest precedence
306 * If none of them is specified then
307 * connector specified in the EEPROM is used
308 * (if present on card or UTP if not).
311 i = sc->vx_connector; /* default in EEPROM */
315 if (ifp->if_flags & IFF_LINK0) {
316 if (sc->vx_connectors & conn_tab[CONNECTOR_AUI].bit) {
320 warning = "aui not present! (link0)";
322 } else if (ifp->if_flags & IFF_LINK1) {
323 if (sc->vx_connectors & conn_tab[CONNECTOR_BNC].bit) {
327 warning = "bnc not present! (link1)";
329 } else if (ifp->if_flags & IFF_LINK2) {
330 if (sc->vx_connectors & conn_tab[CONNECTOR_UTP].bit) {
334 warning = "utp not present! (link2)";
336 } else if ((sc->vx_connectors & conn_tab[(int)sc->vx_connector].bit) == 0) {
337 warning = "strange connector type in EEPROM.";
342 /* Avoid unnecessary message. */
343 k = (prev_flags ^ ifp->if_flags) & (IFF_LINK0 | IFF_LINK1 | IFF_LINK2);
344 if ((k != 0) || (prev_conn != i)) {
346 printf("vx%d: warning: %s\n", sc->unit, warning);
348 printf("vx%d: selected %s. (%s)\n",
349 sc->unit, conn_tab[i].name, reason);
352 /* Set the selected connector. */
354 j = CSR_READ_4(sc, VX_W3_INTERNAL_CFG) & ~INTERNAL_CONNECTOR_MASK;
355 CSR_WRITE_4(sc, VX_W3_INTERNAL_CFG, j | (i <<INTERNAL_CONNECTOR_BITS));
357 /* First, disable all. */
358 CSR_WRITE_2(sc,VX_COMMAND, STOP_TRANSCEIVER);
361 CSR_WRITE_2(sc, VX_W4_MEDIA_TYPE, 0);
363 /* Second, enable the selected one. */
367 CSR_WRITE_2(sc, VX_W4_MEDIA_TYPE, ENABLE_UTP);
370 CSR_WRITE_2(sc, VX_COMMAND, START_TRANSCEIVER);
376 CSR_WRITE_2(sc, VX_W4_MEDIA_TYPE, LINKBEAT_ENABLE);
378 default: /* AUI and MII fall here */
383 prev_flags = ifp->if_flags;
391 struct vx_softc *sc = ifp->if_softc;
395 /* Don't transmit if interface is busy or not running */
396 if ((sc->arpcom.ac_if.if_flags & (IFF_RUNNING|IFF_OACTIVE)) != IFF_RUNNING)
400 /* Sneak a peek at the next packet */
401 m0 = ifp->if_snd.ifq_head;
405 /* We need to use m->m_pkthdr.len, so require the header */
406 if ((m0->m_flags & M_PKTHDR) == 0)
407 panic("vxstart: no header mbuf");
408 len = m0->m_pkthdr.len;
413 * The 3c509 automatically pads short packets to minimum ethernet length,
414 * but we drop packets that are too large. Perhaps we should truncate
417 if (len + pad > ETHER_MAX_LEN) {
418 /* packet is obviously too large: toss it */
420 IF_DEQUEUE(&ifp->if_snd, m0);
425 if (CSR_READ_2(sc, VX_W1_FREE_TX) < len + pad + 4) {
426 CSR_WRITE_2(sc, VX_COMMAND, SET_TX_AVAIL_THRESH | ((len + pad + 4) >> 2));
427 /* not enough room in FIFO */
428 if (CSR_READ_2(sc, VX_W1_FREE_TX) < len + pad + 4) { /* make sure */
429 ifp->if_flags |= IFF_OACTIVE;
434 CSR_WRITE_2(sc, VX_COMMAND, SET_TX_AVAIL_THRESH | (8188 >> 2));
435 IF_DEQUEUE(&ifp->if_snd, m0);
436 if (m0 == NULL) { /* not really needed */
441 CSR_WRITE_2(sc, VX_COMMAND, SET_TX_START_THRESH |
442 ((len / 4 + sc->tx_start_thresh) >> 2));
444 if (sc->arpcom.ac_if.if_bpf) {
445 bpf_mtap(&sc->arpcom.ac_if, m0);
449 * Do the output at splhigh() so that an interrupt from another device
450 * won't cause a FIFO underrun.
454 CSR_WRITE_4(sc, VX_W1_TX_PIO_WR_1, len | TX_INDICATE);
458 bus_space_write_multi_4(sc->vx_btag, sc->vx_bhandle,
460 (u_int32_t *)mtod(m0, caddr_t), m0->m_len / 4);
462 bus_space_write_multi_1(sc->vx_btag, sc->vx_bhandle,
464 mtod(m0, caddr_t) + (m0->m_len & ~3), m0->m_len & 3);
468 CSR_WRITE_1(sc, VX_W1_TX_PIO_WR_1, 0); /* Padding */
476 if ((CSR_READ_2(sc, VX_W1_RX_STATUS) & ERR_INCOMPLETE) == 0) {
477 /* We received a complete packet. */
479 if ((CSR_READ_2(sc, VX_STATUS) & S_INTR_LATCH) == 0) {
481 * No interrupt, read the packet and continue
482 * Is this supposed to happen? Is my motherboard
487 /* Got an interrupt, return so that it gets serviced. */
490 /* Check if we are stuck and reset [see XXX comment] */
492 if (ifp->if_flags & IFF_DEBUG)
493 printf("%s: adapter reset\n", ifp->if_xname);
502 * XXX: The 3c509 card can get in a mode where both the fifo status bit
503 * FIFOS_RX_OVERRUN and the status bit ERR_INCOMPLETE are set
504 * We detect this situation and we reset the adapter.
505 * It happens at times when there is a lot of broadcast traffic
506 * on the cable (once in a blue moon).
515 * Check the FIFO status and act accordingly
518 fifost = CSR_READ_2(sc, VX_W4_FIFO_DIAG);
521 if (fifost & FIFOS_RX_UNDERRUN) {
522 if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
523 printf("vx%d: RX underrun\n", sc->unit);
528 if (fifost & FIFOS_RX_STATUS_OVERRUN) {
529 if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
530 printf("vx%d: RX Status overrun\n", sc->unit);
534 if (fifost & FIFOS_RX_OVERRUN) {
535 if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
536 printf("vx%d: RX overrun\n", sc->unit);
540 if (fifost & FIFOS_TX_OVERRUN) {
541 if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
542 printf("vx%d: TX overrun\n", sc->unit);
557 * We need to read+write TX_STATUS until we get a 0 status
558 * in order to turn off the interrupt flag.
560 while ((i = CSR_READ_1(sc, VX_W1_TX_STATUS)) & TXS_COMPLETE) {
561 CSR_WRITE_1(sc, VX_W1_TX_STATUS, 0x0);
563 if (i & TXS_JABBER) {
564 ++sc->arpcom.ac_if.if_oerrors;
565 if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
566 printf("vx%d: jabber (%x)\n", sc->unit, i);
568 } else if (i & TXS_UNDERRUN) {
569 ++sc->arpcom.ac_if.if_oerrors;
570 if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
571 printf("vx%d: fifo underrun (%x) @%d\n",
572 sc->unit, i, sc->tx_start_thresh);
573 if (sc->tx_succ_ok < 100)
574 sc->tx_start_thresh = min(ETHER_MAX_LEN, sc->tx_start_thresh + 20);
577 } else if (i & TXS_MAX_COLLISION) {
578 ++sc->arpcom.ac_if.if_collisions;
579 CSR_WRITE_2(sc, VX_COMMAND, TX_ENABLE);
580 sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
582 sc->tx_succ_ok = (sc->tx_succ_ok+1) & 127;
591 struct vx_softc *sc = voidsc;
592 struct ifnet *ifp = &sc->arpcom.ac_if;
595 CSR_WRITE_2(sc, VX_COMMAND, C_INTR_LATCH);
597 status = CSR_READ_2(sc, VX_STATUS);
599 if ((status & (S_TX_COMPLETE | S_TX_AVAIL |
600 S_RX_COMPLETE | S_CARD_FAILURE)) == 0)
604 * Acknowledge any interrupts. It's important that we do this
605 * first, since there would otherwise be a race condition.
606 * Due to the i386 interrupt queueing, we may get spurious
607 * interrupts occasionally.
609 CSR_WRITE_2(sc, VX_COMMAND, ACK_INTR | status);
611 if (status & S_RX_COMPLETE)
613 if (status & S_TX_AVAIL) {
615 sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
616 vxstart(&sc->arpcom.ac_if);
618 if (status & S_CARD_FAILURE) {
619 printf("vx%d: adapter failure (%x)\n", sc->unit, status);
624 if (status & S_TX_COMPLETE) {
631 /* no more interrupts */
639 struct ifnet *ifp = &sc->arpcom.ac_if;
641 struct ether_header *eh;
644 len = CSR_READ_2(sc, VX_W1_RX_STATUS);
648 if (ifp->if_flags & IFF_DEBUG) {
649 int err = len & ERR_MASK;
652 if (len & ERR_INCOMPLETE)
653 s = "incomplete packet";
654 else if (err == ERR_OVERRUN)
655 s = "packet overrun";
656 else if (err == ERR_RUNT)
658 else if (err == ERR_ALIGNMENT)
660 else if (err == ERR_CRC)
662 else if (err == ERR_OVERSIZE)
663 s = "oversized packet";
664 else if (err == ERR_DRIBBLE)
668 printf("vx%d: %s\n", sc->unit, s);
671 if (len & ERR_INCOMPLETE)
679 len &= RX_BYTES_MASK; /* Lower 11 bits = RX bytes. */
681 /* Pull packet off interface. */
690 /* We assume the header fit entirely in one mbuf. */
691 eh = mtod(m, struct ether_header *);
694 * XXX: Some cards seem to be in promiscous mode all the time.
695 * we need to make sure we only get our own stuff always.
699 if ((eh->ether_dhost[0] & 1) == 0 /* !mcast and !bcast */
700 && bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN) != 0) {
705 (*ifp->if_input)(ifp, m);
708 * In periods of high traffic we can actually receive enough
709 * packets so that the fifo overrun bit will be set at this point,
710 * even though we just read a packet. In this case we
711 * are not going to receive any more interrupts. We check for
712 * this condition and read again until the fifo is not full.
713 * We could simplify this test by not using vxstatus(), but
714 * rechecking the RX_STATUS register directly. This test could
715 * result in unnecessary looping in cases where there is a new
716 * packet but the fifo is not full, but it will not fix the
719 * Even with this improvement, we still get packet overrun errors
720 * which are hurting performance. Maybe when I get some more time
721 * I'll modify vxread() so that it can handle RX_EARLY interrupts.
724 len = CSR_READ_2(sc, VX_W1_RX_STATUS);
725 /* Check if we are stuck and reset [see XXX comment] */
726 if (len & ERR_INCOMPLETE) {
727 if (ifp->if_flags & IFF_DEBUG)
728 printf("vx%d: adapter reset\n", sc->unit);
738 CSR_WRITE_2(sc, VX_COMMAND, RX_DISCARD_TOP_PACK);
746 struct ifnet *ifp = &sc->arpcom.ac_if;
747 struct mbuf *top, **mp, *m;
751 m = sc->mb[sc->next_mb];
752 sc->mb[sc->next_mb] = 0;
754 MGETHDR(m, MB_DONTWAIT, MT_DATA);
758 /* If the queue is no longer full, refill. */
759 if (sc->last_mb == sc->next_mb && sc->buffill_pending == 0) {
760 callout_reset(&sc->vx_timer, 1, vxmbuffill, sc);
761 sc->buffill_pending = 1;
763 /* Convert one of our saved mbuf's. */
764 sc->next_mb = (sc->next_mb + 1) % MAX_MBS;
765 m->m_data = m->m_pktdat;
766 m->m_flags = M_PKTHDR;
767 bzero(&m->m_pkthdr, sizeof(m->m_pkthdr));
769 m->m_pkthdr.rcvif = ifp;
770 m->m_pkthdr.len = totlen;
776 * We read the packet at splhigh() so that an interrupt from another
777 * device doesn't cause the card's buffer to overflow while we're
778 * reading it. We may still lose packets at other times.
783 * Since we don't set allowLargePackets bit in MacControl register,
784 * we can assume that totlen <= 1500bytes.
785 * The while loop will be performed iff we have a packet with
786 * MLEN < m_len < MINCLSIZE.
790 m = sc->mb[sc->next_mb];
791 sc->mb[sc->next_mb] = 0;
793 MGET(m, MB_DONTWAIT, MT_DATA);
800 sc->next_mb = (sc->next_mb + 1) % MAX_MBS;
804 if (totlen >= MINCLSIZE) {
805 MCLGET(m, MB_DONTWAIT);
806 if (m->m_flags & M_EXT)
809 len = min(totlen, len);
811 bus_space_read_multi_4(sc->vx_btag, sc->vx_bhandle,
812 VX_W1_RX_PIO_RD_1, mtod(m, u_int32_t *), len / 4);
814 bus_space_read_multi_1(sc->vx_btag, sc->vx_bhandle,
815 VX_W1_RX_PIO_RD_1, mtod(m, u_int8_t *) + (len & ~3),
824 CSR_WRITE_2(sc, VX_COMMAND, RX_DISCARD_TOP_PACK);
833 vxioctl(ifp, cmd, data, cr)
839 struct vx_softc *sc = ifp->if_softc;
840 struct ifreq *ifr = (struct ifreq *) data;
848 ether_ioctl(ifp, cmd, data);
852 if ((ifp->if_flags & IFF_UP) == 0 &&
853 (ifp->if_flags & IFF_RUNNING) != 0) {
855 * If interface is marked up and it is stopped, then
859 ifp->if_flags &= ~IFF_RUNNING;
860 } else if ((ifp->if_flags & IFF_UP) != 0 &&
861 (ifp->if_flags & IFF_RUNNING) == 0) {
863 * If interface is marked up and it is stopped, then
869 * deal with flags changes:
870 * IFF_MULTICAST, IFF_PROMISC,
871 * IFF_LINK0, IFF_LINK1,
880 * Set the interface MTU.
882 if (ifr->ifr_mtu > ETHERMTU) {
885 ifp->if_mtu = ifr->ifr_mtu;
892 * Multicast list has changed; set the hardware filter
925 struct vx_softc *sc = ifp->if_softc;
927 if (ifp->if_flags & IFF_DEBUG)
928 printf("%s: device timeout\n", ifp->if_xname);
929 ifp->if_flags &= ~IFF_OACTIVE;
938 struct ifnet *ifp = &sc->arpcom.ac_if;
942 CSR_WRITE_2(sc, VX_COMMAND, RX_DISABLE);
943 CSR_WRITE_2(sc, VX_COMMAND, RX_DISCARD_TOP_PACK);
945 CSR_WRITE_2(sc, VX_COMMAND, TX_DISABLE);
946 CSR_WRITE_2(sc, VX_COMMAND, STOP_TRANSCEIVER);
948 CSR_WRITE_2(sc, VX_COMMAND, RX_RESET);
950 CSR_WRITE_2(sc, VX_COMMAND, TX_RESET);
952 CSR_WRITE_2(sc, VX_COMMAND, C_INTR_LATCH);
953 CSR_WRITE_2(sc, VX_COMMAND, SET_RD_0_MASK);
954 CSR_WRITE_2(sc, VX_COMMAND, SET_INTR_MASK);
955 CSR_WRITE_2(sc, VX_COMMAND, SET_RX_FILTER);
967 j = CSR_READ_2(sc, VX_W0_EEPROM_COMMAND);
974 printf("vx%d: eeprom failed to come ready\n", sc->unit);
984 struct vx_softc *sc = (struct vx_softc *) sp;
990 if (sc->mb[i] == NULL)
991 MGET(sc->mb[i], MB_DONTWAIT, MT_DATA);
992 if (sc->mb[i] == NULL)
994 i = (i + 1) % MAX_MBS;
995 } while (i != sc->next_mb);
997 /* If the queue was not filled, try again. */
998 if (sc->last_mb != sc->next_mb) {
999 callout_reset(&sc->vx_timer, 1, vxmbuffill, sc);
1000 sc->buffill_pending = 1;
1002 sc->buffill_pending = 0;
1009 struct vx_softc *sc;
1014 for (i = 0; i < MAX_MBS; i++) {
1020 sc->last_mb = sc->next_mb = 0;
1021 if (sc->buffill_pending != 0)
1022 callout_stop(&sc->vx_timer);