Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / alpha / a12 / if_adevar.h
blobaa8e5600beb38e798bd2dd58a076396f839658a8
1 /* $NetBSD: if_adevar.h,v 1.5 2007/03/04 05:59:08 christos Exp $ */
3 /*
4 * NOTE: this version of if_de was modified for bounce buffers prior
5 * to the introduction of bus_dma to netbsd. When a busified if_de
6 * is available and the a12 platform bus_dma is complete, then this
7 * module will be taken for a long walk on a short pier.
8 */
10 /* [Notice revision 2.0]
11 * Copyright (c) 1997 Avalon Computer Systems, Inc.
12 * All rights reserved.
14 * Author: Ross Harvey
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright and
20 * author notice, this list of conditions, and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. Neither the name of Avalon Computer Systems, Inc. nor the names of
25 * its contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 * 4. This copyright will be assigned to The NetBSD Foundation on
28 * 1/1/2000 unless these terms (including possibly the assignment
29 * date) are updated in writing by Avalon prior to the latest specified
30 * assignment date.
32 * THIS SOFTWARE IS PROVIDED BY AVALON COMPUTER SYSTEMS, INC. AND CONTRIBUTORS
33 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
34 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
35 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
36 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
37 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
40 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
41 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGE.
45 /*-
46 * Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
47 * All rights reserved.
49 * Redistribution and use in source and binary forms, with or without
50 * modification, are permitted provided that the following conditions
51 * are met:
52 * 1. Redistributions of source code must retain the above copyright
53 * notice, this list of conditions and the following disclaimer.
54 * 2. The name of the author may not be used to endorse or promote products
55 * derived from this software without specific prior written permission
57 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
58 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
59 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
60 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
61 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
63 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
64 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
65 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
66 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68 * Id: if_devar.h,v 1.20 1997/03/25 21:12:17 thomas Exp
71 #if !defined(_DEVAR_H)
72 #define _DEVAR_H
74 #if defined(__NetBSD__)
75 typedef bus_addr_t tulip_csrptr_t;
77 #define TULIP_CSR_READ(sc, csr) \
78 bus_space_read_4((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr)
79 #define TULIP_CSR_WRITE(sc, csr, val) \
80 bus_space_write_4((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr, (val))
82 #define TULIP_CSR_READBYTE(sc, csr) \
83 bus_space_read_1((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr)
84 #define TULIP_CSR_WRITEBYTE(sc, csr, val) \
85 bus_space_write_1((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr, (val))
86 #endif /* __NetBSD__ */
88 #ifdef TULIP_IOMAPPED
89 #define TULIP_EISA_CSRSIZE 16
90 #define TULIP_EISA_CSROFFSET 0
91 #define TULIP_PCI_CSRSIZE 8
92 #define TULIP_PCI_CSROFFSET 0
94 #if !defined(__NetBSD__)
95 typedef u_int16_t tulip_csrptr_t;
97 #define TULIP_CSR_READ(sc, csr) (inl((sc)->tulip_csrs.csr))
98 #define TULIP_CSR_WRITE(sc, csr, val) outl((sc)->tulip_csrs.csr, val)
100 #define TULIP_CSR_READBYTE(sc, csr) (inb((sc)->tulip_csrs.csr))
101 #define TULIP_CSR_WRITEBYTE(sc, csr, val) outb((sc)->tulip_csrs.csr, val)
102 #endif /* __NetBSD__ */
104 #else /* TULIP_IOMAPPED */
106 #define TULIP_PCI_CSRSIZE 8
107 #define TULIP_PCI_CSROFFSET 0
109 #if !defined(__NetBSD__)
110 typedef volatile u_int32_t *tulip_csrptr_t;
113 * macros to read and write CSRs. Note that the "0 +" in
114 * READ_CSR is to prevent the macro from being an lvalue
115 * and WRITE_CSR shouldn't be assigned from.
117 #define TULIP_CSR_READ(sc, csr) (0 + *(sc)->tulip_csrs.csr)
118 #define TULIP_CSR_WRITE(sc, csr, val) ((void)(*(sc)->tulip_csrs.csr = (val)))
119 #endif /* __NetBSD__ */
121 #endif /* TULIP_IOMAPPED */
124 * This structure contains "pointers" for the registers on
125 * the various 21x4x chips. CSR0 through CSR8 are common
126 * to all chips. After that, it gets messy...
128 typedef struct {
129 tulip_csrptr_t csr_busmode; /* CSR0 */
130 tulip_csrptr_t csr_txpoll; /* CSR1 */
131 tulip_csrptr_t csr_rxpoll; /* CSR2 */
132 tulip_csrptr_t csr_rxlist; /* CSR3 */
133 tulip_csrptr_t csr_txlist; /* CSR4 */
134 tulip_csrptr_t csr_status; /* CSR5 */
135 tulip_csrptr_t csr_command; /* CSR6 */
136 tulip_csrptr_t csr_intr; /* CSR7 */
137 tulip_csrptr_t csr_missed_frames; /* CSR8 */
138 tulip_csrptr_t csr_9; /* CSR9 */
139 tulip_csrptr_t csr_10; /* CSR10 */
140 tulip_csrptr_t csr_11; /* CSR11 */
141 tulip_csrptr_t csr_12; /* CSR12 */
142 tulip_csrptr_t csr_13; /* CSR13 */
143 tulip_csrptr_t csr_14; /* CSR14 */
144 tulip_csrptr_t csr_15; /* CSR15 */
145 } tulip_regfile_t;
147 #define csr_enetrom csr_9 /* 21040 */
148 #define csr_reserved csr_10 /* 21040 */
149 #define csr_full_duplex csr_11 /* 21040 */
150 #define csr_bootrom csr_10 /* 21041/21140A/?? */
151 #define csr_gp csr_12 /* 21140* */
152 #define csr_watchdog csr_15 /* 21140* */
153 #define csr_gp_timer csr_11 /* 21041/21140* */
154 #define csr_srom_mii csr_9 /* 21041/21140* */
155 #define csr_sia_status csr_12 /* 2104x */
156 #define csr_sia_connectivity csr_13 /* 2104x */
157 #define csr_sia_tx_rx csr_14 /* 2104x */
158 #define csr_sia_general csr_15 /* 2104x */
161 * While 21x4x allows chaining of its descriptors, this driver
162 * doesn't take advantage of it. We keep the descriptors in a
163 * traditional FIFO ring.
165 typedef struct {
166 tulip_desc_t *ri_first; /* first entry in ring */
167 tulip_desc_t *ri_last; /* one after last entry */
168 tulip_desc_t *ri_nextin; /* next to processed by host */
169 tulip_desc_t *ri_nextout; /* next to processed by adapter */
170 int ri_max;
171 int ri_free;
172 } tulip_ringinfo_t;
175 * The 21040 has a stupid restriction in that the receive
176 * buffers must be longword aligned. But since Ethernet
177 * headers are not a multiple of longwords in size this forces
178 * the data to non-longword aligned. Since IP requires the
179 * data to be longword aligned, we need to copy it after it has
180 * been DMA'ed in our memory.
182 * Since we have to copy it anyways, we might as well as allocate
183 * dedicated receive space for the input. This allows to use a
184 * small receive buffer size and more ring entries to be able to
185 * better keep with a flood of tiny Ethernet packets.
187 * The receive space MUST ALWAYS be a multiple of the page size.
188 * And the number of receive descriptors multiplied by the size
189 * of the receive buffers must equal the recevive space. This
190 * is so that we can manipulate the page tables so that even if a
191 * packet wraps around the end of the receive space, we can
192 * treat it as virtually contiguous.
194 * The above used to be true (the stupid restriction is still true)
195 * but we gone to directly DMA'ing into MBUFs (unless it's on an
196 * architecture which can't handle unaligned accesses) because with
197 * 100Mb/s cards the copying is just too much of a hit.
199 #if defined(__alpha__)
200 #define TULIP_COPY_RXDATA 1
201 #endif
203 #define TULIP_TXTIMER 4
205 #ifdef LCLDMA
206 #define TULIP_RXQ_TARGET 28
207 #define TULIP_TXDESCS 30 /* should test with 2, 3 ... */
208 #define TULIP_RXDESCS 30 /* should test with 2, 3 ... */
209 #define TULIP_XX_BUFLEN (1600-16)
210 #define TULIP_TX_BUFLEN TULIP_XX_BUFLEN
211 #define TULIP_RX_BUFLEN TULIP_XX_BUFLEN
212 #else
213 #define TULIP_RXDESCS 48
214 #define TULIP_TXDESCS 128
215 #define TULIP_RXQ_TARGET 32
216 #define TULIP_RX_BUFLEN ((MCLBYTES < 2048 ? MCLBYTES : 2048) - 16)
217 #endif
219 #if TULIP_RXQ_TARGET >= TULIP_RXDESCS
220 #error TULIP_RXQ_TARGET must be less than TULIP_RXDESCS
221 #endif
224 * Forward reference to make C happy.
226 typedef struct _tulip_softc_t tulip_softc_t;
229 * The various controllers support. Technically the DE425 is just
230 * a 21040 on EISA. But since it remarkably difference from normal
231 * 21040s, we give it its own chip id.
234 typedef enum {
235 TULIP_21040, TULIP_DE425,
236 TULIP_21041,
237 TULIP_21140, TULIP_21140A, TULIP_21142,
238 TULIP_21143,
239 TULIP_CHIPID_UNKNOWN
240 } tulip_chipid_t;
243 * Various physical media types supported.
244 * BNCAUI is BNC or AUI since on the 21040 you can't really tell
245 * which is in use.
247 typedef enum {
248 TULIP_MEDIA_UNKNOWN,
249 TULIP_MEDIA_10BASET,
250 TULIP_MEDIA_10BASET_FD,
251 TULIP_MEDIA_BNC,
252 TULIP_MEDIA_AUI,
253 TULIP_MEDIA_EXTSIA,
254 TULIP_MEDIA_AUIBNC,
255 TULIP_MEDIA_100BASETX,
256 TULIP_MEDIA_100BASETX_FD,
257 TULIP_MEDIA_100BASET4,
258 TULIP_MEDIA_100BASEFX,
259 TULIP_MEDIA_100BASEFX_FD,
260 TULIP_MEDIA_MAX
261 } tulip_media_t;
263 #define TULIP_BIT(b) (1L << ((int)(b)))
264 #define TULIP_FDBIT(m) (1L << ((int)TULIP_MEDIA_ ## m ## _FD))
265 #define TULIP_MBIT(m) (1L << ((int)TULIP_MEDIA_ ## m ))
266 #define TULIP_IS_MEDIA_FD(m) (TULIP_BIT(m) & \
267 (TULIP_FDBIT(10BASET) \
268 |TULIP_FDBIT(100BASETX) \
269 |TULIP_FDBIT(100BASEFX)))
270 #define TULIP_CAN_MEDIA_FD(m) (TULIP_BIT(m) & \
271 (TULIP_MBIT(10BASET) \
272 |TULIP_MBIT(100BASETX) \
273 |TULIP_MBIT(100BASEFX)))
274 #define TULIP_FD_MEDIA_OF(m) ((tulip_media_t)((m) + 1))
275 #define TULIP_HD_MEDIA_OF(m) ((tulip_media_t)((m) - 1))
276 #define TULIP_IS_MEDIA_100MB(m) ((m) >= TULIP_MEDIA_100BASETX)
277 #define TULIP_IS_MEDIA_TP(m) ((TULIP_BIT(m) & \
278 (TULIP_MBIT(BNC) \
279 |TULIP_MBIT(AUI) \
280 |TULIP_MBIT(AUIBNC) \
281 |TULIP_MBIT(EXTSIA))) == 0)
283 #define TULIP_SROM_ATTR_MII 0x0100
284 #define TULIP_SROM_ATTR_NWAY 0x0200
285 #define TULIP_SROM_ATTR_AUTOSENSE 0x0400
286 #define TULIP_SROM_ATTR_POWERUP 0x0800
287 #define TULIP_SROM_ATTR_NOLINKPASS 0x1000
289 typedef struct {
290 enum {
291 TULIP_MEDIAINFO_SIA,
292 TULIP_MEDIAINFO_GPR,
293 TULIP_MEDIAINFO_MII,
294 TULIP_MEDIAINFO_RESET,
295 TULIP_MEDIAINFO_SYM
296 } mi_type;
297 union {
298 struct {
299 u_int16_t sia_connectivity;
300 u_int16_t sia_tx_rx;
301 u_int16_t sia_general;
302 u_int32_t sia_gp_control; /* 21142/21143 */
303 u_int32_t sia_gp_data; /* 21142/21143 */
304 } un_sia;
305 struct {
306 u_int32_t gpr_cmdmode;
307 u_int32_t gpr_gpcontrol; /* 21142/21143 */
308 u_int32_t gpr_gpdata;
309 u_int8_t gpr_actmask;
310 u_int8_t gpr_actdata;
311 u_int8_t gpr_default : 1;
312 } un_gpr;
313 struct {
314 u_int32_t mii_mediamask;
315 u_int16_t mii_capabilities;
316 u_int16_t mii_advertisement;
317 u_int16_t mii_full_duplex;
318 u_int16_t mii_tx_threshold;
319 u_int16_t mii_interrupt; /* 21142/21143 */
320 u_int8_t mii_phyaddr;
321 u_int8_t mii_gpr_length;
322 u_int8_t mii_gpr_offset;
323 u_int8_t mii_reset_length;
324 u_int8_t mii_reset_offset;
325 } un_mii;
326 } mi_un;
327 } tulip_media_info_t;
329 #define mi_sia_connectivity mi_un.un_sia.sia_connectivity
330 #define mi_sia_tx_rx mi_un.un_sia.sia_tx_rx
331 #define mi_sia_general mi_un.un_sia.sia_general
332 #define mi_sia_gp_control mi_un.un_sia.sia_gp_control
333 #define mi_sia_gp_data mi_un.un_sia.sia_gp_data
335 #define mi_gpcontrol mi_un.un_gpr.gpr_gpcontrol
336 #define mi_gpdata mi_un.un_gpr.gpr_gpdata
337 #define mi_actmask mi_un.un_gpr.gpr_actmask
338 #define mi_actdata mi_un.un_gpr.gpr_actdata
339 #define mi_default mi_un.un_gpr.gpr_default
340 #define mi_cmdmode mi_un.un_gpr.gpr_cmdmode
342 #define mi_phyaddr mi_un.un_mii.mii_phyaddr
343 #define mi_gpr_length mi_un.un_mii.mii_gpr_length
344 #define mi_gpr_offset mi_un.un_mii.mii_gpr_offset
345 #define mi_reset_length mi_un.un_mii.mii_reset_length
346 #define mi_reset_offset mi_un.un_mii.mii_reset_offset
347 #define mi_capabilities mi_un.un_mii.mii_capabilities
348 #define mi_advertisement mi_un.un_mii.mii_advertisement
349 #define mi_full_duplex mi_un.un_mii.mii_full_duplex
350 #define mi_tx_threshold mi_un.un_mii.mii_tx_threshold
351 #define mi_mediamask mi_un.un_mii.mii_mediamask
352 #define mi_mii_interrupt mi_un.un_mii.mii_interrupt
354 #define TULIP_MEDIAINFO_SIA_INIT(sc, mi, chipid, media) do { \
355 (mi)->mi_type = TULIP_MEDIAINFO_SIA; \
356 sc->tulip_mediums[TULIP_MEDIA_ ## media] = (mi); \
357 (mi)->mi_sia_connectivity = TULIP_ ## chipid ## _SIACONN_ ## media; \
358 (mi)->mi_sia_tx_rx = TULIP_ ## chipid ## _SIATXRX_ ## media; \
359 (mi)->mi_sia_general = TULIP_ ## chipid ## _SIAGEN_ ## media; \
360 } while (0)
362 #define TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, media) do { \
363 if ((sc)->tulip_mediums[TULIP_MEDIA_ ## media] == NULL \
364 && ((mi)->mi_capabilities & PHYSTS_ ## media)) { \
365 (sc)->tulip_mediums[TULIP_MEDIA_ ## media] = (mi); \
366 (mi)->mi_mediamask |= TULIP_BIT(TULIP_MEDIA_ ## media); \
368 } while (0)
370 #define TULIP_MII_NOPHY 32
372 * Some boards need to treated specially. The following enumeration
373 * identifies the cards with quirks (or those we just want to single
374 * out for special merit or scorn).
376 typedef enum {
377 TULIP_21040_GENERIC, /* Generic 21040 (works with most any board) */
378 TULIP_21140_ISV, /* Digital Semicondutor 21140 ISV SROM Format */
379 TULIP_21142_ISV, /* Digital Semicondutor 21142 ISV SROM Format */
380 TULIP_21143_ISV, /* Digital Semicondutor 21143 ISV SROM Format */
381 TULIP_21140_DEC_EB, /* Digital Semicondutor 21140 Evaluation Board */
382 TULIP_21140_AVALON, /* Very similar to above EB140 board */
383 TULIP_21140_MII, /* 21140[A] with MII */
384 TULIP_21140_DEC_DE500, /* Digital DE500-?? 10/100 */
385 TULIP_21140_SMC_9332, /* SMC 9332 */
386 TULIP_21140_COGENT_EM100, /* Cogent EM100 100 only */
387 TULIP_21140_ZNYX_ZX34X, /* ZNYX ZX342 10/100 */
388 TULIP_21140_ASANTE, /* AsanteFast 10/100 */
389 TULIP_21041_GENERIC /* Generic 21041 card */
390 } tulip_board_t;
392 typedef enum {
393 TULIP_MEDIAPOLL_TIMER, /* 100ms timer fired */
394 TULIP_MEDIAPOLL_FASTTIMER, /* <100ms timer fired */
395 TULIP_MEDIAPOLL_LINKFAIL, /* called from interrupt routine */
396 TULIP_MEDIAPOLL_LINKPASS, /* called from interrupt routine */
397 TULIP_MEDIAPOLL_START, /* start a media probe (called from reset) */
398 TULIP_MEDIAPOLL_TXPROBE_OK, /* txprobe succeeded */
399 TULIP_MEDIAPOLL_TXPROBE_FAILED, /* txprobe failed */
400 TULIP_MEDIAPOLL_MAX
401 } tulip_mediapoll_event_t;
403 typedef enum {
404 TULIP_LINK_DOWN, /* Link is down */
405 TULIP_LINK_UP, /* link is ok */
406 TULIP_LINK_UNKNOWN /* we can't tell either way */
407 } tulip_link_status_t;
411 * This data structure is used to abstract out the quirks.
412 * media_probe = tries to determine the media type.
413 * media_select = enables the current media (or autosenses)
414 * media_poll = autosenses media
415 * media_preset = 21140, etal requires bit to set before the
416 * the software reset; hence pre-set. Should be
417 * pre-reset but that's ugly.
420 typedef struct {
421 tulip_board_t bd_type;
422 void (*bd_media_probe)(tulip_softc_t * const sc);
423 void (*bd_media_select)(tulip_softc_t * const sc);
424 void (*bd_media_poll)(tulip_softc_t * const sc, tulip_mediapoll_event_t event);
425 void (*bd_media_preset)(tulip_softc_t * const sc);
426 #if defined(__bsdi__)
427 struct ifmedia_entry *bd_media_list;
428 int bd_media_cnt;
429 int bd_media_options_mask;
430 #endif
431 } tulip_boardsw_t;
434 * The next few declarations are for MII/PHY based board.
436 * The first enumeration identifies a superset of various datums
437 * that can be obtained from various PHY chips. Not all PHYs will
438 * support all datums.
439 * The modedata structure indicates what register contains
440 * a datum, what mask is applied the register contents, and what the
441 * result should be.
442 * The attr structure records information about a supported PHY.
443 * The phy structure records information about a PHY instance.
446 typedef enum {
447 PHY_MODE_10T,
448 PHY_MODE_100TX,
449 PHY_MODE_100T4,
450 PHY_MODE_FULLDUPLEX,
451 PHY_MODE_MAX
452 } tulip_phy_mode_t;
454 typedef struct {
455 u_int16_t pm_regno;
456 u_int16_t pm_mask;
457 u_int16_t pm_value;
458 } tulip_phy_modedata_t;
460 typedef struct {
461 u_int32_t attr_id;
462 u_int16_t attr_flags;
463 #define PHY_NEED_HARD_RESET 0x0001
464 #define PHY_DUAL_CYCLE_TA 0x0002
465 tulip_phy_modedata_t attr_modes[PHY_MODE_MAX];
466 #ifdef TULIP_DEBUG
467 const char *attr_name;
468 #endif
469 } tulip_phy_attr_t;
472 * Various probe states used when trying to autosense the media.
475 typedef enum {
476 TULIP_PROBE_INACTIVE,
477 TULIP_PROBE_PHYRESET,
478 TULIP_PROBE_PHYAUTONEG,
479 TULIP_PROBE_GPRTEST,
480 TULIP_PROBE_MEDIATEST,
481 TULIP_PROBE_FAILED
482 } tulip_probe_state_t;
484 typedef struct {
486 * Transmit Statistics
488 u_int32_t dot3StatsSingleCollisionFrames;
489 u_int32_t dot3StatsMultipleCollisionFrames;
490 u_int32_t dot3StatsSQETestErrors;
491 u_int32_t dot3StatsDeferredTransmissions;
492 u_int32_t dot3StatsLateCollisions;
493 u_int32_t dot3StatsExcessiveCollisions;
494 u_int32_t dot3StatsInternalMacTransmitErrors;
495 u_int32_t dot3StatsCarrierSenseErrors;
497 * Receive Statistics
499 u_int32_t dot3StatsMissedFrames; /* not in rfc1650! */
500 u_int32_t dot3StatsAlignmentErrors;
501 u_int32_t dot3StatsFCSErrors;
502 u_int32_t dot3StatsFrameTooLongs;
503 u_int32_t dot3StatsInternalMacReceiveErrors;
504 } tulip_dot3_stats_t;
507 * Now to important stuff. This is softc structure (where does softc
508 * come from??? No idea) for the tulip device.
511 struct _tulip_softc_t {
512 #if defined(__bsdi__)
513 struct device tulip_dev; /* base device */
514 struct isadev tulip_id; /* ISA device */
515 struct intrhand tulip_ih; /* intrrupt vectoring */
516 struct atshutdown tulip_ats; /* shutdown hook */
517 #if _BSDI_VERSION < 199401
518 void *tulip_bpf; /* for BPF */
519 #else
520 prf_t tulip_pf; /* printf function */
521 #if _BSDI_VERSION >= 199701
522 struct mii_data tulip_mii; /* Generic MII and media data */
523 #define tulip_ifmedia tulip_mii.mii_media
524 #endif /* _BSDI_VERSION >= 199701 */
525 #endif /* _BSDI_VERSION < 199401 */
526 #endif /* __bsdi__ */
527 #if defined(__NetBSD__)
528 struct device tulip_dev; /* base device */
529 void *tulip_ih; /* intrrupt vectoring */
530 void *tulip_ats; /* shutdown hook */
531 bus_space_tag_t tulip_bustag;
532 bus_space_handle_t tulip_bushandle; /* CSR region handle */
533 pci_chipset_tag_t tulip_pc;
534 struct ethercom tulip_ec;
535 u_int8_t tulip_enaddr[ETHER_ADDR_LEN];
536 #endif
537 #if !defined(tulip_ifmedia)
538 struct ifmedia tulip_ifmedia;
539 #endif
540 #if !defined(__NetBSD__)
541 struct arpcom tulip_ac;
542 #endif
543 tulip_regfile_t tulip_csrs;
544 u_int32_t tulip_flags;
545 #define TULIP_WANTSETUP 0x00000001
546 #define TULIP_WANTHASH 0x00000002
547 #define TULIP_DOINGSETUP 0x00000004
548 #define TULIP_DEVICEPROBE 0x00000008
549 #define TULIP_PRINTMEDIA 0x00000010
550 #define TULIP_TXPROBE_ACTIVE 0x00000020
551 #define TULIP_ALLMULTI 0x00000040
552 #define TULIP_WANTRXACT 0x00000080
553 #define TULIP_RXACT 0x00000100
554 #define TULIP_INRESET 0x00000200
555 #define TULIP_NEEDRESET 0x00000400
556 #define TULIP_SQETEST 0x00000800
557 #define TULIP_ROMOK 0x00001000
558 #define TULIP_BASEROM 0x00002000
559 #define TULIP_SLAVEDROM 0x00004000
560 #define TULIP_SLAVEDINTR 0x00008000
561 #define TULIP_SHAREDINTR 0x00010000
562 #define TULIP_PRINTLINKUP 0x00020000
563 #define TULIP_LINKUP 0x00040000
564 #define TULIP_RXBUFSLOW 0x00080000
565 #define TULIP_NOMESSAGES 0x00100000
566 #define TULIP_SYSTEMERROR 0x00200000
567 #define TULIP_TIMEOUTPENDING 0x00400000
568 #define TULIP_FASTTIMEOUTPENDING 0x00800000
569 #define TULIP_TRYNWAY 0x01000000
570 #define TULIP_DIDNWAY 0x02000000
571 #define TULIP_RXBAD 0x04000000
572 #define TULIP_PROBE1STPASS 0x08000000
573 /* only 4 bits left! */
574 u_int32_t tulip_features; /* static bits indicating features of chip */
575 #define TULIP_HAVE_GPR 0x00000001 /* have gp register (140[A]) */
576 #define TULIP_HAVE_RXBUGGY 0x00000002 /* 21140A rx bug */
577 #define TULIP_HAVE_POWERMGMT 0x00000004 /* Snooze/sleep modes */
578 #define TULIP_HAVE_MII 0x00000008 /* Some medium on MII */
579 #define TULIP_HAVE_SIANWAY 0x00000010 /* SIA does NWAY */
580 #define TULIP_HAVE_DUALSENSE 0x00000020 /* SIA senses both AUI & TP */
581 #define TULIP_HAVE_SIAGP 0x00000040 /* SIA has a GP port */
582 #define TULIP_HAVE_BROKEN_HASH 0x00000080 /* Broken Multicast Hash */
583 #define TULIP_HAVE_ISVSROM 0x00000100 /* uses ISV SROM Format */
584 u_int32_t tulip_intrmask; /* our copy of csr_intr */
585 u_int32_t tulip_cmdmode; /* our copy of csr_cmdmode */
586 u_int32_t tulip_last_system_error : 3; /* last system error (only value is TULIP_SYSTEMERROR is also set) */
587 u_int32_t tulip_txtimer : 2; /* transmission timer */
588 u_int32_t tulip_system_errors; /* number of system errors encountered */
589 u_int32_t tulip_statusbits; /* status bits from CSR5 that may need to be printed */
591 tulip_media_info_t *tulip_mediums[TULIP_MEDIA_MAX]; /* indexes into mediainfo */
592 tulip_media_t tulip_media; /* current media type */
593 u_int32_t tulip_abilities; /* remote system's abiltities (as defined in IEEE 802.3u) */
595 u_int8_t tulip_revinfo; /* revision of chip */
596 u_int8_t tulip_phyaddr; /* 0..31 -- address of current phy */
597 u_int8_t tulip_gpinit; /* active pins on 21140 */
598 u_int8_t tulip_gpdata; /* default gpdata for 21140 */
600 struct {
601 u_int8_t probe_count; /* count of probe operations */
602 int32_t probe_timeout; /* time in ms of probe timeout */
603 tulip_probe_state_t probe_state; /* current media probe state */
604 tulip_media_t probe_media; /* current media being probed */
605 u_int32_t probe_mediamask; /* medias checked */
606 u_int32_t probe_passes; /* times autosense failed */
607 u_int32_t probe_txprobes; /* txprobes attempted */
608 } tulip_probe;
609 #define tulip_probe_count tulip_probe.probe_count
610 #define tulip_probe_timeout tulip_probe.probe_timeout
611 #define tulip_probe_state tulip_probe.probe_state
612 #define tulip_probe_media tulip_probe.probe_media
613 #define tulip_probe_mediamask tulip_probe.probe_mediamask
614 #define tulip_probe_passes tulip_probe.probe_passes
616 tulip_chipid_t tulip_chipid; /* type of chip we are using */
617 const tulip_boardsw_t *tulip_boardsw; /* board/chip characteristics */
618 tulip_softc_t *tulip_slaves; /* slaved devices (ZX3xx) */
619 #if defined(TULIP_DEBUG)
621 * Debugging/Statistical information
623 struct {
624 tulip_media_t dbg_last_media;
625 u_int32_t dbg_intrs;
626 u_int32_t dbg_media_probes;
627 u_int32_t dbg_txprobe_nocarr;
628 u_int32_t dbg_txprobe_exccoll;
629 u_int32_t dbg_link_downed;
630 u_int32_t dbg_link_suspected;
631 u_int32_t dbg_link_intrs;
632 u_int32_t dbg_link_pollintrs;
633 u_int32_t dbg_link_failures;
634 u_int32_t dbg_nway_starts;
635 u_int32_t dbg_nway_failures;
636 u_int16_t dbg_phyregs[32][4];
637 u_int32_t dbg_rxlowbufs;
638 u_int32_t dbg_rxintrs;
639 u_int32_t dbg_last_rxintrs;
640 u_int32_t dbg_high_rxintrs_hz;
641 u_int32_t dbg_txprobes_ok[TULIP_MEDIA_MAX];
642 u_int32_t dbg_txprobes_failed[TULIP_MEDIA_MAX];
643 u_int32_t dbg_events[TULIP_MEDIAPOLL_MAX];
644 u_int32_t dbg_rxpktsperintr[TULIP_RXDESCS];
645 } tulip_dbg;
646 #endif
647 struct ifqueue tulip_txq;
648 struct ifqueue tulip_rxq;
649 tulip_dot3_stats_t tulip_dot3stats;
650 tulip_ringinfo_t tulip_rxinfo;
651 tulip_ringinfo_t tulip_txinfo;
652 tulip_media_info_t tulip_mediainfo[10];
654 * The setup buffers for sending the setup frame to the chip.
655 * one is the one being sent while the other is the one being
656 * filled.
658 char tulip_boardid[16]; /* buffer for board ID */
659 u_int8_t tulip_rombuf[128];
660 u_int8_t tulip_pci_busno; /* needed for multiport boards */
661 u_int8_t tulip_pci_devno; /* needed for multiport boards */
662 u_int8_t tulip_connidx;
663 tulip_srom_connection_t tulip_conntype;
664 #define TULIP_SETUP_BUF_SZ (192/sizeof(u_int32_t))
665 u_int32_t tulip_setupbuf[ TULIP_SETUP_BUF_SZ];
666 u_int32_t tulip_setupdata[TULIP_SETUP_BUF_SZ];
667 #ifdef LCLDMA
668 void *tulip_rx_kva[TULIP_RXDESCS];
669 void *tulip_tx_kva[TULIP_TXDESCS];
670 tulip_desc_t *tulip_rxdescs,
671 *tulip_txdescs;
672 #else
673 tulip_desc_t tulip_rxdescs[TULIP_RXDESCS];
674 tulip_desc_t tulip_txdescs[TULIP_TXDESCS];
675 void *tulip_rx_kva[1];
676 void *tulip_tx_kva[1];
677 #endif
680 #define TULIP_DO_AUTOSENSE(sc) (IFM_SUBTYPE((sc)->tulip_ifmedia.ifm_media) == IFM_AUTO)
682 #if defined(TULIP_HDR_DATA)
683 static const char * const tulip_chipdescs[] = {
684 "21040 [10Mb/s]",
685 #if defined(TULIP_EISA)
686 "DE425 [10Mb/s]",
687 #else
688 NULL,
689 #endif
690 "21041 [10Mb/s]",
691 "21140 [10-100Mb/s]",
692 "21140A [10-100Mb/s]",
693 "21142 [10-100Mb/s]",
694 "21143 [10-100Mb/s]",
697 static const char * const tulip_mediums[] = {
698 "unknown", /* TULIP_MEDIA_UNKNOWN */
699 "10baseT", /* TULIP_MEDIA_10BASET */
700 "Full Duplex 10baseT", /* TULIP_MEDIA_10BASET_FD */
701 "BNC", /* TULIP_MEDIA_BNC */
702 "AUI", /* TULIP_MEDIA_AUI */
703 "External SIA", /* TULIP_MEDIA_EXTSIA */
704 "AUI/BNC", /* TULIP_MEDIA_AUIBNC */
705 "100baseTX", /* TULIP_MEDIA_100BASET */
706 "Full Duplex 100baseTX", /* TULIP_MEDIA_100BASET_FD */
707 "100baseT4", /* TULIP_MEDIA_100BASET4 */
708 "100baseFX", /* TULIP_MEDIA_100BASEFX */
709 "Full Duplex 100baseFX", /* TULIP_MEDIA_100BASEFX_FD */
712 #if defined(IFM_ETHER)
713 static const int tulip_media_to_ifmedia[] = {
714 IFM_ETHER | IFM_NONE, /* TULIP_MEDIA_UNKNOWN */
715 IFM_ETHER | IFM_10_T, /* TULIP_MEDIA_10BASET */
716 IFM_ETHER | IFM_10_T | IFM_FDX, /* TULIP_MEDIA_10BASET_FD */
717 IFM_ETHER | IFM_10_2, /* TULIP_MEDIA_BNC */
718 IFM_ETHER | IFM_10_5, /* TULIP_MEDIA_AUI */
719 IFM_ETHER | IFM_MANUAL, /* TULIP_MEDIA_EXTSIA */
720 IFM_ETHER | IFM_10_5, /* TULIP_MEDIA_AUIBNC */
721 IFM_ETHER | IFM_100_TX, /* TULIP_MEDIA_100BASET */
722 IFM_ETHER | IFM_100_TX | IFM_FDX, /* TULIP_MEDIA_100BASET_FD */
723 IFM_ETHER | IFM_100_T4, /* TULIP_MEDIA_100BASET4 */
724 IFM_ETHER | IFM_100_FX, /* TULIP_MEDIA_100BASEFX */
725 IFM_ETHER | IFM_100_FX | IFM_FDX, /* TULIP_MEDIA_100BASEFX_FD */
727 #endif /* defined(IFM_ETHER) */
729 static const char * const tulip_system_errors[] = {
730 "parity error",
731 "master abort",
732 "target abort",
733 "reserved #3",
734 "reserved #4",
735 "reserved #5",
736 "reserved #6",
737 "reserved #7",
740 static const char * const tulip_status_bits[] = {
741 NULL,
742 "transmit process stopped",
743 NULL,
744 "transmit jabber timeout",
746 NULL,
747 "transmit underflow",
748 NULL,
749 "receive underflow",
751 "receive process stopped",
752 "receive watchdog timeout",
753 NULL,
754 NULL,
756 "link failure",
757 NULL,
758 NULL,
761 static const struct {
762 tulip_srom_connection_t sc_type;
763 tulip_media_t sc_media;
764 u_int32_t sc_attrs;
765 } tulip_srom_conninfo[] = {
766 { TULIP_SROM_CONNTYPE_10BASET, TULIP_MEDIA_10BASET },
767 { TULIP_SROM_CONNTYPE_BNC, TULIP_MEDIA_BNC },
768 { TULIP_SROM_CONNTYPE_AUI, TULIP_MEDIA_AUI },
769 { TULIP_SROM_CONNTYPE_100BASETX, TULIP_MEDIA_100BASETX },
770 { TULIP_SROM_CONNTYPE_100BASET4, TULIP_MEDIA_100BASET4 },
771 { TULIP_SROM_CONNTYPE_100BASEFX, TULIP_MEDIA_100BASEFX },
772 { TULIP_SROM_CONNTYPE_MII_10BASET, TULIP_MEDIA_10BASET,
773 TULIP_SROM_ATTR_MII },
774 { TULIP_SROM_CONNTYPE_MII_100BASETX, TULIP_MEDIA_100BASETX,
775 TULIP_SROM_ATTR_MII },
776 { TULIP_SROM_CONNTYPE_MII_100BASET4, TULIP_MEDIA_100BASET4,
777 TULIP_SROM_ATTR_MII },
778 { TULIP_SROM_CONNTYPE_MII_100BASEFX, TULIP_MEDIA_100BASEFX,
779 TULIP_SROM_ATTR_MII },
780 { TULIP_SROM_CONNTYPE_10BASET_NWAY, TULIP_MEDIA_10BASET,
781 TULIP_SROM_ATTR_NWAY },
782 { TULIP_SROM_CONNTYPE_10BASET_FD, TULIP_MEDIA_10BASET_FD },
783 { TULIP_SROM_CONNTYPE_MII_10BASET_FD, TULIP_MEDIA_10BASET_FD,
784 TULIP_SROM_ATTR_MII },
785 { TULIP_SROM_CONNTYPE_100BASETX_FD, TULIP_MEDIA_100BASETX_FD },
786 { TULIP_SROM_CONNTYPE_MII_100BASETX_FD, TULIP_MEDIA_100BASETX_FD,
787 TULIP_SROM_ATTR_MII },
788 { TULIP_SROM_CONNTYPE_10BASET_NOLINKPASS, TULIP_MEDIA_10BASET,
789 TULIP_SROM_ATTR_NOLINKPASS },
790 { TULIP_SROM_CONNTYPE_AUTOSENSE, TULIP_MEDIA_UNKNOWN,
791 TULIP_SROM_ATTR_AUTOSENSE },
792 { TULIP_SROM_CONNTYPE_AUTOSENSE_POWERUP, TULIP_MEDIA_UNKNOWN,
793 TULIP_SROM_ATTR_AUTOSENSE|TULIP_SROM_ATTR_POWERUP },
794 { TULIP_SROM_CONNTYPE_AUTOSENSE_NWAY, TULIP_MEDIA_UNKNOWN,
795 TULIP_SROM_ATTR_AUTOSENSE|TULIP_SROM_ATTR_NWAY },
796 { TULIP_SROM_CONNTYPE_NOT_USED, TULIP_MEDIA_UNKNOWN }
798 #define TULIP_SROM_LASTCONNIDX \
799 (sizeof(tulip_srom_conninfo)/sizeof(tulip_srom_conninfo[0]) - 1)
801 static const struct {
802 tulip_media_t sm_type;
803 tulip_srom_media_t sm_srom_type;
804 } tulip_srom_mediums[] = {
805 { TULIP_MEDIA_100BASEFX_FD, TULIP_SROM_MEDIA_100BASEFX_FD },
806 { TULIP_MEDIA_100BASEFX, TULIP_SROM_MEDIA_100BASEFX },
807 { TULIP_MEDIA_100BASET4, TULIP_SROM_MEDIA_100BASET4 },
808 { TULIP_MEDIA_100BASETX_FD, TULIP_SROM_MEDIA_100BASETX_FD },
809 { TULIP_MEDIA_100BASETX, TULIP_SROM_MEDIA_100BASETX },
810 { TULIP_MEDIA_10BASET_FD, TULIP_SROM_MEDIA_10BASET_FD },
811 { TULIP_MEDIA_AUI, TULIP_SROM_MEDIA_AUI },
812 { TULIP_MEDIA_BNC, TULIP_SROM_MEDIA_BNC },
813 { TULIP_MEDIA_10BASET, TULIP_SROM_MEDIA_10BASET },
814 { TULIP_MEDIA_UNKNOWN }
816 #endif /* TULIP_HDR_DATA */
819 * This driver supports a maximum of 32 tulip boards.
820 * This should be enough for the forseeable future.
822 #define TULIP_MAX_DEVICES 32
824 #if defined(TULIP_USE_SOFTINTR) && defined(TULIP_HDR_DATA)
825 static u_int32_t tulip_softintr_mask;
826 static int tulip_softintr_last_unit;
827 static int tulip_softintr_max_unit;
828 static void tulip_softintr(void);
829 #endif
831 #ifdef notyet
832 #define SIOCGADDRROM _IOW('i', 240, struct ifreq) /* get 128 bytes of ROM */
833 #define SIOCGCHIPID _IOWR('i', 241, struct ifreq) /* get chipid */
834 #endif
836 #if defined(__FreeBSD__)
837 typedef void ifnet_ret_t;
838 typedef int ioctl_cmd_t;
839 #if defined(TULIP_HDR_DATA)
840 static tulip_softc_t *tulips[TULIP_MAX_DEVICES];
841 #endif
842 #if BSD >= 199506
843 #define TULIP_IFP_TO_SOFTC(ifp) ((tulip_softc_t *)((ifp)->if_softc))
844 #if NBPFILTER > 0
845 #define TULIP_BPF_MTAP(sc, m) bpf_mtap(&(sc)->tulip_if, m)
846 #define TULIP_BPF_TAP(sc, p, l) bpf_tap(&(sc)->tulip_if, p, l)
847 #define TULIP_BPF_ATTACH(sc) bpfattach(&(sc)->tulip_if, DLT_EN10MB, sizeof(struct ether_header))
848 #endif
849 #define tulip_intrfunc_t void
850 #define TULIP_VOID_INTRFUNC
851 #define IFF_NOTRAILERS 0
852 #define CLBYTES PAGE_SIZE
853 #if 0
854 #define TULIP_KVATOPHYS(sc, va) kvtop(va)
855 #endif
856 #define TULIP_EADDR_FMT "%6D"
857 #define TULIP_EADDR_ARGS(addr) addr, ":"
858 #else
859 extern int bootverbose;
860 #define TULIP_IFP_TO_SOFTC(ifp) (TULIP_UNIT_TO_SOFTC((ifp)->if_unit))
861 #include <sys/devconf.h>
862 #define TULIP_DEVCONF
863 #endif
864 #if defined(TULIP_USE_SOFTINTR)
865 NETISR_SET(NETISR_DE, tulip_softintr);
866 #endif
867 #define TULIP_UNIT_TO_SOFTC(unit) (tulips[unit])
868 #define TULIP_BURSTSIZE(unit) pci_max_burst_len
869 #define loudprintf if (bootverbose) printf
870 #endif
872 #if defined(__bsdi__)
873 typedef int ifnet_ret_t;
874 typedef u_long ioctl_cmd_t;
875 extern struct cfdriver decd;
876 #define TULIP_UNIT_TO_SOFTC(unit) ((tulip_softc_t *) decd.cd_devs[unit])
877 #define TULIP_IFP_TO_SOFTC(ifp) (TULIP_UNIT_TO_SOFTC((ifp)->if_unit))
878 #if _BSDI_VERSION >= 199510
879 #if 0
880 #define TULIP_BURSTSIZE(unit) log2_burst_size
881 #endif
882 #define loudprintf aprint_verbose
883 #define printf (*sc->tulip_pf)
884 #define MCNT(x) (sizeof(x) / sizeof(struct ifmedia_entry))
885 #elif _BSDI_VERSION <= 199401
886 #define DRQNONE 0
887 #define loudprintf printf
888 static void
889 arp_ifinit(
890 struct arpcom *ac,
891 struct ifaddr *ifa)
893 ac->ac_ipaddr = IA_SIN(ifa)->sin_addr;
894 arpwhohas(ac, &ac->ac_ipaddr);
896 #endif
897 #endif /* __bsdi__ */
899 #if defined(__NetBSD__)
900 typedef void ifnet_ret_t;
901 typedef u_long ioctl_cmd_t;
902 extern struct cfdriver ade_cd;
903 #define TULIP_UNIT_TO_SOFTC(unit) (device_lookup_private(&ade_cd,unit))
904 #define TULIP_IFP_TO_SOFTC(ifp) ((tulip_softc_t *)((ifp)->if_softc))
905 #define tulip_unit tulip_dev.dv_unit
906 #define tulip_xname tulip_if.if_xname
907 #define TULIP_RAISESPL() splnet()
908 #define TULIP_RAISESOFTSPL() splsoftnet()
909 #define TULIP_RESTORESPL(s) splx(s)
910 #define tulip_if tulip_ec.ec_if
911 #define tulip_enaddr tulip_enaddr
912 #define tulip_multicnt tulip_ec.ec_multicnt
913 #define TULIP_ETHERCOM(sc) (&(sc)->tulip_ec)
914 #define TULIP_ARP_IFINIT(sc, ifa) arp_ifinit(&(sc)->tulip_if, (ifa))
915 #define TULIP_ETHER_IFATTACH(sc) ether_ifattach(&(sc)->tulip_if, (sc)->tulip_enaddr)
916 #define loudprintf printf
917 #define TULIP_PRINTF_FMT "%s"
918 #define TULIP_PRINTF_ARGS sc->tulip_xname
919 #if defined(__alpha__)
920 /* XXX XXX NEED REAL DMA MAPPING SUPPORT XXX XXX */
921 #define TULIP_KVATOPHYS(sc, va) alpha_XXX_dmamap((vaddr_t)(va))
922 #endif
923 #endif /* __NetBSD__ */
925 #ifndef TULIP_PRINTF_FMT
926 #define TULIP_PRINTF_FMT "%s%d"
927 #endif
928 #ifndef TULIP_PRINTF_ARGS
929 #define TULIP_PRINTF_ARGS sc->tulip_name, sc->tulip_unit
930 #endif
932 #ifndef TULIP_BURSTSIZE
933 #define TULIP_BURSTSIZE(unit) 3
934 #endif
936 #ifndef tulip_if
937 #define tulip_if tulip_ac.ac_if
938 #endif
939 #ifndef tulip_unit
940 #define tulip_unit tulip_if.if_unit
941 #endif
942 #define tulip_name tulip_if.if_name
943 #ifndef tulip_enaddr
944 #define tulip_enaddr tulip_ac.ac_enaddr
945 #endif
946 #ifndef tulip_multicnt
947 #define tulip_multicnt tulip_ac.ac_multicnt
948 #endif
950 #if !defined(TULIP_ETHERCOM)
951 #define TULIP_ETHERCOM(sc) (&(sc)->tulip_ac)
952 #endif
954 #if !defined(TULIP_ARP_IFINIT)
955 #define TULIP_ARP_IFINIT(sc, ifa) arp_ifinit(TULIP_ETHERCOM(sc), (ifa))
956 #endif
958 #if !defined(TULIP_ETHER_IFATTACH)
959 #define TULIP_ETHER_IFATTACH(sc) ether_ifattach(&(sc)->tulip_if)
960 #endif
962 #if !defined(tulip_bpf) && (!defined(__bsdi__) || _BSDI_VERSION >= 199401)
963 #define tulip_bpf tulip_if.if_bpf
964 #endif
966 #if !defined(tulip_intrfunc_t)
967 #define tulip_intrfunc_t int
968 #endif
970 #if !defined(TULIP_KVATOPHYS)
971 #define TULIP_KVATOPHYS(sc, va) vtophys(va)
972 #endif
974 #ifndef TULIP_RAISESPL
975 #define TULIP_RAISESPL() splimp()
976 #endif
977 #ifndef TULIP_RAISESOFTSPL
978 #define TULIP_RAISESOFTSPL() splnet()
979 #endif
980 #ifndef TULUP_RESTORESPL
981 #define TULIP_RESTORESPL(s) splx(s)
982 #endif
985 * While I think FreeBSD's 2.2 change to the bpf is a nice simplification,
986 * it does add yet more conditional code to this driver. Sigh.
988 #if !defined(TULIP_BPF_MTAP) && NBPFILTER > 0
989 #define TULIP_BPF_MTAP(sc, m) bpf_mtap((sc)->tulip_bpf, m)
990 #define TULIP_BPF_TAP(sc, p, l) bpf_tap((sc)->tulip_bpf, p, l)
991 #define TULIP_BPF_ATTACH(sc) bpfattach(&(sc)->tulip_bpf, &(sc)->tulip_if, DLT_EN10MB, sizeof(struct ether_header))
992 #endif
995 * However, this change to FreeBSD I am much less enamored with.
997 #if !defined(TULIP_EADDR_FMT)
998 #define TULIP_EADDR_FMT "%s"
999 #define TULIP_EADDR_ARGS(addr) ether_sprintf(addr)
1000 #endif
1002 #define TULIP_CRC32_POLY 0xEDB88320UL /* CRC-32 Poly -- Little Endian */
1003 #define TULIP_MAX_TXSEG 30
1005 #define TULIP_ADDREQUAL(a1, a2) \
1006 (((u_int16_t *)a1)[0] == ((u_int16_t *)a2)[0] \
1007 && ((u_int16_t *)a1)[1] == ((u_int16_t *)a2)[1] \
1008 && ((u_int16_t *)a1)[2] == ((u_int16_t *)a2)[2])
1009 #define TULIP_ADDRBRDCST(a1) \
1010 (((u_int16_t *)a1)[0] == 0xFFFFU \
1011 && ((u_int16_t *)a1)[1] == 0xFFFFU \
1012 && ((u_int16_t *)a1)[2] == 0xFFFFU)
1014 typedef int tulip_spl_t;
1016 #endif /* !defined(_DEVAR_H) */