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.23 2005/07/04 07:32:37 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>
60 #include <sys/systm.h>
61 #include <sys/sockio.h>
62 #include <sys/malloc.h>
64 #include <sys/socket.h>
65 #include <sys/linker_set.h>
66 #include <sys/module.h>
67 #include <sys/thread2.h>
70 #include <net/ifq_var.h>
72 #include <net/ethernet.h>
73 #include <net/if_arp.h>
75 #include <machine/bus_pio.h>
76 #include <machine/bus.h>
82 DECLARE_DUMMY_MODULE(if_vx);
84 static struct connector_entry {
87 } conn_tab[VX_CONNECTORS] = {
88 #define CONNECTOR_UTP 0
90 #define CONNECTOR_AUI 1
94 #define CONNECTOR_BNC 3
96 #define CONNECTOR_TX 4
98 #define CONNECTOR_FX 5
100 #define CONNECTOR_MII 6
105 /* int vxattach (struct vx_softc *); */
106 static void vxtxstat (struct vx_softc *);
107 static int vxstatus (struct vx_softc *);
108 static void vxinit (void *);
109 static int vxioctl (struct ifnet *, u_long, caddr_t, struct ucred *);
110 static void vxstart (struct ifnet *ifp);
111 static void vxwatchdog (struct ifnet *);
112 static void vxreset (struct vx_softc *);
113 /* void vxstop (struct vx_softc *); */
114 static void vxread (struct vx_softc *);
115 static struct mbuf *vxget (struct vx_softc *, u_int);
116 static void vxmbuffill (void *);
117 static void vxmbufempty (struct vx_softc *);
118 static void vxsetfilter (struct vx_softc *);
119 static void vxgetlink (struct vx_softc *);
120 static void vxsetlink (struct vx_softc *);
121 /* int vxbusyeeprom (struct vx_softc *); */
124 vxattach(device_t dev)
128 uint8_t eaddr[ETHER_ADDR_LEN];
131 sc = device_get_softc(dev);
133 callout_init(&sc->vx_timer);
135 CSR_WRITE_2(sc, VX_COMMAND, GLOBAL_RESET);
138 ifp = &sc->arpcom.ac_if;
139 if_initname(ifp, device_get_name(dev), device_get_unit(dev));
144 * Read the station address from the eeprom
147 for (i = 0; i < 3; i++) {
149 if (vxbusyeeprom(sc))
151 CSR_WRITE_2(sc, VX_W0_EEPROM_COMMAND, EEPROM_CMD_RD
152 | (EEPROM_OEM_ADDR_0 + i));
153 if (vxbusyeeprom(sc))
155 x = CSR_READ_2(sc, VX_W0_EEPROM_DATA);
156 eaddr[(i << 1)] = x >> 8;
157 eaddr[(i << 1) + 1] = x;
160 ifp->if_mtu = ETHERMTU;
161 ifq_set_maxlen(&ifp->if_snd, IFQ_MAXLEN);
162 ifq_set_ready(&ifp->if_snd);
163 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
164 ifp->if_start = vxstart;
165 ifp->if_ioctl = vxioctl;
166 ifp->if_init = vxinit;
167 ifp->if_watchdog = vxwatchdog;
170 ether_ifattach(ifp, eaddr);
172 sc->tx_start_thresh = 20; /* probably a good starting point. */
182 * The order in here seems important. Otherwise we may not receive
189 struct vx_softc *sc = (struct vx_softc *) xsc;
190 struct ifnet *ifp = &sc->arpcom.ac_if;
197 for (i = 0; i < 6; i++) /* Reload the ether_addr. */
198 CSR_WRITE_1(sc, VX_W2_ADDR_0 + i, sc->arpcom.ac_enaddr[i]);
200 CSR_WRITE_2(sc, VX_COMMAND, RX_RESET);
202 CSR_WRITE_2(sc, VX_COMMAND, TX_RESET);
205 GO_WINDOW(1); /* Window 1 is operating window */
206 for (i = 0; i < 31; i++)
207 CSR_READ_1(sc, VX_W1_TX_STATUS);
209 CSR_WRITE_2(sc, VX_COMMAND,SET_RD_0_MASK | S_CARD_FAILURE |
210 S_RX_COMPLETE | S_TX_COMPLETE | S_TX_AVAIL);
211 CSR_WRITE_2(sc, VX_COMMAND,SET_INTR_MASK | S_CARD_FAILURE |
212 S_RX_COMPLETE | S_TX_COMPLETE | S_TX_AVAIL);
215 * Attempt to get rid of any stray interrupts that occured during
216 * configuration. On the i386 this isn't possible because one may
217 * already be queued. However, a single stray interrupt is
220 CSR_WRITE_2(sc, VX_COMMAND, ACK_INTR | 0xff);
225 CSR_WRITE_2(sc, VX_COMMAND, RX_ENABLE);
226 CSR_WRITE_2(sc, VX_COMMAND, TX_ENABLE);
228 vxmbuffill((caddr_t) sc);
230 /* Interface is now `running', with no output active. */
231 ifp->if_flags |= IFF_RUNNING;
232 ifp->if_flags &= ~IFF_OACTIVE;
234 /* Attempt to start output, if any. */
242 struct ifnet *ifp = &sc->arpcom.ac_if;
244 GO_WINDOW(1); /* Window 1 is operating window */
245 CSR_WRITE_2(sc, VX_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL | FIL_BRDCST |
247 ((ifp->if_flags & IFF_PROMISC) ? FIL_PROMISC : 0 ));
257 sc->vx_connectors = CSR_READ_2(sc, VX_W3_RESET_OPT) & 0x7f;
258 for (n = 0, k = 0; k < VX_CONNECTORS; k++) {
259 if (sc->vx_connectors & conn_tab[k].bit) {
261 if_printf(&sc->arpcom.ac_if, "%s", conn_tab[k].name);
263 printf("/%s", conn_tab[k].name);
268 if_printf(&sc->arpcom.ac_if, "no connectors!\n");
272 sc->vx_connector = (CSR_READ_4(sc, VX_W3_INTERNAL_CFG)
273 & INTERNAL_CONNECTOR_MASK)
274 >> INTERNAL_CONNECTOR_BITS;
275 if (sc->vx_connector & 0x10) {
276 sc->vx_connector &= 0x0f;
277 printf("[*%s*]", conn_tab[(int)sc->vx_connector].name);
278 printf(": disable 'auto select' with DOS util!\n");
280 printf("[*%s*]\n", conn_tab[(int)sc->vx_connector].name);
288 struct ifnet *ifp = &sc->arpcom.ac_if;
290 const char *reason, *warning;
291 static short prev_flags;
292 static char prev_conn = -1;
294 if (prev_conn == -1) {
295 prev_conn = sc->vx_connector;
301 * Now behavior was slightly changed:
303 * if any of flags link[0-2] is used and its connector is
304 * physically present the following connectors are used:
306 * link0 - AUI * highest precedence
308 * link2 - UTP * lowest precedence
310 * If none of them is specified then
311 * connector specified in the EEPROM is used
312 * (if present on card or UTP if not).
315 i = sc->vx_connector; /* default in EEPROM */
319 if (ifp->if_flags & IFF_LINK0) {
320 if (sc->vx_connectors & conn_tab[CONNECTOR_AUI].bit) {
324 warning = "aui not present! (link0)";
326 } else if (ifp->if_flags & IFF_LINK1) {
327 if (sc->vx_connectors & conn_tab[CONNECTOR_BNC].bit) {
331 warning = "bnc not present! (link1)";
333 } else if (ifp->if_flags & IFF_LINK2) {
334 if (sc->vx_connectors & conn_tab[CONNECTOR_UTP].bit) {
338 warning = "utp not present! (link2)";
340 } else if ((sc->vx_connectors & conn_tab[(int)sc->vx_connector].bit) == 0) {
341 warning = "strange connector type in EEPROM.";
346 /* Avoid unnecessary message. */
347 k = (prev_flags ^ ifp->if_flags) & (IFF_LINK0 | IFF_LINK1 | IFF_LINK2);
348 if ((k != 0) || (prev_conn != i)) {
349 if (warning != NULL) {
350 if_printf(ifp, "warning: %s\n", warning);
352 if_printf(ifp, "selected %s. (%s)\n", conn_tab[i].name, reason);
355 /* Set the selected connector. */
357 j = CSR_READ_4(sc, VX_W3_INTERNAL_CFG) & ~INTERNAL_CONNECTOR_MASK;
358 CSR_WRITE_4(sc, VX_W3_INTERNAL_CFG, j | (i <<INTERNAL_CONNECTOR_BITS));
360 /* First, disable all. */
361 CSR_WRITE_2(sc,VX_COMMAND, STOP_TRANSCEIVER);
364 CSR_WRITE_2(sc, VX_W4_MEDIA_TYPE, 0);
366 /* Second, enable the selected one. */
370 CSR_WRITE_2(sc, VX_W4_MEDIA_TYPE, ENABLE_UTP);
373 CSR_WRITE_2(sc, VX_COMMAND, START_TRANSCEIVER);
379 CSR_WRITE_2(sc, VX_W4_MEDIA_TYPE, LINKBEAT_ENABLE);
381 default: /* AUI and MII fall here */
386 prev_flags = ifp->if_flags;
394 struct vx_softc *sc = ifp->if_softc;
398 /* Don't transmit if interface is busy or not running */
399 if ((ifp->if_flags & (IFF_RUNNING|IFF_OACTIVE)) != IFF_RUNNING)
403 /* Sneak a peek at the next packet */
404 m0 = ifq_poll(&ifp->if_snd);
407 /* We need to use m->m_pkthdr.len, so require the header */
409 len = m0->m_pkthdr.len;
414 * The 3c509 automatically pads short packets to minimum ethernet length,
415 * but we drop packets that are too large. Perhaps we should truncate
418 if (len + pad > ETHER_MAX_LEN) {
419 /* packet is obviously too large: toss it */
421 m0 = ifq_dequeue(&ifp->if_snd);
426 if (CSR_READ_2(sc, VX_W1_FREE_TX) < len + pad + 4) {
427 CSR_WRITE_2(sc, VX_COMMAND, SET_TX_AVAIL_THRESH | ((len + pad + 4) >> 2));
428 /* not enough room in FIFO */
429 if (CSR_READ_2(sc, VX_W1_FREE_TX) < len + pad + 4) { /* make sure */
430 ifp->if_flags |= IFF_OACTIVE;
435 CSR_WRITE_2(sc, VX_COMMAND, SET_TX_AVAIL_THRESH | (8188 >> 2));
436 m0 = ifq_dequeue(&ifp->if_snd);
439 CSR_WRITE_2(sc, VX_COMMAND, SET_TX_START_THRESH |
440 ((len / 4 + sc->tx_start_thresh) >> 2));
445 * Do the output in a critical section so that an interrupt from
446 * another device won't cause a FIFO underrun.
450 CSR_WRITE_4(sc, VX_W1_TX_PIO_WR_1, len | TX_INDICATE);
454 bus_space_write_multi_4(sc->vx_btag, sc->vx_bhandle,
456 (u_int32_t *)mtod(m0, caddr_t), m0->m_len / 4);
458 bus_space_write_multi_1(sc->vx_btag, sc->vx_bhandle,
460 mtod(m0, caddr_t) + (m0->m_len & ~3), m0->m_len & 3);
464 CSR_WRITE_1(sc, VX_W1_TX_PIO_WR_1, 0); /* Padding */
472 if ((CSR_READ_2(sc, VX_W1_RX_STATUS) & ERR_INCOMPLETE) == 0) {
473 /* We received a complete packet. */
475 if ((CSR_READ_2(sc, VX_STATUS) & S_INTR_LATCH) != 0) {
476 /* Got an interrupt, return so that it gets serviced. */
480 * No interrupt, read the packet and continue
481 * Is this supposed to happen? Is my motherboard
486 /* Check if we are stuck and reset [see XXX comment] */
488 if (ifp->if_flags & IFF_DEBUG)
489 if_printf(ifp, "adapter reset\n");
498 * XXX: The 3c509 card can get in a mode where both the fifo status bit
499 * FIFOS_RX_OVERRUN and the status bit ERR_INCOMPLETE are set
500 * We detect this situation and we reset the adapter.
501 * It happens at times when there is a lot of broadcast traffic
502 * on the cable (once in a blue moon).
509 struct ifnet *ifp = &sc->arpcom.ac_if;
512 * Check the FIFO status and act accordingly
515 fifost = CSR_READ_2(sc, VX_W4_FIFO_DIAG);
518 if (fifost & FIFOS_RX_UNDERRUN) {
519 if (ifp->if_flags & IFF_DEBUG)
520 if_printf(ifp, "RX underrun\n");
525 if (fifost & FIFOS_RX_STATUS_OVERRUN) {
526 if (ifp->if_flags & IFF_DEBUG)
527 if_printf(ifp, "RX Status overrun\n");
531 if (fifost & FIFOS_RX_OVERRUN) {
532 if (ifp->if_flags & IFF_DEBUG)
533 if_printf(ifp, "RX overrun\n");
537 if (fifost & FIFOS_TX_OVERRUN) {
538 if (ifp->if_flags & IFF_DEBUG)
539 if_printf(ifp, "TX overrun\n");
547 vxtxstat(struct vx_softc *sc)
550 struct ifnet *ifp = &sc->arpcom.ac_if;
553 * We need to read+write TX_STATUS until we get a 0 status
554 * in order to turn off the interrupt flag.
556 while ((i = CSR_READ_1(sc, VX_W1_TX_STATUS)) & TXS_COMPLETE) {
557 CSR_WRITE_1(sc, VX_W1_TX_STATUS, 0x0);
559 if (i & TXS_JABBER) {
561 if (ifp->if_flags & IFF_DEBUG)
562 if_printf(ifp, "jabber (%x)\n", i);
564 } else if (i & TXS_UNDERRUN) {
566 if (ifp->if_flags & IFF_DEBUG) {
567 if_printf(ifp, "fifo underrun (%x) @%d\n",
568 i, sc->tx_start_thresh);
570 if (sc->tx_succ_ok < 100) {
571 sc->tx_start_thresh = min(
572 ETHER_MAX_LEN, sc->tx_start_thresh + 20);
576 } else if (i & TXS_MAX_COLLISION) {
577 ++ifp->if_collisions;
578 CSR_WRITE_2(sc, VX_COMMAND, TX_ENABLE);
579 ifp->if_flags &= ~IFF_OACTIVE;
581 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 ifp->if_flags &= ~IFF_OACTIVE;
618 if (status & S_CARD_FAILURE) {
619 if_printf(ifp, "adapter failure (%x)\n", status);
624 if (status & S_TX_COMPLETE) {
630 /* no more interrupts */
637 struct ifnet *ifp = &sc->arpcom.ac_if;
639 struct ether_header *eh;
642 len = CSR_READ_2(sc, VX_W1_RX_STATUS);
646 if (ifp->if_flags & IFF_DEBUG) {
647 int err = len & ERR_MASK;
648 const char *s = NULL;
650 if (len & ERR_INCOMPLETE)
651 s = "incomplete packet";
652 else if (err == ERR_OVERRUN)
653 s = "packet overrun";
654 else if (err == ERR_RUNT)
656 else if (err == ERR_ALIGNMENT)
658 else if (err == ERR_CRC)
660 else if (err == ERR_OVERSIZE)
661 s = "oversized packet";
662 else if (err == ERR_DRIBBLE)
666 if_printf(ifp, "%s\n", s);
669 if (len & ERR_INCOMPLETE)
677 len &= RX_BYTES_MASK; /* Lower 11 bits = RX bytes. */
679 /* Pull packet off interface. */
688 /* We assume the header fit entirely in one mbuf. */
689 eh = mtod(m, struct ether_header *);
692 * XXX: Some cards seem to be in promiscous mode all the time.
693 * we need to make sure we only get our own stuff always.
697 if ((eh->ether_dhost[0] & 1) == 0 /* !mcast and !bcast */
698 && bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN) != 0) {
703 (*ifp->if_input)(ifp, m);
706 * In periods of high traffic we can actually receive enough
707 * packets so that the fifo overrun bit will be set at this point,
708 * even though we just read a packet. In this case we
709 * are not going to receive any more interrupts. We check for
710 * this condition and read again until the fifo is not full.
711 * We could simplify this test by not using vxstatus(), but
712 * rechecking the RX_STATUS register directly. This test could
713 * result in unnecessary looping in cases where there is a new
714 * packet but the fifo is not full, but it will not fix the
717 * Even with this improvement, we still get packet overrun errors
718 * which are hurting performance. Maybe when I get some more time
719 * I'll modify vxread() so that it can handle RX_EARLY interrupts.
722 len = CSR_READ_2(sc, VX_W1_RX_STATUS);
723 /* Check if we are stuck and reset [see XXX comment] */
724 if (len & ERR_INCOMPLETE) {
725 if (ifp->if_flags & IFF_DEBUG)
726 if_printf(ifp, "adapter reset\n");
736 CSR_WRITE_2(sc, VX_COMMAND, RX_DISCARD_TOP_PACK);
744 struct ifnet *ifp = &sc->arpcom.ac_if;
745 struct mbuf *top, **mp, *m;
748 m = sc->mb[sc->next_mb];
749 sc->mb[sc->next_mb] = NULL;
751 MGETHDR(m, MB_DONTWAIT, MT_DATA);
755 /* If the queue is no longer full, refill. */
756 if (sc->last_mb == sc->next_mb && sc->buffill_pending == 0) {
757 callout_reset(&sc->vx_timer, 1, vxmbuffill, sc);
758 sc->buffill_pending = 1;
760 /* Convert one of our saved mbuf's. */
761 sc->next_mb = (sc->next_mb + 1) % MAX_MBS;
762 m->m_data = m->m_pktdat;
763 m->m_flags = M_PKTHDR;
764 bzero(&m->m_pkthdr, sizeof(m->m_pkthdr));
766 m->m_pkthdr.rcvif = ifp;
767 m->m_pkthdr.len = totlen;
773 * We read the packet in a critical section so that an interrupt
774 * from another device doesn't cause the card's buffer to overflow
775 * while we're reading it. We may still lose packets at other times.
780 * Since we don't set allowLargePackets bit in MacControl register,
781 * we can assume that totlen <= 1500bytes.
782 * The while loop will be performed if we have a packet with
783 * MLEN < m_len < MINCLSIZE.
787 m = sc->mb[sc->next_mb];
788 sc->mb[sc->next_mb] = NULL;
790 MGET(m, MB_DONTWAIT, MT_DATA);
797 sc->next_mb = (sc->next_mb + 1) % MAX_MBS;
801 if (totlen >= MINCLSIZE) {
802 MCLGET(m, MB_DONTWAIT);
803 if (m->m_flags & M_EXT)
806 len = min(totlen, len);
808 bus_space_read_multi_4(sc->vx_btag, sc->vx_bhandle,
809 VX_W1_RX_PIO_RD_1, mtod(m, u_int32_t *), len / 4);
811 bus_space_read_multi_1(sc->vx_btag, sc->vx_bhandle,
812 VX_W1_RX_PIO_RD_1, mtod(m, u_int8_t *) + (len & ~3),
821 CSR_WRITE_2(sc, VX_COMMAND, RX_DISCARD_TOP_PACK);
830 vxioctl(ifp, cmd, data, cr)
836 struct vx_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) != 0) {
847 * If interface is marked up and it is stopped, then
851 ifp->if_flags &= ~IFF_RUNNING;
852 } else 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
861 * deal with flags changes:
862 * IFF_MULTICAST, IFF_PROMISC,
863 * IFF_LINK0, IFF_LINK1,
872 * Set the interface MTU.
874 if (ifr->ifr_mtu > ETHERMTU) {
877 ifp->if_mtu = ifr->ifr_mtu;
884 * Multicast list has changed; set the hardware filter
893 ether_ioctl(ifp, cmd, data);
918 struct vx_softc *sc = ifp->if_softc;
920 if (ifp->if_flags & IFF_DEBUG)
921 if_printf(ifp, "device timeout\n");
922 ifp->if_flags &= ~IFF_OACTIVE;
931 struct ifnet *ifp = &sc->arpcom.ac_if;
935 CSR_WRITE_2(sc, VX_COMMAND, RX_DISABLE);
936 CSR_WRITE_2(sc, VX_COMMAND, RX_DISCARD_TOP_PACK);
938 CSR_WRITE_2(sc, VX_COMMAND, TX_DISABLE);
939 CSR_WRITE_2(sc, VX_COMMAND, STOP_TRANSCEIVER);
941 CSR_WRITE_2(sc, VX_COMMAND, RX_RESET);
943 CSR_WRITE_2(sc, VX_COMMAND, TX_RESET);
945 CSR_WRITE_2(sc, VX_COMMAND, C_INTR_LATCH);
946 CSR_WRITE_2(sc, VX_COMMAND, SET_RD_0_MASK);
947 CSR_WRITE_2(sc, VX_COMMAND, SET_INTR_MASK);
948 CSR_WRITE_2(sc, VX_COMMAND, SET_RX_FILTER);
960 j = CSR_READ_2(sc, VX_W0_EEPROM_COMMAND);
967 if_printf(&sc->arpcom.ac_if, "eeprom failed to come ready\n");
977 struct vx_softc *sc = (struct vx_softc *) sp;
983 if (sc->mb[i] == NULL)
984 MGET(sc->mb[i], MB_DONTWAIT, MT_DATA);
985 if (sc->mb[i] == NULL)
987 i = (i + 1) % MAX_MBS;
988 } while (i != sc->next_mb);
990 /* If the queue was not filled, try again. */
991 if (sc->last_mb != sc->next_mb) {
992 callout_reset(&sc->vx_timer, 1, vxmbuffill, sc);
993 sc->buffill_pending = 1;
995 sc->buffill_pending = 0;
1002 struct vx_softc *sc;
1007 for (i = 0; i < MAX_MBS; i++) {
1013 sc->last_mb = sc->next_mb = 0;
1014 if (sc->buffill_pending != 0)
1015 callout_stop(&sc->vx_timer);