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.
35 * Created from if_ep.c driver by Fred Gray (fgray@rice.edu) to support
40 * Modified from the FreeBSD 1.1.5.1 version by:
42 * INRIA - Sophia Antipolis, France
43 * avega@sophia.inria.fr
47 * Promiscuous mode added and interrupt logic slightly changed
48 * to reduce the number of adapter failures. Transceiver select
49 * logic changed to use value from EEPROM. Autoconfiguration
53 * Chelindbank (Chelyabinsk, Russia)
54 * 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>
67 #include <net/ethernet.h>
68 #include <net/if_arp.h>
70 #include <machine/bus_pio.h>
71 #include <machine/bus.h>
76 #include <dev/vx/if_vxreg.h>
78 #define ETHER_MAX_LEN 1518
79 #define ETHER_ADDR_LEN 6
82 static struct connector_entry {
85 } conn_tab[VX_CONNECTORS] = {
86 #define CONNECTOR_UTP 0
88 #define CONNECTOR_AUI 1
92 #define CONNECTOR_BNC 3
94 #define CONNECTOR_TX 4
96 #define CONNECTOR_FX 5
98 #define CONNECTOR_MII 6
103 /* int vxattach(struct vx_softc *); */
104 static void vxtxstat(struct vx_softc *);
105 static int vxstatus(struct vx_softc *);
106 static void vxinit(void *);
107 static int vxioctl(struct ifnet *, u_long, caddr_t);
108 static void vxstart(struct ifnet *ifp);
109 static void vxwatchdog(struct ifnet *);
110 static void vxreset(struct vx_softc *);
111 /* void vxstop(struct vx_softc *); */
112 static void vxread(struct vx_softc *);
113 static struct mbuf *vxget(struct vx_softc *, u_int);
114 static void vxmbuffill(void *);
115 static void vxmbufempty(struct vx_softc *);
116 static void vxsetfilter(struct vx_softc *);
117 static void vxgetlink(struct vx_softc *);
118 static void vxsetlink(struct vx_softc *);
119 /* int vxbusyeeprom(struct vx_softc *); */
126 struct ifnet *ifp = &sc->arpcom.ac_if;
129 callout_handle_init(&sc->ch);
131 CSR_WRITE_2(sc, VX_COMMAND, GLOBAL_RESET);
137 * Read the station address from the eeprom
140 for (i = 0; i < 3; i++) {
142 if (vxbusyeeprom(sc))
144 CSR_WRITE_2(sc, VX_W0_EEPROM_COMMAND, EEPROM_CMD_RD
145 | (EEPROM_OEM_ADDR_0 + i));
146 if (vxbusyeeprom(sc))
148 x = CSR_READ_2(sc, VX_W0_EEPROM_DATA);
149 sc->arpcom.ac_enaddr[(i << 1)] = x >> 8;
150 sc->arpcom.ac_enaddr[(i << 1) + 1] = x;
153 printf(" address %6D\n", sc->arpcom.ac_enaddr, ":");
155 ifp->if_unit = 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_output = ether_output;
161 ifp->if_start = vxstart;
162 ifp->if_ioctl = vxioctl;
163 ifp->if_init = vxinit;
164 ifp->if_watchdog = vxwatchdog;
167 ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
169 sc->tx_start_thresh = 20; /* probably a good starting point. */
179 * The order in here seems important. Otherwise we may not receive
186 struct vx_softc *sc = (struct vx_softc *) xsc;
187 struct ifnet *ifp = &sc->arpcom.ac_if;
194 for (i = 0; i < 6; i++) /* Reload the ether_addr. */
195 CSR_WRITE_1(sc, VX_W2_ADDR_0 + i, sc->arpcom.ac_enaddr[i]);
197 CSR_WRITE_2(sc, VX_COMMAND, RX_RESET);
199 CSR_WRITE_2(sc, VX_COMMAND, TX_RESET);
202 GO_WINDOW(1); /* Window 1 is operating window */
203 for (i = 0; i < 31; i++)
204 CSR_READ_1(sc, VX_W1_TX_STATUS);
206 CSR_WRITE_2(sc, VX_COMMAND,SET_RD_0_MASK | S_CARD_FAILURE |
207 S_RX_COMPLETE | S_TX_COMPLETE | S_TX_AVAIL);
208 CSR_WRITE_2(sc, VX_COMMAND,SET_INTR_MASK | S_CARD_FAILURE |
209 S_RX_COMPLETE | S_TX_COMPLETE | S_TX_AVAIL);
212 * Attempt to get rid of any stray interrupts that occured during
213 * configuration. On the i386 this isn't possible because one may
214 * already be queued. However, a single stray interrupt is
217 CSR_WRITE_2(sc, VX_COMMAND, ACK_INTR | 0xff);
222 CSR_WRITE_2(sc, VX_COMMAND, RX_ENABLE);
223 CSR_WRITE_2(sc, VX_COMMAND, TX_ENABLE);
225 vxmbuffill((caddr_t) sc);
227 /* Interface is now `running', with no output active. */
228 ifp->if_flags |= IFF_RUNNING;
229 ifp->if_flags &= ~IFF_OACTIVE;
231 /* Attempt to start output, if any. */
239 register struct ifnet *ifp = &sc->arpcom.ac_if;
241 GO_WINDOW(1); /* Window 1 is operating window */
242 CSR_WRITE_2(sc, VX_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL | FIL_BRDCST |
244 ((ifp->if_flags & IFF_PROMISC) ? FIL_PROMISC : 0 ));
254 sc->vx_connectors = CSR_READ_2(sc, VX_W3_RESET_OPT) & 0x7f;
255 for (n = 0, k = 0; k < VX_CONNECTORS; k++) {
256 if (sc->vx_connectors & conn_tab[k].bit) {
260 printf("%s", conn_tab[k].name);
264 if (sc->vx_connectors == 0) {
265 printf("no connectors!");
269 sc->vx_connector = (CSR_READ_4(sc, VX_W3_INTERNAL_CFG)
270 & INTERNAL_CONNECTOR_MASK)
271 >> INTERNAL_CONNECTOR_BITS;
272 if (sc->vx_connector & 0x10) {
273 sc->vx_connector &= 0x0f;
274 printf("[*%s*]", conn_tab[(int)sc->vx_connector].name);
275 printf(": disable 'auto select' with DOS util!");
277 printf("[*%s*]", conn_tab[(int)sc->vx_connector].name);
285 register struct ifnet *ifp = &sc->arpcom.ac_if;
287 char *reason, *warning;
288 static int prev_flags;
289 static char prev_conn = -1;
291 if (prev_conn == -1) {
292 prev_conn = sc->vx_connector;
298 * Now behavior was slightly changed:
300 * if any of flags link[0-2] is used and its connector is
301 * physically present the following connectors are used:
303 * link0 - AUI * highest precedence
305 * link2 - UTP * lowest precedence
307 * If none of them is specified then
308 * connector specified in the EEPROM is used
309 * (if present on card or UTP if not).
312 i = sc->vx_connector; /* default in EEPROM */
316 if (ifp->if_flags & IFF_LINK0) {
317 if (sc->vx_connectors & conn_tab[CONNECTOR_AUI].bit) {
321 warning = "aui not present! (link0)";
323 } else if (ifp->if_flags & IFF_LINK1) {
324 if (sc->vx_connectors & conn_tab[CONNECTOR_BNC].bit) {
328 warning = "bnc not present! (link1)";
330 } else if (ifp->if_flags & IFF_LINK2) {
331 if (sc->vx_connectors & conn_tab[CONNECTOR_UTP].bit) {
335 warning = "utp not present! (link2)";
337 } else if ((sc->vx_connectors & conn_tab[(int)sc->vx_connector].bit) == 0) {
338 warning = "strange connector type in EEPROM.";
343 /* Avoid unnecessary message. */
344 k = (prev_flags ^ ifp->if_flags) & (IFF_LINK0 | IFF_LINK1 | IFF_LINK2);
345 if ((k != 0) || (prev_conn != i)) {
347 printf("vx%d: warning: %s\n", sc->unit, warning);
349 printf("vx%d: selected %s. (%s)\n",
350 sc->unit, conn_tab[i].name, reason);
353 /* Set the selected connector. */
355 j = CSR_READ_4(sc, VX_W3_INTERNAL_CFG) & ~INTERNAL_CONNECTOR_MASK;
356 CSR_WRITE_4(sc, VX_W3_INTERNAL_CFG, j | (i <<INTERNAL_CONNECTOR_BITS));
358 /* First, disable all. */
359 CSR_WRITE_2(sc, VX_COMMAND, STOP_TRANSCEIVER);
362 CSR_WRITE_2(sc, VX_W4_MEDIA_TYPE, 0);
364 /* Second, enable the selected one. */
368 CSR_WRITE_2(sc, VX_W4_MEDIA_TYPE, ENABLE_UTP);
371 CSR_WRITE_2(sc, VX_COMMAND, START_TRANSCEIVER);
377 CSR_WRITE_2(sc, VX_W4_MEDIA_TYPE, LINKBEAT_ENABLE);
379 default: /* AUI and MII fall here */
384 prev_flags = ifp->if_flags;
392 register struct vx_softc *sc = ifp->if_softc;
393 register struct mbuf *m;
396 /* Don't transmit if interface is busy or not running */
397 if ((sc->arpcom.ac_if.if_flags & (IFF_RUNNING|IFF_OACTIVE)) != IFF_RUNNING)
401 /* Sneak a peek at the next packet */
402 m = ifp->if_snd.ifq_head;
406 /* We need to use m->m_pkthdr.len, so require the header */
407 if ((m->m_flags & M_PKTHDR) == 0)
408 panic("vxstart: no header mbuf");
409 len = m->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 IF_DEQUEUE(&ifp->if_snd, m);
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 IF_DEQUEUE(&ifp->if_snd, m);
437 if (m == 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, m);
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,
459 VX_W1_TX_PIO_WR_1, (u_int32_t *)mtod(m, caddr_t), m->m_len / 4);
461 bus_space_write_multi_1(sc->vx_btag, sc->vx_bhandle,
463 mtod(m, caddr_t) + (m->m_len & ~3) , m->m_len & 3);
467 CSR_WRITE_1(sc, VX_W1_TX_PIO_WR_1, 0); /* Padding */
475 if ((CSR_READ_2(sc, VX_W1_RX_STATUS) & ERR_INCOMPLETE) == 0) {
476 /* We received a complete packet. */
478 if ((CSR_READ_2(sc, VX_STATUS) & S_INTR_LATCH) == 0) {
480 * No interrupt, read the packet and continue
481 * Is this supposed to happen? Is my motherboard
486 /* Got an interrupt, return so that it gets serviced. */
489 /* Check if we are stuck and reset [see XXX comment] */
491 if (ifp->if_flags & IFF_DEBUG)
492 printf("vx%d: adapter reset\n", ifp->if_unit);
501 * XXX: The 3c509 card can get in a mode where both the fifo status bit
502 * FIFOS_RX_OVERRUN and the status bit ERR_INCOMPLETE are set
503 * We detect this situation and we reset the adapter.
504 * It happens at times when there is a lot of broadcast traffic
505 * on the cable (once in a blue moon).
514 * Check the FIFO status and act accordingly
517 fifost = CSR_READ_2(sc, VX_W4_FIFO_DIAG);
520 if (fifost & FIFOS_RX_UNDERRUN) {
521 if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
522 printf("vx%d: RX underrun\n", sc->unit);
527 if (fifost & FIFOS_RX_STATUS_OVERRUN) {
528 if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
529 printf("vx%d: RX Status overrun\n", sc->unit);
533 if (fifost & FIFOS_RX_OVERRUN) {
534 if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
535 printf("vx%d: RX overrun\n", sc->unit);
539 if (fifost & FIFOS_TX_OVERRUN) {
540 if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
541 printf("vx%d: TX overrun\n", sc->unit);
556 * We need to read+write TX_STATUS until we get a 0 status
557 * in order to turn off the interrupt flag.
559 while ((i = CSR_READ_1(sc, VX_W1_TX_STATUS)) & TXS_COMPLETE) {
560 CSR_WRITE_1(sc, VX_W1_TX_STATUS, 0x0);
562 if (i & TXS_JABBER) {
563 ++sc->arpcom.ac_if.if_oerrors;
564 if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
565 printf("vx%d: jabber (%x)\n", sc->unit, i);
567 } else if (i & TXS_UNDERRUN) {
568 ++sc->arpcom.ac_if.if_oerrors;
569 if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
570 printf("vx%d: fifo underrun (%x) @%d\n",
571 sc->unit, i, sc->tx_start_thresh);
572 if (sc->tx_succ_ok < 100)
573 sc->tx_start_thresh = min(ETHER_MAX_LEN, sc->tx_start_thresh + 20);
576 } else if (i & TXS_MAX_COLLISION) {
577 ++sc->arpcom.ac_if.if_collisions;
578 CSR_WRITE_2(sc, VX_COMMAND, TX_ENABLE);
579 sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
581 sc->tx_succ_ok = (sc->tx_succ_ok+1) & 127;
589 register short status;
590 struct vx_softc *sc = voidsc;
591 struct ifnet *ifp = &sc->arpcom.ac_if;
594 CSR_WRITE_2(sc, VX_COMMAND, C_INTR_LATCH);
596 status = CSR_READ_2(sc, VX_STATUS);
598 if ((status & (S_TX_COMPLETE | S_TX_AVAIL |
599 S_RX_COMPLETE | S_CARD_FAILURE)) == 0)
603 * Acknowledge any interrupts. It's important that we do this
604 * first, since there would otherwise be a race condition.
605 * Due to the i386 interrupt queueing, we may get spurious
606 * interrupts occasionally.
608 CSR_WRITE_2(sc, VX_COMMAND, ACK_INTR | status);
610 if (status & S_RX_COMPLETE)
612 if (status & S_TX_AVAIL) {
614 sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
615 vxstart(&sc->arpcom.ac_if);
617 if (status & S_CARD_FAILURE) {
618 printf("vx%d: adapter failure (%x)\n", sc->unit, status);
623 if (status & S_TX_COMPLETE) {
630 /* no more interrupts */
638 struct ifnet *ifp = &sc->arpcom.ac_if;
640 struct ether_header *eh;
643 len = CSR_READ_2(sc, VX_W1_RX_STATUS);
647 if (ifp->if_flags & IFF_DEBUG) {
648 int err = len & ERR_MASK;
651 if (len & ERR_INCOMPLETE)
652 s = "incomplete packet";
653 else if (err == ERR_OVERRUN)
654 s = "packet overrun";
655 else if (err == ERR_RUNT)
657 else if (err == ERR_ALIGNMENT)
659 else if (err == ERR_CRC)
661 else if (err == ERR_OVERSIZE)
662 s = "oversized packet";
663 else if (err == ERR_DRIBBLE)
667 printf("vx%d: %s\n", sc->unit, s);
670 if (len & ERR_INCOMPLETE)
678 len &= RX_BYTES_MASK; /* Lower 11 bits = RX bytes. */
680 /* Pull packet off interface. */
692 m0 = m_devget(mtod(m, char *), m->m_pkthdr.len, ETHER_ALIGN, ifp, NULL);
702 /* We assume the header fit entirely in one mbuf. */
703 eh = mtod(m, struct ether_header *);
706 * XXX: Some cards seem to be in promiscous mode all the time.
707 * we need to make sure we only get our own stuff always.
711 if ((eh->ether_dhost[0] & 1) == 0 /* !mcast and !bcast */
712 && bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN) != 0) {
717 m_adj(m, sizeof(struct ether_header));
718 ether_input(ifp, eh, m);
721 * In periods of high traffic we can actually receive enough
722 * packets so that the fifo overrun bit will be set at this point,
723 * even though we just read a packet. In this case we
724 * are not going to receive any more interrupts. We check for
725 * this condition and read again until the fifo is not full.
726 * We could simplify this test by not using vxstatus(), but
727 * rechecking the RX_STATUS register directly. This test could
728 * result in unnecessary looping in cases where there is a new
729 * packet but the fifo is not full, but it will not fix the
732 * Even with this improvement, we still get packet overrun errors
733 * which are hurting performance. Maybe when I get some more time
734 * I'll modify vxread() so that it can handle RX_EARLY interrupts.
737 len = CSR_READ_2(sc, VX_W1_RX_STATUS);
738 /* Check if we are stuck and reset [see XXX comment] */
739 if (len & ERR_INCOMPLETE) {
740 if (ifp->if_flags & IFF_DEBUG)
741 printf("vx%d: adapter reset\n", sc->unit);
751 CSR_WRITE_2(sc, VX_COMMAND, RX_DISCARD_TOP_PACK);
759 struct ifnet *ifp = &sc->arpcom.ac_if;
760 struct mbuf *top, **mp, *m;
764 m = sc->mb[sc->next_mb];
765 sc->mb[sc->next_mb] = 0;
767 MGETHDR(m, M_DONTWAIT, MT_DATA);
771 /* If the queue is no longer full, refill. */
772 if (sc->last_mb == sc->next_mb && sc->buffill_pending == 0) {
773 sc->ch = timeout(vxmbuffill, sc, 1);
774 sc->buffill_pending = 1;
776 /* Convert one of our saved mbuf's. */
777 sc->next_mb = (sc->next_mb + 1) % MAX_MBS;
778 m->m_data = m->m_pktdat;
779 m->m_flags = M_PKTHDR;
780 bzero(&m->m_pkthdr, sizeof(m->m_pkthdr));
782 m->m_pkthdr.rcvif = ifp;
783 m->m_pkthdr.len = totlen;
789 * We read the packet at splhigh() so that an interrupt from another
790 * device doesn't cause the card's buffer to overflow while we're
791 * reading it. We may still lose packets at other times.
796 * Since we don't set allowLargePackets bit in MacControl register,
797 * we can assume that totlen <= 1500bytes.
798 * The while loop will be performed iff we have a packet with
799 * MLEN < m_len < MINCLSIZE.
803 m = sc->mb[sc->next_mb];
804 sc->mb[sc->next_mb] = 0;
806 MGET(m, M_DONTWAIT, MT_DATA);
813 sc->next_mb = (sc->next_mb + 1) % MAX_MBS;
817 if (totlen >= MINCLSIZE) {
818 MCLGET(m, M_DONTWAIT);
819 if (m->m_flags & M_EXT)
822 len = min(totlen, len);
824 bus_space_read_multi_4(sc->vx_btag, sc->vx_bhandle,
825 VX_W1_RX_PIO_RD_1, mtod(m, u_int32_t *), len / 4);
827 bus_space_read_multi_1(sc->vx_btag, sc->vx_bhandle,
828 VX_W1_RX_PIO_RD_1, mtod(m, u_int8_t *) + (len & ~3),
837 CSR_WRITE_2(sc, VX_COMMAND, RX_DISCARD_TOP_PACK);
846 vxioctl(ifp, cmd, data)
847 register struct ifnet *ifp;
851 struct vx_softc *sc = ifp->if_softc;
852 struct ifreq *ifr = (struct ifreq *) data;
860 ether_ioctl(ifp, cmd, data);
864 if ((ifp->if_flags & IFF_UP) == 0 &&
865 (ifp->if_flags & IFF_RUNNING) != 0) {
867 * If interface is marked up and it is stopped, then
871 ifp->if_flags &= ~IFF_RUNNING;
872 } else if ((ifp->if_flags & IFF_UP) != 0 &&
873 (ifp->if_flags & IFF_RUNNING) == 0) {
875 * If interface is marked up and it is stopped, then
881 * deal with flags changes:
882 * IFF_MULTICAST, IFF_PROMISC,
883 * IFF_LINK0, IFF_LINK1,
892 * Set the interface MTU.
894 if (ifr->ifr_mtu > ETHERMTU) {
897 ifp->if_mtu = ifr->ifr_mtu;
904 * Multicast list has changed; set the hardware filter
937 struct vx_softc *sc = ifp->if_softc;
939 if (ifp->if_flags & IFF_DEBUG)
940 printf("vx%d: device timeout\n", ifp->if_unit);
941 ifp->if_flags &= ~IFF_OACTIVE;
950 struct ifnet *ifp = &sc->arpcom.ac_if;
954 CSR_WRITE_2(sc, VX_COMMAND, RX_DISABLE);
955 CSR_WRITE_2(sc, VX_COMMAND, RX_DISCARD_TOP_PACK);
957 CSR_WRITE_2(sc, VX_COMMAND, TX_DISABLE);
958 CSR_WRITE_2(sc, VX_COMMAND, STOP_TRANSCEIVER);
960 CSR_WRITE_2(sc, VX_COMMAND, RX_RESET);
962 CSR_WRITE_2(sc, VX_COMMAND, TX_RESET);
964 CSR_WRITE_2(sc, VX_COMMAND, C_INTR_LATCH);
965 CSR_WRITE_2(sc, VX_COMMAND, SET_RD_0_MASK);
966 CSR_WRITE_2(sc, VX_COMMAND, SET_INTR_MASK);
967 CSR_WRITE_2(sc, VX_COMMAND, SET_RX_FILTER);
979 j = CSR_READ_2(sc, VX_W0_EEPROM_COMMAND);
986 printf("vx%d: eeprom failed to come ready\n", sc->unit);
996 struct vx_softc *sc = (struct vx_softc *) sp;
1002 if (sc->mb[i] == NULL)
1003 MGET(sc->mb[i], M_DONTWAIT, MT_DATA);
1004 if (sc->mb[i] == NULL)
1006 i = (i + 1) % MAX_MBS;
1007 } while (i != sc->next_mb);
1009 /* If the queue was not filled, try again. */
1010 if (sc->last_mb != sc->next_mb) {
1011 sc->ch = timeout(vxmbuffill, sc, 1);
1012 sc->buffill_pending = 1;
1014 sc->buffill_pending = 0;
1021 struct vx_softc *sc;
1026 for (i = 0; i < MAX_MBS; i++) {
1032 sc->last_mb = sc->next_mb = 0;
1033 if (sc->buffill_pending != 0)
1034 untimeout(vxmbuffill, sc, sc->ch);