1 /* $NetBSD: seeq8005.c,v 1.42 2007/10/19 12:00:00 ad Exp $ */
4 * Copyright (c) 2000, 2001 Ben Harris
5 * Copyright (c) 1995-1998 Mark Brinicombe
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Mark Brinicombe
19 * for the NetBSD Project.
20 * 4. The name of the company nor the name of the author may be used to
21 * endorse or promote products derived from this software without specific
22 * prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
25 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
28 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * seeq8005.c - SEEQ 8005 device driver
40 * This driver currently supports the following chips:
41 * SEEQ 8005 Advanced Ethernet Data Link Controller
42 * SEEQ 80C04 Ethernet Data Link Controller
43 * SEEQ 80C04A AutoDUPLEX CMOS Ethernet Data Link Controller
46 * More information on the 8004 and 8005 AEDLC controllers can be found in
47 * the SEEQ Technology Inc 1992 Data Comm Devices data book.
49 * This data book may no longer be available as these are rather old chips
53 * This driver is based on the arm32 ea(4) driver, hence the names of many
57 * Bugs/possible improvements:
58 * - Does not currently support DMA
59 * - Does not transmit multiple packets in one go
60 * - Does not support 8-bit busses
63 #include <sys/cdefs.h>
64 __KERNEL_RCSID(0, "$NetBSD: seeq8005.c,v 1.42 2007/10/19 12:00:00 ad Exp $");
66 #include <sys/param.h>
67 #include <sys/systm.h>
68 #include <sys/endian.h>
69 #include <sys/errno.h>
70 #include <sys/ioctl.h>
72 #include <sys/socket.h>
73 #include <sys/syslog.h>
74 #include <sys/device.h>
77 #include <net/if_dl.h>
78 #include <net/if_types.h>
79 #include <net/if_ether.h>
80 #include <net/if_media.h>
85 #include <net/bpfdesc.h>
96 #include <dev/ic/seeq8005reg.h>
97 #include <dev/ic/seeq8005var.h>
99 /*#define SEEQ_DEBUG*/
101 /* for debugging convenience */
102 #ifdef SEEQ8005_DEBUG
103 #define SEEQ_DEBUG_MISC 1
104 #define SEEQ_DEBUG_TX 2
105 #define SEEQ_DEBUG_RX 4
106 #define SEEQ_DEBUG_PKT 8
107 #define SEEQ_DEBUG_TXINT 16
108 #define SEEQ_DEBUG_RXINT 32
109 int seeq8005_debug
= 0;
110 #define DPRINTF(f, x) { if (seeq8005_debug & (f)) printf x; }
112 #define DPRINTF(f, x)
115 #define SEEQ_TX_BUFFER_SIZE 0x800 /* (> ETHER_MAX_LEN) */
117 #define SEEQ_READ16(sc, iot, ioh, reg) \
118 ((sc)->sc_flags & SF_8BIT ? \
119 (bus_space_read_1((iot), (ioh), (reg)) | \
120 (bus_space_read_1((iot), (ioh), (reg) + 1) << 8)) : \
121 (bus_space_read_2((iot), (ioh), (reg))))
123 #define SEEQ_WRITE16(sc, iot, ioh, reg, val) do { \
124 if ((sc)->sc_flags & SF_8BIT) { \
125 bus_space_write_1((iot), (ioh), (reg), (val) & 0xff); \
126 bus_space_write_1((iot), (ioh), (reg) + 1, (val) >> 8); \
128 bus_space_write_2((iot), (ioh), (reg), (val)); \
129 } while (/*CONSTCOND*/0)
135 static int ea_init(struct ifnet
*);
136 static int ea_ioctl(struct ifnet
*, u_long
, void *);
137 static void ea_start(struct ifnet
*);
138 static void ea_watchdog(struct ifnet
*);
139 static void ea_chipreset(struct seeq8005_softc
*);
140 static void ea_ramtest(struct seeq8005_softc
*);
141 static int ea_stoptx(struct seeq8005_softc
*);
142 static int ea_stoprx(struct seeq8005_softc
*);
143 static void ea_stop(struct ifnet
*, int);
144 static void ea_await_fifo_empty(struct seeq8005_softc
*);
145 static void ea_await_fifo_full(struct seeq8005_softc
*);
146 static void ea_writebuf(struct seeq8005_softc
*, u_char
*, int, size_t);
147 static void ea_readbuf(struct seeq8005_softc
*, u_char
*, int, size_t);
148 static void ea_select_buffer(struct seeq8005_softc
*, int);
149 static void ea_set_address(struct seeq8005_softc
*, int, const u_int8_t
*);
150 static void ea_read(struct seeq8005_softc
*, int, int);
151 static struct mbuf
*ea_get(struct seeq8005_softc
*, int, int, struct ifnet
*);
152 static void ea_txint(struct seeq8005_softc
*);
153 static void ea_rxint(struct seeq8005_softc
*);
154 static void eatxpacket(struct seeq8005_softc
*);
155 static int ea_writembuf(struct seeq8005_softc
*, struct mbuf
*, int);
156 static void ea_mc_reset(struct seeq8005_softc
*);
157 static void ea_mc_reset_8004(struct seeq8005_softc
*);
158 static void ea_mc_reset_8005(struct seeq8005_softc
*);
159 static int ea_mediachange(struct ifnet
*);
160 static void ea_mediastatus(struct ifnet
*, struct ifmediareq
*);
162 static char* padbuf
= NULL
;
170 seeq8005_attach(struct seeq8005_softc
*sc
, const u_int8_t
*myaddr
, int *media
,
171 int nmedia
, int defmedia
)
173 struct ifnet
*ifp
= &sc
->sc_ethercom
.ec_if
;
174 bus_space_tag_t iot
= sc
->sc_iot
;
175 bus_space_handle_t ioh
= sc
->sc_ioh
;
178 KASSERT(myaddr
!= NULL
);
179 printf(" address %s", ether_sprintf(myaddr
));
181 /* Stop the board. */
185 /* Work out data bus width. */
186 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_RX_PTR
, 0x1234);
187 if (SEEQ_READ16(sc
, iot
, ioh
, SEEQ_RX_PTR
) != 0x1234) {
189 sc
->sc_flags
|= SF_8BIT
;
190 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_RX_PTR
, 0x1234);
191 if (SEEQ_READ16(sc
, iot
, ioh
, SEEQ_RX_PTR
) != 0x1234) {
193 aprint_error_dev(&sc
->sc_dev
, "Cannot determine data bus width\n");
198 printf(", %d-bit", sc
->sc_flags
& SF_8BIT
? 8 : 16);
200 /* Get the product ID */
202 ea_select_buffer(sc
, SEEQ_BUFCODE_PRODUCTID
);
203 id
= SEEQ_READ16(sc
, sc
->sc_iot
, sc
->sc_ioh
, SEEQ_BUFWIN
);
205 switch (id
& SEEQ_PRODUCTID_MASK
) {
206 case SEEQ_PRODUCTID_8004
:
207 sc
->sc_variant
= SEEQ_8004
;
208 switch (id
& SEEQ_PRODUCTID_REV_MASK
) {
209 case SEEQ_PRODUCTID_REV_80C04
:
210 printf(", SEEQ 80C04\n");
212 case SEEQ_PRODUCTID_REV_80C04A
:
213 printf(", SEEQ 80C04A\n");
216 /* Unknown SEEQ 8004 variants */
217 printf(", SEEQ 8004 rev %x\n",
218 id
& SEEQ_PRODUCTID_REV_MASK
);
223 sc
->sc_variant
= SEEQ_8005
;
224 printf(", SEEQ 8005\n");
228 /* Both the 8004 and 8005 are designed for 64K Buffer memory */
229 sc
->sc_buffersize
= SEEQ_MAX_BUFFER_SIZE
;
232 * Set up tx and rx buffers.
234 * We use approximately a quarter of the packet memory for TX
235 * buffers and the rest for RX buffers
237 /* sc->sc_tx_bufs = sc->sc_buffersize / SEEQ_TX_BUFFER_SIZE / 4; */
239 sc
->sc_tx_bufsize
= sc
->sc_tx_bufs
* SEEQ_TX_BUFFER_SIZE
;
240 sc
->sc_rx_bufsize
= sc
->sc_buffersize
- sc
->sc_tx_bufsize
;
246 printf("%s: %dKB packet memory, txbuf=%dKB (%d buffers), rxbuf=%dKB",
247 device_xname(&sc
->sc_dev
), sc
->sc_buffersize
>> 10,
248 sc
->sc_tx_bufsize
>> 10, sc
->sc_tx_bufs
, sc
->sc_rx_bufsize
>> 10);
250 if (padbuf
== NULL
) {
251 padbuf
= malloc(ETHER_MIN_LEN
- ETHER_CRC_LEN
, M_DEVBUF
,
253 if (padbuf
== NULL
) {
254 aprint_error_dev(&sc
->sc_dev
, "can't allocate pad buffer\n");
259 /* Initialise ifnet structure. */
261 strlcpy(ifp
->if_xname
, device_xname(&sc
->sc_dev
), IFNAMSIZ
);
263 ifp
->if_start
= ea_start
;
264 ifp
->if_ioctl
= ea_ioctl
;
265 ifp
->if_init
= ea_init
;
266 ifp
->if_stop
= ea_stop
;
267 ifp
->if_watchdog
= ea_watchdog
;
268 ifp
->if_flags
= IFF_BROADCAST
| IFF_MULTICAST
| IFF_NOTRAILERS
;
269 if (sc
->sc_variant
== SEEQ_8004
)
270 ifp
->if_flags
|= IFF_SIMPLEX
;
271 IFQ_SET_READY(&ifp
->if_snd
);
273 /* Initialize media goo. */
274 ifmedia_init(&sc
->sc_media
, 0, ea_mediachange
, ea_mediastatus
);
278 for (i
= 0; i
< nmedia
; i
++)
279 ifmedia_add(&sc
->sc_media
, media
[i
], 0, NULL
);
280 ifmedia_set(&sc
->sc_media
, defmedia
);
282 ifmedia_add(&sc
->sc_media
, IFM_ETHER
|IFM_MANUAL
, 0, NULL
);
283 ifmedia_set(&sc
->sc_media
, IFM_ETHER
|IFM_MANUAL
);
286 /* We can support 802.1Q VLAN-sized frames. */
287 sc
->sc_ethercom
.ec_capabilities
|= ETHERCAP_VLAN_MTU
;
289 /* Now we can attach the interface. */
292 ether_ifattach(ifp
, myaddr
);
297 /* After \n because it can print a line of its own. */
298 rnd_attach_source(&sc
->rnd_source
, device_xname(&sc
->sc_dev
),
304 * Media change callback.
307 ea_mediachange(struct ifnet
*ifp
)
309 struct seeq8005_softc
*sc
= ifp
->if_softc
;
311 if (sc
->sc_mediachange
)
312 return ((*sc
->sc_mediachange
)(sc
));
317 * Media status callback.
320 ea_mediastatus(struct ifnet
*ifp
, struct ifmediareq
*ifmr
)
322 struct seeq8005_softc
*sc
= ifp
->if_softc
;
324 if (sc
->sc_enabled
== 0) {
325 ifmr
->ifm_active
= IFM_ETHER
| IFM_NONE
;
326 ifmr
->ifm_status
= 0;
330 if (sc
->sc_mediastatus
)
331 (*sc
->sc_mediastatus
)(sc
, ifmr
);
335 * Test the RAM on the ethernet card.
339 ea_ramtest(struct seeq8005_softc
*sc
)
341 bus_space_tag_t iot
= sc
->sc_iot
;
342 bus_space_handle_t ioh
= sc
->sc_ioh
;
347 * Test the buffer memory on the board.
348 * Write simple pattens to it and read them back.
351 /* Set up the whole buffer RAM for writing */
353 ea_select_buffer(sc
, SEEQ_BUFCODE_TX_EAP
);
354 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_BUFWIN
, (SEEQ_MAX_BUFFER_SIZE
>> 8) - 1);
355 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_TX_PTR
, 0x0000);
356 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_RX_PTR
, SEEQ_MAX_BUFFER_SIZE
- 2);
358 #define SEEQ_RAMTEST_LOOP(value) \
360 /* Set the write start address and write a pattern */ \
361 ea_writebuf(sc, NULL, 0x0000, 0); \
362 for (loop = 0; loop < SEEQ_MAX_BUFFER_SIZE; loop += 2) \
363 SEEQ_WRITE16(sc, iot, ioh, SEEQ_BUFWIN, (value)); \
365 /* Set the read start address and verify the pattern */ \
366 ea_readbuf(sc, NULL, 0x0000, 0); \
367 for (loop = 0; loop < SEEQ_MAX_BUFFER_SIZE; loop += 2) \
368 if (SEEQ_READ16(sc, iot, ioh, SEEQ_BUFWIN) != (value)) \
370 } while (/*CONSTCOND*/0)
372 SEEQ_RAMTEST_LOOP(loop
);
373 SEEQ_RAMTEST_LOOP(loop
^ (SEEQ_MAX_BUFFER_SIZE
- 1));
374 SEEQ_RAMTEST_LOOP(0xaa55);
375 SEEQ_RAMTEST_LOOP(0x55aa);
380 aprint_error_dev(&sc
->sc_dev
, "buffer RAM failed self test, %d faults\n", sum
);
385 * Stop the tx interface.
387 * Returns 0 if the tx was already stopped or 1 if it was active
391 ea_stoptx(struct seeq8005_softc
*sc
)
393 bus_space_tag_t iot
= sc
->sc_iot
;
394 bus_space_handle_t ioh
= sc
->sc_ioh
;
398 DPRINTF(SEEQ_DEBUG_TX
, ("ea_stoptx()\n"));
402 status
= SEEQ_READ16(sc
, iot
, ioh
, SEEQ_STATUS
);
403 if (!(status
& SEEQ_STATUS_TX_ON
))
406 /* Stop any tx and wait for confirmation */
407 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_COMMAND
,
408 sc
->sc_command
| SEEQ_CMD_TX_OFF
);
412 status
= SEEQ_READ16(sc
, iot
, ioh
, SEEQ_STATUS
);
414 } while ((status
& SEEQ_STATUS_TX_ON
) && --timeout
> 0);
416 log(LOG_ERR
, "%s: timeout waiting for tx termination\n",
417 device_xname(&sc
->sc_dev
));
419 /* Clear any pending tx interrupt */
420 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_COMMAND
,
421 sc
->sc_command
| SEEQ_CMD_TX_INTACK
);
427 * Stop the rx interface.
429 * Returns 0 if the tx was already stopped or 1 if it was active
433 ea_stoprx(struct seeq8005_softc
*sc
)
435 bus_space_tag_t iot
= sc
->sc_iot
;
436 bus_space_handle_t ioh
= sc
->sc_ioh
;
440 DPRINTF(SEEQ_DEBUG_RX
, ("ea_stoprx()\n"));
442 status
= SEEQ_READ16(sc
, iot
, ioh
, SEEQ_STATUS
);
443 if (!(status
& SEEQ_STATUS_RX_ON
))
446 /* Stop any rx and wait for confirmation */
448 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_COMMAND
,
449 sc
->sc_command
| SEEQ_CMD_RX_OFF
);
453 status
= SEEQ_READ16(sc
, iot
, ioh
, SEEQ_STATUS
);
454 } while ((status
& SEEQ_STATUS_RX_ON
) && --timeout
> 0);
456 log(LOG_ERR
, "%s: timeout waiting for rx termination\n",
457 device_xname(&sc
->sc_dev
));
459 /* Clear any pending rx interrupt */
461 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_COMMAND
,
462 sc
->sc_command
| SEEQ_CMD_RX_INTACK
);
469 * Stop all IO and shut the interface down
474 ea_stop(struct ifnet
*ifp
, int disable
)
476 struct seeq8005_softc
*sc
= ifp
->if_softc
;
477 bus_space_tag_t iot
= sc
->sc_iot
;
478 bus_space_handle_t ioh
= sc
->sc_ioh
;
480 DPRINTF(SEEQ_DEBUG_MISC
, ("ea_stop()\n"));
486 /* Disable rx and tx interrupts */
487 sc
->sc_command
&= (SEEQ_CMD_RX_INTEN
| SEEQ_CMD_TX_INTEN
);
489 /* Clear any pending interrupts */
490 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_COMMAND
,
491 sc
->sc_command
| SEEQ_CMD_RX_INTACK
|
492 SEEQ_CMD_TX_INTACK
| SEEQ_CMD_DMA_INTACK
|
495 if (sc
->sc_variant
== SEEQ_8004
) {
496 /* Put the chip to sleep */
497 ea_select_buffer(sc
, SEEQ_BUFCODE_CONFIG3
);
498 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_BUFWIN
,
499 sc
->sc_config3
| SEEQ_CFG3_SLEEP
);
502 /* Cancel any watchdog timer */
503 sc
->sc_ethercom
.ec_if
.if_timer
= 0;
509 * Following this the software registers are reset
513 ea_chipreset(struct seeq8005_softc
*sc
)
515 bus_space_tag_t iot
= sc
->sc_iot
;
516 bus_space_handle_t ioh
= sc
->sc_ioh
;
518 DPRINTF(SEEQ_DEBUG_MISC
, ("ea_chipreset()\n"));
520 /* Reset the controller. Min of 4us delay here */
523 * This can be called before we know whether the chip is in 8- or
524 * 16-bit mode, so we do a reset in both modes. The 16-bit reset is
525 * harmless in 8-bit mode, so we do that second.
528 /* In 16-bit mode, this will munge the PreamSelect bit. */
529 bus_space_write_1(iot
, ioh
, SEEQ_CONFIG2
+ 1, SEEQ_CFG2_RESET
>> 8);
531 /* In 8-bit mode, this will zero the bottom half of config reg 2. */
532 bus_space_write_2(iot
, ioh
, SEEQ_CONFIG2
, SEEQ_CFG2_RESET
);
543 * If the DMA FIFO's in write mode, wait for it to empty. Needed when
544 * switching the FIFO from write to read. We also use it when changing
545 * the address for writes.
548 ea_await_fifo_empty(struct seeq8005_softc
*sc
)
550 bus_space_tag_t iot
= sc
->sc_iot
;
551 bus_space_handle_t ioh
= sc
->sc_ioh
;
555 if ((SEEQ_READ16(sc
, iot
, ioh
, SEEQ_STATUS
) &
556 SEEQ_STATUS_FIFO_DIR
) != 0)
557 return; /* FIFO is reading anyway. */
558 while (--timeout
> 0)
559 if (SEEQ_READ16(sc
, iot
, ioh
, SEEQ_STATUS
) &
560 SEEQ_STATUS_FIFO_EMPTY
)
562 log(LOG_ERR
, "%s: DMA FIFO failed to empty\n", device_xname(&sc
->sc_dev
));
566 * Wait for the DMA FIFO to fill before reading from it.
569 ea_await_fifo_full(struct seeq8005_softc
*sc
)
571 bus_space_tag_t iot
= sc
->sc_iot
;
572 bus_space_handle_t ioh
= sc
->sc_ioh
;
576 while (--timeout
> 0)
577 if (SEEQ_READ16(sc
, iot
, ioh
, SEEQ_STATUS
) &
578 SEEQ_STATUS_FIFO_FULL
)
580 log(LOG_ERR
, "%s: DMA FIFO failed to fill\n", device_xname(&sc
->sc_dev
));
584 * write to the buffer memory on the interface
586 * The buffer address is set to ADDR.
587 * If len != 0 then data is copied from the address starting at buf
588 * to the interface buffer.
589 * BUF must be usable as a u_int16_t *.
590 * If LEN is odd, it must be safe to overwrite one extra byte.
594 ea_writebuf(struct seeq8005_softc
*sc
, u_char
*buf
, int addr
, size_t len
)
596 bus_space_tag_t iot
= sc
->sc_iot
;
597 bus_space_handle_t ioh
= sc
->sc_ioh
;
599 DPRINTF(SEEQ_DEBUG_MISC
, ("writebuf: st=%04x\n",
600 SEEQ_READ16(sc
, iot
, ioh
, SEEQ_STATUS
)));
603 if (__predict_false(!ALIGNED_POINTER(buf
, u_int16_t
)))
604 panic("%s: unaligned writebuf", device_xname(&sc
->sc_dev
));
605 if (__predict_false(addr
>= SEEQ_MAX_BUFFER_SIZE
))
606 panic("%s: writebuf out of range", device_xname(&sc
->sc_dev
));
610 ea_await_fifo_empty(sc
);
612 ea_select_buffer(sc
, SEEQ_BUFCODE_LOCAL_MEM
);
613 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_COMMAND
,
614 sc
->sc_command
| SEEQ_CMD_FIFO_WRITE
);
615 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_DMA_ADDR
, addr
);
619 if (sc
->sc_flags
& SF_8BIT
)
620 bus_space_write_multi_1(iot
, ioh
, SEEQ_BUFWIN
,
621 (u_int8_t
*)buf
, len
);
623 bus_space_write_multi_2(iot
, ioh
, SEEQ_BUFWIN
,
624 /* LINTED: alignment checked above */
625 (u_int16_t
*)buf
, len
/ 2);
627 if (!(sc
->sc_flags
& SF_8BIT
) && len
% 2) {
628 /* Write the last byte */
629 bus_space_write_2(iot
, ioh
, SEEQ_BUFWIN
, buf
[len
- 1]);
631 /* Leave FIFO to empty in the background */
636 * read from the buffer memory on the interface
638 * The buffer address is set to ADDR.
639 * If len != 0 then data is copied from the interface buffer to the
640 * address starting at buf.
641 * BUF must be usable as a u_int16_t *.
642 * If LEN is odd, it must be safe to overwrite one extra byte.
646 ea_readbuf(struct seeq8005_softc
*sc
, u_char
*buf
, int addr
, size_t len
)
648 bus_space_tag_t iot
= sc
->sc_iot
;
649 bus_space_handle_t ioh
= sc
->sc_ioh
;
652 DPRINTF(SEEQ_DEBUG_MISC
, ("readbuf: st=%04x addr=%04x len=%d\n",
653 SEEQ_READ16(sc
, iot
, ioh
, SEEQ_STATUS
), addr
, len
));
656 if (__predict_false(!ALIGNED_POINTER(buf
, u_int16_t
)))
657 panic("%s: unaligned readbuf", device_xname(&sc
->sc_dev
));
658 if (__predict_false(addr
>= SEEQ_MAX_BUFFER_SIZE
))
659 panic("%s: readbuf out of range", device_xname(&sc
->sc_dev
));
665 * Starting reading from certain addresses seems to cause
666 * us to get bogus results, so we avoid them.
669 if (sc
->sc_variant
== SEEQ_8004
&&
670 ((addr
& 0x00ff) == 0x00ea ||
671 (addr
& 0x00ff) == 0x00ee ||
672 (addr
& 0x00ff) == 0x00f0))
673 runup
= (addr
& 0x00ff) - 0x00e8;
675 ea_await_fifo_empty(sc
);
677 ea_select_buffer(sc
, SEEQ_BUFCODE_LOCAL_MEM
);
680 * 80C04 bug workaround. I found this in the old arm32 "eb"
681 * driver. I've no idea what it does, but it seems to stop
682 * the chip mangling data so often.
684 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_COMMAND
,
685 sc
->sc_command
| SEEQ_CMD_FIFO_WRITE
);
686 ea_await_fifo_empty(sc
);
688 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_DMA_ADDR
, addr
- runup
);
689 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_COMMAND
,
690 sc
->sc_command
| SEEQ_CMD_FIFO_READ
);
692 ea_await_fifo_full(sc
);
694 /* LINTED: Reading a volatile _does_ have an effect */
695 (void)SEEQ_READ16(sc
, iot
, ioh
, SEEQ_BUFWIN
);
701 if (sc
->sc_flags
& SF_8BIT
)
702 bus_space_read_multi_1(iot
, ioh
, SEEQ_BUFWIN
,
703 (u_int8_t
*)buf
, len
);
705 bus_space_read_multi_2(iot
, ioh
, SEEQ_BUFWIN
,
706 /* LINTED: pointer alignment checked above */
707 (u_int16_t
*)buf
, len
/ 2);
709 if (!(sc
->sc_flags
& SF_8BIT
) && len
% 2) {
710 /* Read the last byte */
711 buf
[len
- 1] = bus_space_read_2(iot
, ioh
, SEEQ_BUFWIN
);
716 ea_select_buffer(struct seeq8005_softc
*sc
, int bufcode
)
719 SEEQ_WRITE16(sc
, sc
->sc_iot
, sc
->sc_ioh
, SEEQ_CONFIG1
,
720 sc
->sc_config1
| bufcode
);
723 /* Must be called at splnet */
725 ea_set_address(struct seeq8005_softc
*sc
, int which
, const u_int8_t
*ea
)
729 ea_select_buffer(sc
, SEEQ_BUFCODE_STATION_ADDR0
+ which
);
730 for (i
= 0; i
< ETHER_ADDR_LEN
; ++i
)
731 SEEQ_WRITE16(sc
, sc
->sc_iot
, sc
->sc_ioh
, SEEQ_BUFWIN
,
736 * Initialize interface.
738 * This should leave the interface in a state for packet reception and
743 ea_init(struct ifnet
*ifp
)
745 struct seeq8005_softc
*sc
= ifp
->if_softc
;
746 bus_space_tag_t iot
= sc
->sc_iot
;
747 bus_space_handle_t ioh
= sc
->sc_ioh
;
750 DPRINTF(SEEQ_DEBUG_MISC
, ("ea_init()\n"));
754 /* First, reset the board. */
758 /* Set up defaults for the registers */
762 #if BYTE_ORDER == BIG_ENDIAN
763 sc
->sc_config2
= SEEQ_CFG2_BYTESWAP
;
769 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_COMMAND
, sc
->sc_command
);
770 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_CONFIG1
, sc
->sc_config1
);
771 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_CONFIG2
, sc
->sc_config2
);
772 if (sc
->sc_variant
== SEEQ_8004
) {
773 ea_select_buffer(sc
, SEEQ_BUFCODE_CONFIG3
);
774 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_BUFWIN
, sc
->sc_config3
);
777 /* Write the station address - the receiver must be off */
778 ea_set_address(sc
, 0, (const u_int8_t
*)CLLADDR(ifp
->if_sadl
));
780 /* Split board memory into Rx and Tx. */
781 ea_select_buffer(sc
, SEEQ_BUFCODE_TX_EAP
);
782 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_BUFWIN
, (sc
->sc_tx_bufsize
>> 8) - 1);
784 if (sc
->sc_variant
== SEEQ_8004
) {
785 /* Make the interface IFF_SIMPLEX. */
786 sc
->sc_config2
|= SEEQ_CFG2_RX_TX_DISABLE
;
787 /* Enable reception of long packets (for vlan(4)). */
788 sc
->sc_config2
|= SEEQ_CFG2_PASS_LONGSHORT
;
793 if (ifp
->if_flags
& IFF_PROMISC
)
794 sc
->sc_config1
= SEEQ_CFG1_PROMISCUOUS
;
795 else if ((ifp
->if_flags
& IFF_ALLMULTI
) || sc
->sc_variant
== SEEQ_8004
)
796 sc
->sc_config1
= SEEQ_CFG1_MULTICAST
;
798 sc
->sc_config1
= SEEQ_CFG1_BROADCAST
;
799 sc
->sc_config1
|= SEEQ_CFG1_STATION_ADDR0
;
800 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_CONFIG1
, sc
->sc_config1
);
802 /* Setup the Rx pointers */
803 sc
->sc_rx_ptr
= sc
->sc_tx_bufsize
;
805 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_RX_PTR
, sc
->sc_rx_ptr
);
806 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_RX_END
, sc
->sc_rx_ptr
>> 8);
809 /* Place a NULL header at the beginning of the receive area */
810 ea_writebuf(sc
, NULL
, sc
->sc_rx_ptr
, 0);
812 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_BUFWIN
, 0x0000);
813 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_BUFWIN
, 0x0000);
817 DPRINTF(SEEQ_DEBUG_MISC
, ("Configuring tx...\n"));
819 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_TX_PTR
, 0x0000);
821 sc
->sc_config2
|= SEEQ_CFG2_OUTPUT
;
822 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_CONFIG2
, sc
->sc_config2
);
824 /* Reset tx buffer pointers */
829 /* Place a NULL header at the beginning of the transmit area */
830 ea_writebuf(sc
, NULL
, 0x0000, 0);
832 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_BUFWIN
, 0x0000);
833 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_BUFWIN
, 0x0000);
835 sc
->sc_command
|= SEEQ_CMD_TX_INTEN
;
836 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_COMMAND
, sc
->sc_command
);
839 sc
->sc_command
|= SEEQ_CMD_RX_INTEN
;
840 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_COMMAND
,
841 sc
->sc_command
| SEEQ_CMD_RX_ON
);
843 /* TX_ON gets set by ea_txpacket when there's something to transmit. */
846 /* Set flags appropriately. */
847 ifp
->if_flags
|= IFF_RUNNING
;
848 ifp
->if_flags
&= ~IFF_OACTIVE
;
851 /* And start output. */
859 * Start output on interface. Get datagrams from the queue and output them,
860 * giving the receiver a chance between datagrams. Call only from splnet or
865 ea_start(struct ifnet
*ifp
)
867 struct seeq8005_softc
*sc
= ifp
->if_softc
;
871 DPRINTF(SEEQ_DEBUG_TX
, ("ea_start()...\n"));
874 * Don't do anything if output is active. seeq8005intr() will call
875 * us (actually eatxpacket()) back when the card's ready for more
878 if (ifp
->if_flags
& IFF_OACTIVE
)
881 /* Mark interface as output active */
883 ifp
->if_flags
|= IFF_OACTIVE
;
893 * Transfer a packet to the interface buffer and start transmission
899 eatxpacket(struct seeq8005_softc
*sc
)
901 bus_space_tag_t iot
= sc
->sc_iot
;
902 bus_space_handle_t ioh
= sc
->sc_ioh
;
906 ifp
= &sc
->sc_ethercom
.ec_if
;
908 /* Dequeue the next packet. */
909 IFQ_DEQUEUE(&ifp
->if_snd
, m0
);
911 /* If there's nothing to send, return. */
913 ifp
->if_flags
&= ~IFF_OACTIVE
;
914 sc
->sc_config2
|= SEEQ_CFG2_OUTPUT
;
915 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_CONFIG2
, sc
->sc_config2
);
916 DPRINTF(SEEQ_DEBUG_TX
, ("tx finished\n"));
921 /* Give the packet to the bpf, if any. */
923 bpf_mtap(ifp
->if_bpf
, m0
);
926 DPRINTF(SEEQ_DEBUG_TX
, ("Tx new packet\n"));
928 sc
->sc_config2
&= ~SEEQ_CFG2_OUTPUT
;
929 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_CONFIG2
, sc
->sc_config2
);
931 ea_writembuf(sc
, m0
, 0x0000);
934 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_TX_PTR
, 0x0000);
936 /* Now transmit the datagram. */
937 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_COMMAND
,
938 sc
->sc_command
| SEEQ_CMD_TX_ON
);
940 /* Make sure we notice if the chip goes silent on us. */
943 DPRINTF(SEEQ_DEBUG_TX
,
944 ("st=%04x\n", SEEQ_READ16(sc
, iot
, ioh
, SEEQ_STATUS
)));
945 DPRINTF(SEEQ_DEBUG_TX
, ("tx: queued\n"));
949 * Copy a packet from an mbuf to the transmit buffer on the card.
951 * Puts a valid Tx header at the start of the packet, and a null header at
955 ea_writembuf(struct seeq8005_softc
*sc
, struct mbuf
*m0
, int bufstart
)
962 * Copy the datagram to the packet buffer.
965 for (m
= m0
; m
; m
= m
->m_next
) {
968 ea_writebuf(sc
, mtod(m
, u_char
*), bufstart
+ 4 + len
,
973 if (len
< ETHER_MIN_LEN
) {
974 ea_writebuf(sc
, padbuf
, bufstart
+ 4 + len
,
975 ETHER_MIN_LEN
- len
);
979 /* Follow it with a NULL packet header */
981 ea_writebuf(sc
, hdr
, bufstart
+ 4 + len
, 4);
982 SEEQ_WRITE16(sc
, sc
->sc_iot
, sc
->sc_ioh
, SEEQ_BUFWIN
, 0x0000);
983 SEEQ_WRITE16(sc
, sc
->sc_iot
, sc
->sc_ioh
, SEEQ_BUFWIN
, 0x0000);
985 /* Ok we now have a packet len bytes long in our packet buffer */
986 DPRINTF(SEEQ_DEBUG_TX
, ("ea_writembuf: length=%d\n", len
));
988 /* Write the packet header */
989 nextpacket
= len
+ 4;
990 hdr
[0] = (nextpacket
>> 8) & 0xff;
991 hdr
[1] = nextpacket
& 0xff;
992 hdr
[2] = SEEQ_PKTCMD_TX
| SEEQ_PKTCMD_DATA_FOLLOWS
|
993 SEEQ_TXCMD_XMIT_SUCCESS_INT
| SEEQ_TXCMD_COLLISION_INT
;
994 hdr
[3] = 0; /* Status byte -- will be update by hardware. */
995 ea_writebuf(sc
, hdr
, 0x0000, 4);
1001 * Ethernet controller interrupt.
1005 seeq8005intr(void *arg
)
1007 struct seeq8005_softc
*sc
= arg
;
1008 bus_space_tag_t iot
= sc
->sc_iot
;
1009 bus_space_handle_t ioh
= sc
->sc_ioh
;
1010 int status
, handled
;
1014 /* Get the controller status */
1015 status
= SEEQ_READ16(sc
, iot
, ioh
, SEEQ_STATUS
);
1017 /* Tx interrupt ? */
1018 if (status
& SEEQ_STATUS_TX_INT
) {
1021 /* Acknowledge the interrupt */
1022 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_COMMAND
,
1023 sc
->sc_command
| SEEQ_CMD_TX_INTACK
);
1029 /* Rx interrupt ? */
1030 if (status
& SEEQ_STATUS_RX_INT
) {
1033 /* Acknowledge the interrupt */
1034 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_COMMAND
,
1035 sc
->sc_command
| SEEQ_CMD_RX_INTACK
);
1037 /* Processes the received packets */
1043 rnd_add_uint32(&sc
->rnd_source
, status
);
1049 ea_txint(struct seeq8005_softc
*sc
)
1051 struct ifnet
*ifp
= &sc
->sc_ethercom
.ec_if
;
1052 bus_space_tag_t iot
= sc
->sc_iot
;
1053 bus_space_handle_t ioh
= sc
->sc_ioh
;
1057 ea_readbuf(sc
, txhdr
, 0x0000, 4);
1059 DPRINTF(SEEQ_DEBUG_TX
, ("txstatus=%02x %02x %02x %02x\n",
1060 txhdr
[0], txhdr
[1], txhdr
[2], txhdr
[3]));
1061 txstatus
= txhdr
[3];
1064 * If SEEQ_TXSTAT_COLLISION is set then we received at least
1065 * one collision. On the 8004 we can find out exactly how many
1066 * collisions occurred.
1068 * The SEEQ_PKTSTAT_DONE will be set if the transmission has
1071 * If SEEQ_TXSTAT_COLLISION16 is set then 16 collisions
1072 * occurred and the packet transmission was aborted.
1073 * This situation is untested as present.
1075 * The SEEQ_TXSTAT_BABBLE is untested as it should only be set
1076 * when we deliberately transmit oversized packets (e.g. for
1079 if (txstatus
& SEEQ_TXSTAT_COLLISION
) {
1080 switch (sc
->sc_variant
) {
1085 * The 8004 contains a 4 bit collision count
1086 * in the status register.
1089 /* This appears to be broken on 80C04.AE */
1090 /* ifp->if_collisions +=
1091 (txstatus >> SEEQ_TXSTAT_COLLISIONS_SHIFT)
1092 & SEEQ_TXSTAT_COLLISION_MASK;*/
1094 /* Use the TX Collision register */
1095 ea_select_buffer(sc
, SEEQ_BUFCODE_TX_COLLS
);
1096 colls
= bus_space_read_1(iot
, ioh
, SEEQ_BUFWIN
);
1097 ifp
->if_collisions
+= colls
;
1101 /* We known there was at least 1 collision */
1102 ifp
->if_collisions
++;
1105 } else if (txstatus
& SEEQ_TXSTAT_COLLISION16
) {
1106 printf("seeq_intr: col16 %x\n", txstatus
);
1107 ifp
->if_collisions
+= 16;
1111 /* Have we completed transmission on the packet ? */
1112 if (txstatus
& SEEQ_PKTSTAT_DONE
) {
1113 /* Clear watchdog timer. */
1115 ifp
->if_flags
&= ~IFF_OACTIVE
;
1120 /* Tx next packet */
1127 ea_rxint(struct seeq8005_softc
*sc
)
1129 bus_space_tag_t iot
= sc
->sc_iot
;
1130 bus_space_handle_t ioh
= sc
->sc_ioh
;
1139 ifp
= &sc
->sc_ethercom
.ec_if
;
1142 /* We start from the last rx pointer position */
1143 addr
= sc
->sc_rx_ptr
;
1144 sc
->sc_config2
&= ~SEEQ_CFG2_OUTPUT
;
1145 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_CONFIG2
, sc
->sc_config2
);
1148 /* Read rx header */
1149 ea_readbuf(sc
, rxhdr
, addr
, 4);
1151 /* Split the packet header */
1152 ptr
= (rxhdr
[0] << 8) | rxhdr
[1];
1156 DPRINTF(SEEQ_DEBUG_RX
,
1157 ("addr=%04x ptr=%04x ctrl=%02x status=%02x\n",
1158 addr
, ptr
, ctrl
, status
));
1160 /* Zero packet ptr ? then must be null header so exit */
1161 if (ptr
== 0) break;
1163 /* Sanity-check the next-packet pointer and flags. */
1164 if (__predict_false(ptr
< sc
->sc_tx_bufsize
||
1165 (ctrl
& SEEQ_PKTCMD_TX
))) {
1168 "%s: Rx chain corrupt at %04x (ptr = %04x)\n",
1169 device_xname(&sc
->sc_dev
), addr
, ptr
);
1174 /* Get packet length */
1175 len
= (ptr
- addr
) - 4;
1178 len
+= sc
->sc_rx_bufsize
;
1179 DPRINTF(SEEQ_DEBUG_RX
, ("len=%04x\n", len
));
1181 /* Has the packet rx completed ? if not then exit */
1182 if ((status
& SEEQ_PKTSTAT_DONE
) == 0)
1186 * Did we have any errors? then note error and go to
1189 if (__predict_false(status
&
1190 (SEEQ_RXSTAT_CRC_ERROR
| SEEQ_RXSTAT_DRIBBLE_ERROR
|
1191 SEEQ_RXSTAT_SHORT_FRAME
))) {
1194 "%s: rx packet error at %04x (err=%02x)\n",
1195 device_xname(&sc
->sc_dev
), addr
, status
& 0x0f);
1196 /* XXX shouldn't need to reset if it's genuine. */
1201 * Is the packet too big? We allow slightly oversize packets
1202 * for vlan(4) and tcpdump purposes, but the rest of the world
1203 * wants incoming packets in a single mbuf cluster.
1205 if (__predict_false(len
> MCLBYTES
)) {
1208 "%s: rx packet size error at %04x (len=%d)\n",
1209 device_xname(&sc
->sc_dev
), addr
, len
);
1210 sc
->sc_config2
|= SEEQ_CFG2_OUTPUT
;
1211 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_CONFIG2
,
1218 /* Pass data up to upper levels. */
1219 ea_read(sc
, addr
+ 4, len
);
1224 sc
->sc_config2
|= SEEQ_CFG2_OUTPUT
;
1225 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_CONFIG2
, sc
->sc_config2
);
1227 DPRINTF(SEEQ_DEBUG_RX
, ("new rx ptr=%04x\n", addr
));
1229 /* Store new rx pointer */
1230 sc
->sc_rx_ptr
= addr
;
1231 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_RX_END
, sc
->sc_rx_ptr
>> 8);
1233 /* Make sure the receiver is on */
1234 SEEQ_WRITE16(sc
, iot
, ioh
, SEEQ_COMMAND
,
1235 sc
->sc_command
| SEEQ_CMD_RX_ON
);
1240 * Pass a packet up to the higher levels.
1244 ea_read(struct seeq8005_softc
*sc
, int addr
, int len
)
1249 ifp
= &sc
->sc_ethercom
.ec_if
;
1251 /* Pull packet off interface. */
1252 m
= ea_get(sc
, addr
, len
, ifp
);
1258 * Check if there's a BPF listener on this interface.
1259 * If so, hand off the raw packet to bpf.
1262 bpf_mtap(ifp
->if_bpf
, m
);
1265 (*ifp
->if_input
)(ifp
, m
);
1269 * Pull read data off a interface. Len is length of data, with local net
1270 * header stripped. We copy the data into mbufs. When full cluster sized
1271 * units are present we copy into clusters.
1275 ea_get(struct seeq8005_softc
*sc
, int addr
, int totlen
, struct ifnet
*ifp
)
1277 struct mbuf
*top
, **mp
, *m
;
1284 MGETHDR(m
, M_DONTWAIT
, MT_DATA
);
1287 m
->m_pkthdr
.rcvif
= ifp
;
1288 m
->m_pkthdr
.len
= totlen
;
1293 while (totlen
> 0) {
1295 MGET(m
, M_DONTWAIT
, MT_DATA
);
1302 len
= min(totlen
, epkt
- cp
);
1303 if (len
>= MINCLSIZE
) {
1304 MCLGET(m
, M_DONTWAIT
);
1305 if (m
->m_flags
& M_EXT
)
1306 m
->m_len
= len
= min(len
, MCLBYTES
);
1311 * Place initial small packet/header at end of mbuf.
1313 if (len
< m
->m_len
) {
1314 if (top
== 0 && len
+ max_linkhdr
<= m
->m_len
)
1315 m
->m_data
+= max_linkhdr
;
1321 /* Make sure the payload is aligned */
1322 char *newdata
= (char *)
1323 ALIGN((char*)m
->m_data
+
1324 sizeof(struct ether_header
)) -
1325 sizeof(struct ether_header
);
1326 len
-= newdata
- m
->m_data
;
1328 m
->m_data
= newdata
;
1330 ea_readbuf(sc
, mtod(m
, u_char
*),
1331 cp
< SEEQ_MAX_BUFFER_SIZE
? cp
: cp
- sc
->sc_rx_bufsize
,
1345 * Process an ioctl request. Mostly boilerplate.
1348 ea_ioctl(struct ifnet
*ifp
, u_long cmd
, void *data
)
1350 struct seeq8005_softc
*sc
= ifp
->if_softc
;
1357 error
= ether_ioctl(ifp
, cmd
, data
);
1358 if (error
== ENETRESET
) {
1360 * Multicast list has changed; set the hardware filter
1363 if (ifp
->if_flags
& IFF_RUNNING
)
1374 /* Must be called at splnet() */
1377 ea_mc_reset(struct seeq8005_softc
*sc
)
1380 switch (sc
->sc_variant
) {
1382 ea_mc_reset_8004(sc
);
1385 ea_mc_reset_8005(sc
);
1391 ea_mc_reset_8004(struct seeq8005_softc
*sc
)
1393 struct ethercom
*ec
= &sc
->sc_ethercom
;
1394 struct ifnet
*ifp
= &ec
->ec_if
;
1395 struct ether_multi
*enm
;
1398 struct ether_multistep step
;
1402 * Set up multicast address filter by passing all multicast addresses
1403 * through a crc generator, and then using bits 2 - 7 as an index
1404 * into the 64 bit logical address filter. The high order bits
1405 * selects the word, while the rest of the bits select the bit within
1409 if (ifp
->if_flags
& IFF_PROMISC
) {
1410 ifp
->if_flags
|= IFF_ALLMULTI
;
1411 for (i
= 0; i
< 8; i
++)
1415 for (i
= 0; i
< 8; i
++)
1417 ETHER_FIRST_MULTI(step
, ec
, enm
);
1418 while (enm
!= NULL
) {
1419 if (memcmp(enm
->enm_addrlo
, enm
->enm_addrhi
,
1420 sizeof(enm
->enm_addrlo
)) != 0) {
1422 * We must listen to a range of multicast addresses.
1423 * For now, just accept all multicasts, rather than
1424 * trying to set only those filter bits needed to match
1425 * the range. (At this time, the only use of address
1426 * ranges is for IP multicast routing, for which the
1427 * range is big enough to require all bits set.)
1429 ifp
->if_flags
|= IFF_ALLMULTI
;
1430 for (i
= 0; i
< 8; i
++)
1435 crc
= ether_crc32_be(enm
->enm_addrlo
, sizeof(enm
->enm_addrlo
));
1437 /* Just want the 6 most significant bits. */
1438 crc
= (crc
>> 2) & 0x3f;
1440 /* Turn on the corresponding bit in the filter. */
1441 af
[crc
>> 3] |= 1 << (crc
& 0x7);
1443 ETHER_NEXT_MULTI(step
, enm
);
1445 ifp
->if_flags
&= ~IFF_ALLMULTI
;
1447 ea_select_buffer(sc
, SEEQ_BUFCODE_MULTICAST
);
1448 for (i
= 0; i
< 8; ++i
)
1449 bus_space_write_1(sc
->sc_iot
, sc
->sc_ioh
,
1450 SEEQ_BUFWIN
, af
[i
]);
1454 ea_mc_reset_8005(struct seeq8005_softc
*sc
)
1456 struct ether_multi
*enm
;
1457 struct ether_multistep step
;
1458 int naddr
, maxaddrs
;
1462 ETHER_FIRST_MULTI(step
, &sc
->sc_ethercom
, enm
);
1463 while (enm
!= NULL
) {
1464 /* Have we got space? */
1465 if (naddr
>= maxaddrs
||
1466 memcmp(enm
->enm_addrlo
, enm
->enm_addrhi
, 6) != 0) {
1467 sc
->sc_ethercom
.ec_if
.if_flags
|= IFF_ALLMULTI
;
1468 ea_ioctl(&sc
->sc_ethercom
.ec_if
, SIOCSIFFLAGS
, NULL
);
1471 ea_set_address(sc
, 1 + naddr
, enm
->enm_addrlo
);
1472 sc
->sc_config1
|= SEEQ_CFG1_STATION_ADDR1
<< naddr
;
1474 ETHER_NEXT_MULTI(step
, enm
);
1476 for (; naddr
< maxaddrs
; naddr
++)
1477 sc
->sc_config1
&= ~(SEEQ_CFG1_STATION_ADDR1
<< naddr
);
1478 SEEQ_WRITE16(sc
, sc
->sc_iot
, sc
->sc_ioh
, SEEQ_CONFIG1
,
1483 * Device timeout routine.
1487 ea_watchdog(struct ifnet
*ifp
)
1489 struct seeq8005_softc
*sc
= ifp
->if_softc
;
1491 log(LOG_ERR
, "%s: lost Tx interrupt (status = 0x%04x)\n",
1492 device_xname(&sc
->sc_dev
),
1493 SEEQ_READ16(sc
, sc
->sc_iot
, sc
->sc_ioh
, SEEQ_STATUS
));
1496 /* Kick the interface */
1503 /* End of if_ea.c */