1 /* $NetBSD: smc90cx6.c,v 1.59 2009/03/14 15:36:17 dsl Exp $ */
4 * Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Ignatios Souvatzis.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * Chip core driver for the SMC90c26 / SMC90c56 (and SMC90c66 in '56
34 * compatibility mode) boards
37 #include <sys/cdefs.h>
38 __KERNEL_RCSID(0, "$NetBSD: smc90cx6.c,v 1.59 2009/03/14 15:36:17 dsl Exp $");
40 /* #define BAHSOFTCOPY */
41 #define BAHRETRANSMIT /**/
46 #include <sys/param.h>
47 #include <sys/systm.h>
50 #include <sys/device.h>
51 #include <sys/protosw.h>
52 #include <sys/socket.h>
53 #include <sys/syslog.h>
54 #include <sys/ioctl.h>
55 #include <sys/errno.h>
56 #include <sys/kernel.h>
60 #include <net/if_dl.h>
61 #include <net/if_ether.h>
62 #include <net/if_types.h>
63 #include <net/if_arc.h>
66 #include <netinet/in.h>
67 #include <netinet/in_systm.h>
68 #include <netinet/in_var.h>
69 #include <netinet/ip.h>
70 #include <netinet/if_inarp.h>
75 #include <net/bpfdesc.h>
81 #include <dev/ic/smc90cx6reg.h>
82 #include <dev/ic/smc90cx6var.h>
84 /* these should be elsewhere */
87 #define ARC_MIN_FORBID_LEN 254
88 #define ARC_MAX_FORBID_LEN 256
89 #define ARC_MAX_LEN 508
90 #define ARC_ADDR_LEN 1
92 /* for watchdog timer. This should be more than enough. */
93 #define ARCTIMEOUT (5*IFNET_SLOWHZ)
96 * This currently uses 2 bufs for tx, 2 for rx
100 * rx has a fillcount variable. If fillcount > (NRXBUF-1),
101 * rx can be switched off from rx hard int.
102 * Else rx is restarted on the other receiver.
103 * rx soft int counts down. if it is == (NRXBUF-1), it restarts
105 * To ensure packet ordering (we need that for 1201 later), we have a counter
106 * which is incremented modulo 256 on each receive and a per buffer
107 * variable, which is set to the counter on filling. The soft int can
108 * compare both values to determine the older packet.
110 * Transmit direction:
112 * bah_start checks tx_fillcount
115 * else fill tx_act ^ 1 && inc tx_fillcount
117 * check tx_fillcount again.
118 * case 2: set IFF_OACTIVE to stop arc_output from filling us.
121 * tint clears IFF_OCATIVE, decrements and checks tx_fillcount
122 * case 1: start tx on tx_act ^ 1, softcall bah_start
123 * case 0: softcall bah_start
125 * #define fill(i) get mbuf && copy mbuf to chip(i)
128 void bah_init(struct bah_softc
*);
129 void bah_reset(struct bah_softc
*);
130 void bah_stop(struct bah_softc
*);
131 void bah_start(struct ifnet
*);
133 int bah_ioctl(struct ifnet
*, unsigned long, void *);
134 void bah_watchdog(struct ifnet
*);
135 void bah_srint(void *vsc
);
136 static void bah_tint(struct bah_softc
*, int);
137 void bah_reconwatch(void *);
141 #define GETREG(off) bus_space_read_1(bst_r, regs, (off))
142 #define PUTREG(off, v) bus_space_write_1(bst_r, regs, (off), (v))
143 #define GETMEM(off) bus_space_read_1(bst_m, mem, (off))
144 #define PUTMEM(off, v) bus_space_write_1(bst_m, mem, (off), (v))
147 bah_attach_subr(struct bah_softc
*sc
)
149 struct ifnet
*ifp
= &sc
->sc_arccom
.ac_if
;
151 u_int8_t linkaddress
;
153 bus_space_tag_t bst_r
= sc
->sc_bst_r
;
154 bus_space_tag_t bst_m
= sc
->sc_bst_m
;
155 bus_space_handle_t regs
= sc
->sc_regs
;
156 bus_space_handle_t mem
= sc
->sc_mem
;
158 #if (defined(BAH_DEBUG) && (BAH_DEBUG > 2))
159 printf("\n%s: attach(0x%x, 0x%x, 0x%x)\n",
160 device_xname(&sc
->sc_dev
), parent
, self
, aux
);
165 * read the arcnet address from the board
168 (*sc
->sc_reset
)(sc
, 1);
172 } while (!(GETREG(BAHSTAT
) & BAH_POR
));
174 linkaddress
= GETMEM(BAHMACOFF
);
176 printf(": link addr 0x%02x(%d)\n", linkaddress
, linkaddress
);
178 /* clear the int mask... */
183 PUTREG(BAHCMD
, BAH_CONF(CONF_LONG
));
184 PUTREG(BAHCMD
, BAH_CLR(CLR_POR
|CLR_RECONFIG
));
185 sc
->sc_recontime
= sc
->sc_reconcount
= 0;
187 /* and reenable kernel int level */
191 * set interface to stopped condition (reset)
195 strlcpy(ifp
->if_xname
, device_xname(&sc
->sc_dev
), IFNAMSIZ
);
197 ifp
->if_start
= bah_start
;
198 ifp
->if_ioctl
= bah_ioctl
;
200 ifp
->if_watchdog
= bah_watchdog
;
201 IFQ_SET_READY(&ifp
->if_snd
);
203 ifp
->if_flags
= IFF_BROADCAST
| IFF_SIMPLEX
| IFF_NOTRAILERS
;
205 ifp
->if_mtu
= ARCMTU
;
207 arc_ifattach(ifp
, linkaddress
);
210 sc
->sc_rxcookie
= softint_establish(SOFTINT_NET
, bah_srint
, sc
);
211 sc
->sc_txcookie
= softint_establish(SOFTINT_NET
,
212 (void (*)(void *))bah_start
, ifp
);
215 callout_init(&sc
->sc_recon_ch
, 0);
223 bah_init(struct bah_softc
*sc
)
228 ifp
= &sc
->sc_arccom
.ac_if
;
230 if ((ifp
->if_flags
& IFF_RUNNING
) == 0) {
232 ifp
->if_flags
|= IFF_RUNNING
;
240 * Reset the interface...
242 * this assumes that it is called inside a critical section...
246 bah_reset(struct bah_softc
*sc
)
251 bus_space_tag_t bst_r
= sc
->sc_bst_r
;
252 bus_space_tag_t bst_m
= sc
->sc_bst_m
;
253 bus_space_handle_t regs
= sc
->sc_regs
;
254 bus_space_handle_t mem
= sc
->sc_mem
;
256 ifp
= &sc
->sc_arccom
.ac_if
;
259 printf("%s: reset\n", device_xname(&sc
->sc_dev
));
261 /* stop and restart hardware */
263 (*sc
->sc_reset
)(sc
, 1);
266 } while (!(GETREG(BAHSTAT
) & BAH_POR
));
268 linkaddress
= GETMEM(BAHMACOFF
);
270 #if defined(BAH_DEBUG) && (BAH_DEBUG > 2)
271 printf("%s: reset: card reset, link addr = 0x%02x (%ld)\n",
272 device_xname(&sc
->sc_dev
), linkaddress
, linkaddress
);
275 /* tell the routing level about the (possibly changed) link address */
276 if_set_sadl(ifp
, &linkaddress
, sizeof(linkaddress
), false);
278 /* POR is NMI, but we need it below: */
279 sc
->sc_intmask
= BAH_RECON
|BAH_POR
;
280 PUTREG(BAHSTAT
, sc
->sc_intmask
);
281 PUTREG(BAHCMD
, BAH_CONF(CONF_LONG
));
284 printf("%s: reset: chip configured, status=0x%02x\n",
285 device_xname(&sc
->sc_dev
), GETREG(BAHSTAT
));
287 PUTREG(BAHCMD
, BAH_CLR(CLR_POR
|CLR_RECONFIG
));
290 printf("%s: reset: bits cleared, status=0x%02x\n",
291 device_xname(&sc
->sc_dev
), GETREG(BAHSTAT
);
294 sc
->sc_reconcount_excessive
= ARC_EXCESSIVE_RECONS
;
298 sc
->sc_intmask
|= BAH_RI
;
299 sc
->sc_rx_fillcount
= 0;
302 PUTREG(BAHCMD
, BAH_RXBC(2));
303 PUTREG(BAHSTAT
, sc
->sc_intmask
);
306 printf("%s: reset: started receiver, status=0x%02x\n",
307 device_xname(&sc
->sc_dev
), GETREG(BAHSTAT
);
310 /* and init transmitter status */
312 sc
->sc_tx_fillcount
= 0;
314 ifp
->if_flags
|= IFF_RUNNING
;
315 ifp
->if_flags
&= ~IFF_OACTIVE
;
321 * Take interface offline
324 bah_stop(struct bah_softc
*sc
)
326 bus_space_tag_t bst_r
= sc
->sc_bst_r
;
327 bus_space_handle_t regs
= sc
->sc_regs
;
329 /* Stop the interrupts */
332 /* Stop the interface */
333 (*sc
->sc_reset
)(sc
, 0);
335 /* Stop watchdog timer */
336 sc
->sc_arccom
.ac_if
.if_timer
= 0;
340 * Start output on interface. Get another datagram to send
341 * off the interface queue, and copy it to the
342 * interface before starting the output
344 * this assumes that it is called inside a critical section...
345 * XXX hm... does it still?
349 bah_start(struct ifnet
*ifp
)
351 struct bah_softc
*sc
= ifp
->if_softc
;
354 bus_space_tag_t bst_r
= sc
->sc_bst_r
;
355 bus_space_handle_t regs
= sc
->sc_regs
;
356 bus_space_tag_t bst_m
= sc
->sc_bst_m
;
357 bus_space_handle_t mem
= sc
->sc_mem
;
360 int len
, tlen
, offset
, s
, buffer
;
362 u_long copystart
, lencopy
, perbyte
;
365 #if defined(BAH_DEBUG) && (BAH_DEBUG > 3)
366 printf("%s: start(0x%x)\n", device_xname(&sc
->sc_dev
), ifp
);
369 if ((ifp
->if_flags
& IFF_RUNNING
) == 0)
374 if (sc
->sc_tx_fillcount
>= 2) {
379 IFQ_DEQUEUE(&ifp
->if_snd
, m
);
380 buffer
= sc
->sc_tx_act
^ 1;
389 * If bpf is listening on this interface, let it
390 * see the packet before we commit it to the wire
392 * (can't give the copy in A2060 card RAM to bpf, because
393 * that RAM is just accessed as on every other byte)
396 bpf_mtap(ifp
->if_bpf
, m
);
400 if (m
->m_len
< ARC_HDRLEN
)
401 m
= m_pullup(m
, ARC_HDRLEN
);/* gcc does structure padding */
402 printf("%s: start: filling %ld from %ld to %ld type %ld\n",
403 device_xname(&sc
->sc_dev
), buffer
, mtod(m
, u_char
*)[0],
404 mtod(m
, u_char
*)[1], mtod(m
, u_char
*)[2]);
409 bah_ram_ptr
= buffer
*512;
414 /* write the addresses to RAM and throw them away */
417 * Hardware does this: Yet Another Microsecond Saved.
418 * (btw, timing code says usually 2 microseconds)
419 * PUTMEM(bah_ram_ptr + 0, mtod(m, u_char *)[0]);
422 PUTMEM(bah_ram_ptr
+ 1, mtod(m
, u_char
*)[1]);
425 /* get total length left at this point */
426 tlen
= m
->m_pkthdr
.len
;
427 if (tlen
< ARC_MIN_FORBID_LEN
) {
429 PUTMEM(bah_ram_ptr
+ 2, offset
);
431 PUTMEM(bah_ram_ptr
+ 2, 0);
432 if (tlen
<= ARC_MAX_FORBID_LEN
)
433 offset
= 255; /* !!! */
435 if (tlen
> ARC_MAX_LEN
)
439 PUTMEM(bah_ram_ptr
+ 3, offset
);
442 bah_ram_ptr
+= offset
;
444 /* lets loop through the mbuf chain */
446 for (mp
= m
; mp
; mp
= mp
->m_next
) {
447 if ((len
= mp
->m_len
)) { /* YAMS */
448 bus_space_write_region_1(bst_m
, mem
, bah_ram_ptr
,
449 mtod(mp
, void *), len
);
455 sc
->sc_broadcast
[buffer
] = (m
->m_flags
& M_BCAST
) != 0;
456 sc
->sc_retransmits
[buffer
] = (m
->m_flags
& M_BCAST
) ? 1 : 5;
458 /* actually transmit the packet */
461 if (++sc
->sc_tx_fillcount
> 1) {
463 * We are filled up to the rim. No more bufs for the moment,
466 ifp
->if_flags
|= IFF_OACTIVE
;
469 printf("%s: start: starting transmitter on buffer %d\n",
470 device_xname(&sc
->sc_dev
), buffer
);
472 /* Transmitter was off, start it */
473 sc
->sc_tx_act
= buffer
;
476 * We still can accept another buf, so don't:
477 * ifp->if_flags |= IFF_OACTIVE;
479 sc
->sc_intmask
|= BAH_TA
;
480 PUTREG(BAHCMD
, BAH_TX(buffer
));
481 PUTREG(BAHSTAT
, sc
->sc_intmask
);
483 sc
->sc_arccom
.ac_if
.if_timer
= ARCTIMEOUT
;
489 * After 10 times reading the docs, I realized
490 * that in the case the receiver NAKs the buffer request,
491 * the hardware retries till shutdown.
492 * This is integrated now in the code above.
499 * Arcnet interface receiver soft interrupt:
500 * get the stuff out of any filled buffer we find.
505 struct bah_softc
*sc
= (struct bah_softc
*)vsc
;
506 int buffer
, len
, len1
, amount
, offset
, s
, type
;
508 struct mbuf
*m
, *dst
, *head
;
509 struct arc_header
*ah
;
512 bus_space_tag_t bst_r
= sc
->sc_bst_r
;
513 bus_space_tag_t bst_m
= sc
->sc_bst_m
;
514 bus_space_handle_t regs
= sc
->sc_regs
;
515 bus_space_handle_t mem
= sc
->sc_mem
;
517 ifp
= &sc
->sc_arccom
.ac_if
;
521 buffer
= sc
->sc_rx_act
^ 1;
524 /* Allocate header mbuf */
525 MGETHDR(m
, M_DONTWAIT
, MT_DATA
);
529 * in case s.th. goes wrong with mem, drop it
530 * to make sure the receiver can be started again
531 * count it as input error (we dont have any other
538 m
->m_pkthdr
.rcvif
= ifp
;
541 * Align so that IP packet will be longword aligned. Here we
542 * assume that m_data of new packet is longword aligned.
543 * When implementing PHDS, we might have to change it to 2,
544 * (2*sizeof(ulong) - ARC_HDRNEWLEN)), packet type dependent.
547 bah_ram_ptr
= buffer
*512;
548 offset
= GETMEM(bah_ram_ptr
+ 2);
552 offset
= GETMEM(bah_ram_ptr
+ 3);
555 if (len
+2 >= MINCLSIZE
)
556 MCLGET(m
, M_DONTWAIT
);
563 type
= GETMEM(bah_ram_ptr
+ offset
);
564 m
->m_data
+= 1 + arc_isphds(type
);
567 ah
= mtod(head
, struct arc_header
*);
569 ah
->arc_shost
= GETMEM(bah_ram_ptr
+ 0);
570 ah
->arc_dhost
= GETMEM(bah_ram_ptr
+ 1);
572 m
->m_pkthdr
.len
= len
+2; /* whole packet length */
573 m
->m_len
= 2; /* mbuf filled with ARCnet addresses */
574 bah_ram_ptr
+= offset
; /* ram buffer continues there */
579 amount
= M_TRAILINGSPACE(m
);
583 MGET(m
, M_DONTWAIT
, MT_DATA
);
590 if (len1
>= MINCLSIZE
)
591 MCLGET(m
, M_DONTWAIT
);
595 amount
= M_TRAILINGSPACE(m
);
601 bus_space_read_region_1(bst_m
, mem
, bah_ram_ptr
,
602 mtod(m
, u_char
*) + m
->m_len
, len1
);
611 bpf_mtap(ifp
->if_bpf
, head
);
614 (*sc
->sc_arccom
.ac_if
.if_input
)(&sc
->sc_arccom
.ac_if
, head
);
624 /* mark buffer as invalid by source id 0 */
625 bus_space_write_1(bst_m
, mem
, buffer
*512, 0);
628 if (--sc
->sc_rx_fillcount
== 2 - 1) {
630 /* was off, restart it on buffer just emptied */
631 sc
->sc_rx_act
= buffer
;
632 sc
->sc_intmask
|= BAH_RI
;
634 /* this also clears the RI flag interrupt: */
635 PUTREG(BAHCMD
, BAH_RXBC(buffer
));
636 PUTREG(BAHSTAT
, sc
->sc_intmask
);
639 printf("%s: srint: restarted rx on buf %ld\n",
640 device_xname(&sc
->sc_dev
), buffer
);
647 bah_tint(struct bah_softc
*sc
, int isr
)
651 bus_space_tag_t bst_r
= sc
->sc_bst_r
;
652 bus_space_handle_t regs
= sc
->sc_regs
;
660 ifp
= &(sc
->sc_arccom
.ac_if
);
661 buffer
= sc
->sc_tx_act
;
665 * Normal situations first for fast path:
666 * If acknowledgement received ok or broadcast, we're ok.
670 if (isr
& BAH_TMA
|| sc
->sc_broadcast
[buffer
])
671 sc
->sc_arccom
.ac_if
.if_opackets
++;
673 else if (ifp
->if_flags
& IFF_LINK2
&& ifp
->if_timer
> 0
674 && --sc
->sc_retransmits
[buffer
] > 0) {
675 /* retransmit same buffer */
676 PUTREG(BAHCMD
, BAH_TX(buffer
));
684 /* We know we can accept another buffer at this point. */
685 ifp
->if_flags
&= ~IFF_OACTIVE
;
687 if (--sc
->sc_tx_fillcount
> 0) {
690 * start tx on other buffer.
691 * This also clears the int flag
694 sc
->sc_tx_act
= buffer
;
698 * sc->sc_intmask |= BAH_TA;
699 * PUTREG(BAHSTAT, sc->sc_intmask);
701 PUTREG(BAHCMD
, BAH_TX(buffer
));
702 /* init watchdog timer */
703 ifp
->if_timer
= ARCTIMEOUT
;
705 #if defined(BAH_DEBUG) && (BAH_DEBUG > 1)
706 printf("%s: tint: starting tx on buffer %d, status 0x%02x\n",
707 device_xname(&sc
->sc_dev
), buffer
, GETREG(BAHSTAT
));
710 /* have to disable TX interrupt */
711 sc
->sc_intmask
&= ~BAH_TA
;
712 PUTREG(BAHSTAT
, sc
->sc_intmask
);
713 /* ... and watchdog timer */
717 printf("%s: tint: no more buffers to send, status 0x%02x\n",
718 device_xname(&sc
->sc_dev
), GETREG(BAHSTAT
));
724 /* schedule soft int to fill a new buffer for us */
725 softint_schedule(sc
->sc_txcookie
);
727 /* call it directly */
733 * Our interrupt routine
738 struct bah_softc
*sc
= arg
;
740 bus_space_tag_t bst_r
= sc
->sc_bst_r
;
741 bus_space_tag_t bst_m
= sc
->sc_bst_m
;
742 bus_space_handle_t regs
= sc
->sc_regs
;
743 bus_space_handle_t mem
= sc
->sc_mem
;
745 u_char isr
, maskedisr
;
749 isr
= GETREG(BAHSTAT
);
750 maskedisr
= isr
& sc
->sc_intmask
;
755 #if defined(BAH_DEBUG) && (BAH_DEBUG>1)
756 printf("%s: intr: status 0x%02x, intmask 0x%02x\n",
757 device_xname(&sc
->sc_dev
), isr
, sc
->sc_intmask
);
760 if (maskedisr
& BAH_POR
) {
762 * XXX We should never see this. Don't bother to store
764 * sc->sc_arccom.ac_anaddr = GETMEM(BAHMACOFF);
766 PUTREG(BAHCMD
, BAH_CLR(CLR_POR
));
768 "%s: intr: got spurious power on reset int\n",
769 device_xname(&sc
->sc_dev
));
772 if (maskedisr
& BAH_RECON
) {
775 * PUTREG(BAHCMD, BAH_CONF(CONF_LONG));
777 PUTREG(BAHCMD
, BAH_CLR(CLR_RECONFIG
));
778 sc
->sc_arccom
.ac_if
.if_collisions
++;
781 * If less than 2 seconds per reconfig:
782 * If ARC_EXCESSIVE_RECONFIGS
783 * since last burst, complain and set threshold for
784 * warnings to ARC_EXCESSIVE_RECONS_REWARN.
786 * This allows for, e.g., new stations on the cable, or
787 * cable switching as long as it is over after
788 * (normally) 16 seconds.
790 * XXX TODO: check timeout bits in status word and
791 * double time if necessary.
794 callout_stop(&sc
->sc_recon_ch
);
795 newsec
= time_second
;
796 if ((newsec
- sc
->sc_recontime
<= 2) &&
797 (++sc
->sc_reconcount
== ARC_EXCESSIVE_RECONS
)) {
799 "%s: excessive token losses, "
800 "cable problem?\n", device_xname(&sc
->sc_dev
));
802 sc
->sc_recontime
= newsec
;
803 callout_reset(&sc
->sc_recon_ch
, 15 * hz
,
804 bah_reconwatch
, (void *)sc
);
807 if (maskedisr
& BAH_RI
) {
808 #if defined(BAH_DEBUG) && (BAH_DEBUG > 1)
809 printf("%s: intr: hard rint, act %ld\n",
810 device_xname(&sc
->sc_dev
), sc
->sc_rx_act
);
813 buffer
= sc
->sc_rx_act
;
814 /* look if buffer is marked invalid: */
815 if (GETMEM(buffer
*512) == 0) {
817 * invalid marked buffer (or illegally
821 "%s: spurious RX interrupt or sender 0 "
822 " (ignored)\n", device_xname(&sc
->sc_dev
));
824 * restart receiver on same buffer.
825 * XXX maybe better reset interface?
827 PUTREG(BAHCMD
, BAH_RXBC(buffer
));
829 if (++sc
->sc_rx_fillcount
> 1) {
830 sc
->sc_intmask
&= ~BAH_RI
;
831 PUTREG(BAHSTAT
, sc
->sc_intmask
);
834 sc
->sc_rx_act
= buffer
;
837 * Start receiver on other receive
838 * buffer. This also clears the RI
841 PUTREG(BAHCMD
, BAH_RXBC(buffer
));
842 /* in RX intr, so mask is ok for RX */
845 printf("%s: strt rx for buf %ld, "
847 device_xname(&sc
->sc_dev
), sc
->sc_rx_act
,
854 * this one starts a soft int to copy out
857 softint_schedule(sc
->sc_rxcookie
);
859 /* this one does the copy here */
864 if (maskedisr
& BAH_TA
) {
867 isr
= GETREG(BAHSTAT
);
868 maskedisr
= isr
& sc
->sc_intmask
;
875 bah_reconwatch(void *arg
)
877 struct bah_softc
*sc
= arg
;
879 if (sc
->sc_reconcount
>= ARC_EXCESSIVE_RECONS
) {
880 sc
->sc_reconcount
= 0;
881 log(LOG_WARNING
, "%s: token valid again.\n",
882 device_xname(&sc
->sc_dev
));
884 sc
->sc_reconcount
= 0;
889 * Process an ioctl request.
890 * This code needs some work - it looks pretty ugly.
893 bah_ioctl(struct ifnet
*ifp
, u_long cmd
, void *data
)
895 struct bah_softc
*sc
;
902 ifa
= (struct ifaddr
*)data
;
903 ifr
= (struct ifreq
*)data
;
906 #if defined(BAH_DEBUG) && (BAH_DEBUG > 2)
907 printf("%s: ioctl() called, cmd = 0x%x\n",
908 device_xname(&sc
->sc_dev
), cmd
);
913 ifp
->if_flags
|= IFF_UP
;
915 switch (ifa
->ifa_addr
->sa_family
) {
918 arp_ifinit(ifp
, ifa
);
926 if ((error
= ifioctl_common(ifp
, cmd
, data
)) != 0)
928 /* XXX re-use ether_ioctl() */
929 switch (ifp
->if_flags
& (IFF_UP
|IFF_RUNNING
)) {
932 * If interface is marked down and it is running,
936 ifp
->if_flags
&= ~IFF_RUNNING
;
940 * If interface is marked up and it is stopped, then
950 switch (ifreq_getaddr(cmd
, ifr
)->sa_family
) {
956 error
= EAFNOSUPPORT
;
962 error
= ether_ioctl(ifp
, cmd
, data
);
970 * watchdog routine for transmitter.
972 * We need this, because else a receiver whose hardware is alive, but whose
973 * software has not enabled the Receiver, would make our hardware wait forever
974 * Discovered this after 20 times reading the docs.
976 * Only thing we do is disable transmitter. We'll get an transmit timeout,
977 * and the int handler will have to decide not to retransmit (in case
978 * retransmission is implemented).
980 * This one assumes being called inside splnet()
984 bah_watchdog(struct ifnet
*ifp
)
986 struct bah_softc
*sc
= ifp
->if_softc
;
988 bus_space_tag_t bst_r
= sc
->sc_bst_r
;
989 bus_space_handle_t regs
= sc
->sc_regs
;
991 PUTREG(BAHCMD
, BAH_TXDIS
);