1 /* $NetBSD: if_devar.h,v 1.51 2009/03/29 05:26:43 dholland Exp $ */
4 * Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. The name of the author may not be used to endorse or promote products
13 * derived from this software without specific prior written permission
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * Id: if_devar.h,v 1.28 1997/07/03 16:55:07 thomas Exp
29 #if !defined(_DEVAR_H)
32 #if defined(__NetBSD__)
40 #define TULIP_BUS_DMA 1
41 /* #define TULIP_BUS_DMA_NORX 1 */
42 /* #define TULIP_BUS_DMA_NOTX 1 */
45 typedef bus_addr_t tulip_csrptr_t
;
47 #define TULIP_CSR_READ(sc, csr) \
48 bus_space_read_4((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr)
49 #define TULIP_CSR_WRITE(sc, csr, val) \
50 bus_space_write_4((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr, (val))
52 #define TULIP_CSR_READBYTE(sc, csr) \
53 bus_space_read_1((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr)
54 #define TULIP_CSR_WRITEBYTE(sc, csr, val) \
55 bus_space_write_1((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr, (val))
56 #endif /* __NetBSD__ */
59 #define TULIP_EISA_CSRSIZE 16
60 #define TULIP_EISA_CSROFFSET 0
61 #define TULIP_PCI_CSRSIZE 8
62 #define TULIP_PCI_CSROFFSET 0
64 #if !defined(__NetBSD__)
65 typedef u_int16_t tulip_csrptr_t
;
67 #define TULIP_CSR_READ(sc, csr) (inl((sc)->tulip_csrs.csr))
68 #define TULIP_CSR_WRITE(sc, csr, val) outl((sc)->tulip_csrs.csr, val)
70 #define TULIP_CSR_READBYTE(sc, csr) (inb((sc)->tulip_csrs.csr))
71 #define TULIP_CSR_WRITEBYTE(sc, csr, val) outb((sc)->tulip_csrs.csr, val)
72 #endif /* __NetBSD__ */
74 #else /* TULIP_IOMAPPED */
76 #define TULIP_PCI_CSRSIZE 8
77 #define TULIP_PCI_CSROFFSET 0
79 #if !defined(__NetBSD__)
80 typedef volatile u_int32_t
*tulip_csrptr_t
;
83 * macros to read and write CSRs. Note that the "0 +" in
84 * READ_CSR is to prevent the macro from being an lvalue
85 * and WRITE_CSR shouldn't be assigned from.
87 #define TULIP_CSR_READ(sc, csr) (0 + *(sc)->tulip_csrs.csr)
88 #define TULIP_CSR_WRITE(sc, csr, val) ((void)(*(sc)->tulip_csrs.csr = (val)))
89 #endif /* __NetBSD__ */
91 #endif /* TULIP_IOMAPPED */
94 * This structure contains "pointers" for the registers on
95 * the various 21x4x chips. CSR0 through CSR8 are common
96 * to all chips. After that, it gets messy...
99 tulip_csrptr_t csr_busmode
; /* CSR0 */
100 tulip_csrptr_t csr_txpoll
; /* CSR1 */
101 tulip_csrptr_t csr_rxpoll
; /* CSR2 */
102 tulip_csrptr_t csr_rxlist
; /* CSR3 */
103 tulip_csrptr_t csr_txlist
; /* CSR4 */
104 tulip_csrptr_t csr_status
; /* CSR5 */
105 tulip_csrptr_t csr_command
; /* CSR6 */
106 tulip_csrptr_t csr_intr
; /* CSR7 */
107 tulip_csrptr_t csr_missed_frames
; /* CSR8 */
108 tulip_csrptr_t csr_9
; /* CSR9 */
109 tulip_csrptr_t csr_10
; /* CSR10 */
110 tulip_csrptr_t csr_11
; /* CSR11 */
111 tulip_csrptr_t csr_12
; /* CSR12 */
112 tulip_csrptr_t csr_13
; /* CSR13 */
113 tulip_csrptr_t csr_14
; /* CSR14 */
114 tulip_csrptr_t csr_15
; /* CSR15 */
117 #define csr_enetrom csr_9 /* 21040 */
118 #define csr_reserved csr_10 /* 21040 */
119 #define csr_full_duplex csr_11 /* 21040 */
120 #define csr_bootrom csr_10 /* 21041/21140A/?? */
121 #define csr_gp csr_12 /* 21140* */
122 #define csr_watchdog csr_15 /* 21140* */
123 #define csr_gp_timer csr_11 /* 21041/21140* */
124 #define csr_srom_mii csr_9 /* 21041/21140* */
125 #define csr_sia_status csr_12 /* 2104x */
126 #define csr_sia_connectivity csr_13 /* 2104x */
127 #define csr_sia_tx_rx csr_14 /* 2104x */
128 #define csr_sia_general csr_15 /* 2104x */
131 * While 21x4x allows chaining of its descriptors, this driver
132 * doesn't take advantage of it. We keep the descriptors in a
133 * traditional FIFO ring.
136 tulip_desc_t
*ri_first
; /* first entry in ring */
137 tulip_desc_t
*ri_last
; /* one after last entry */
138 tulip_desc_t
*ri_nextin
; /* next to processed by host */
139 tulip_desc_t
*ri_nextout
; /* next to processed by adapter */
145 * The 21040 has a stupid restriction in that the receive
146 * buffers must be longword aligned. But since Ethernet
147 * headers are not a multiple of longwords in size this forces
148 * the data to non-longword aligned. Since IP requires the
149 * data to be longword aligned, we need to copy it after it has
150 * been DMA'ed in our memory.
152 * Since we have to copy it anyways, we might as well as allocate
153 * dedicated receive space for the input. This allows to use a
154 * small receive buffer size and more ring entries to be able to
155 * better keep with a flood of tiny Ethernet packets.
157 * The receive space MUST ALWAYS be a multiple of the page size.
158 * And the number of receive descriptors multiplied by the size
159 * of the receive buffers must equal the recevive space. This
160 * is so that we can manipulate the page tables so that even if a
161 * packet wraps around the end of the receive space, we can
162 * treat it as virtually contiguous.
164 * The above used to be true (the stupid restriction is still true)
165 * but we gone to directly DMA'ing into MBUFs (unless it's on an
166 * architecture which can't handle unaligned accesses) because with
167 * 100Mb/s cards the copying is just too much of a hit.
169 #if !defined(__i386__) && !defined(__vax__)
170 #define TULIP_COPY_RXDATA 1
173 #define TULIP_DATA_PER_DESC 2032
174 #define TULIP_TXTIMER 4
175 #define TULIP_RXDESCS 48
176 #define TULIP_TXDESCS 32
177 #define TULIP_RXQ_TARGET 32
178 #if TULIP_RXQ_TARGET >= TULIP_RXDESCS
179 #error TULIP_RXQ_TARGET must be less than TULIP_RXDESCS
181 #define TULIP_RX_BUFLEN ((MCLBYTES < 2048 ? MCLBYTES : 2048) - 16)
184 * Forward reference to make C happy.
186 typedef struct _tulip_softc_t tulip_softc_t
;
189 * The various controllers support. Technically the DE425 is just
190 * a 21040 on EISA. But since it remarkably difference from normal
191 * 21040s, we give it its own chip id.
195 TULIP_21040
, TULIP_DE425
,
197 TULIP_21140
, TULIP_21140A
, TULIP_21142
,
203 * Various physical media types supported.
204 * BNCAUI is BNC or AUI since on the 21040 you can't really tell
210 TULIP_MEDIA_10BASET_FD
,
215 TULIP_MEDIA_100BASETX
,
216 TULIP_MEDIA_100BASETX_FD
,
217 TULIP_MEDIA_100BASET4
,
218 TULIP_MEDIA_100BASEFX
,
219 TULIP_MEDIA_100BASEFX_FD
,
223 #define TULIP_BIT(b) (1L << ((int)(b)))
224 #define TULIP_FDBIT(m) (1L << ((int)TULIP_MEDIA_ ## m ## _FD))
225 #define TULIP_MBIT(m) (1L << ((int)TULIP_MEDIA_ ## m ))
226 #define TULIP_IS_MEDIA_FD(m) (TULIP_BIT(m) & \
227 (TULIP_FDBIT(10BASET) \
228 |TULIP_FDBIT(100BASETX) \
229 |TULIP_FDBIT(100BASEFX)))
230 #define TULIP_CAN_MEDIA_FD(m) (TULIP_BIT(m) & \
231 (TULIP_MBIT(10BASET) \
232 |TULIP_MBIT(100BASETX) \
233 |TULIP_MBIT(100BASEFX)))
234 #define TULIP_FD_MEDIA_OF(m) ((tulip_media_t)((m) + 1))
235 #define TULIP_HD_MEDIA_OF(m) ((tulip_media_t)((m) - 1))
236 #define TULIP_IS_MEDIA_100MB(m) ((m) >= TULIP_MEDIA_100BASETX)
237 #define TULIP_IS_MEDIA_TP(m) ((TULIP_BIT(m) & \
240 |TULIP_MBIT(AUIBNC) \
241 |TULIP_MBIT(EXTSIA))) == 0)
243 #define TULIP_SROM_ATTR_MII 0x0100
244 #define TULIP_SROM_ATTR_NWAY 0x0200
245 #define TULIP_SROM_ATTR_AUTOSENSE 0x0400
246 #define TULIP_SROM_ATTR_POWERUP 0x0800
247 #define TULIP_SROM_ATTR_NOLINKPASS 0x1000
251 TULIP_MEDIAINFO_NONE
,
255 TULIP_MEDIAINFO_RESET
,
260 u_int16_t sia_connectivity
;
262 u_int16_t sia_general
;
263 u_int32_t sia_gp_control
; /* 21142/21143 */
264 u_int32_t sia_gp_data
; /* 21142/21143 */
267 u_int32_t gpr_cmdmode
;
268 u_int32_t gpr_gpcontrol
; /* 21142/21143 */
269 u_int32_t gpr_gpdata
;
270 u_int8_t gpr_actmask
;
271 u_int8_t gpr_actdata
;
272 u_int8_t gpr_default
: 1;
275 u_int32_t mii_mediamask
;
276 u_int16_t mii_capabilities
;
277 u_int16_t mii_advertisement
;
278 u_int16_t mii_full_duplex
;
279 u_int16_t mii_tx_threshold
;
280 u_int16_t mii_interrupt
; /* 21142/21143 */
281 u_int8_t mii_phyaddr
;
282 u_int8_t mii_gpr_length
;
283 u_int8_t mii_gpr_offset
;
284 u_int8_t mii_reset_length
;
285 u_int8_t mii_reset_offset
;
289 } tulip_media_info_t
;
291 #define mi_sia_connectivity mi_un.un_sia.sia_connectivity
292 #define mi_sia_tx_rx mi_un.un_sia.sia_tx_rx
293 #define mi_sia_general mi_un.un_sia.sia_general
294 #define mi_sia_gp_control mi_un.un_sia.sia_gp_control
295 #define mi_sia_gp_data mi_un.un_sia.sia_gp_data
297 #define mi_gpcontrol mi_un.un_gpr.gpr_gpcontrol
298 #define mi_gpdata mi_un.un_gpr.gpr_gpdata
299 #define mi_actmask mi_un.un_gpr.gpr_actmask
300 #define mi_actdata mi_un.un_gpr.gpr_actdata
301 #define mi_default mi_un.un_gpr.gpr_default
302 #define mi_cmdmode mi_un.un_gpr.gpr_cmdmode
304 #define mi_phyaddr mi_un.un_mii.mii_phyaddr
305 #define mi_gpr_length mi_un.un_mii.mii_gpr_length
306 #define mi_gpr_offset mi_un.un_mii.mii_gpr_offset
307 #define mi_reset_length mi_un.un_mii.mii_reset_length
308 #define mi_reset_offset mi_un.un_mii.mii_reset_offset
309 #define mi_capabilities mi_un.un_mii.mii_capabilities
310 #define mi_advertisement mi_un.un_mii.mii_advertisement
311 #define mi_full_duplex mi_un.un_mii.mii_full_duplex
312 #define mi_tx_threshold mi_un.un_mii.mii_tx_threshold
313 #define mi_mediamask mi_un.un_mii.mii_mediamask
314 #define mi_mii_interrupt mi_un.un_mii.mii_interrupt
315 #define mi_phyid mi_un.un_mii.mii_phyid
317 #define TULIP_MEDIAINFO_SIA_INIT(sc, mi, chipid, media) do { \
318 (mi)->mi_type = TULIP_MEDIAINFO_SIA; \
319 sc->tulip_mediums[TULIP_MEDIA_ ## media] = (mi); \
320 (mi)->mi_sia_connectivity = TULIP_ ## chipid ## _SIACONN_ ## media; \
321 (mi)->mi_sia_tx_rx = TULIP_ ## chipid ## _SIATXRX_ ## media; \
322 (mi)->mi_sia_general = TULIP_ ## chipid ## _SIAGEN_ ## media; \
325 #define TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, media) do { \
326 if ((sc)->tulip_mediums[TULIP_MEDIA_ ## media] == NULL \
327 && ((mi)->mi_capabilities & PHYSTS_ ## media)) { \
328 (sc)->tulip_mediums[TULIP_MEDIA_ ## media] = (mi); \
329 (mi)->mi_mediamask |= TULIP_BIT(TULIP_MEDIA_ ## media); \
333 #define TULIP_MII_NOPHY 32
335 * Some boards need to treated specially. The following enumeration
336 * identifies the cards with quirks (or those we just want to single
337 * out for special merit or scorn).
340 TULIP_21040_GENERIC
, /* Generic 21040 (works with most any board) */
341 TULIP_21140_ISV
, /* Digital Semicondutor 21140 ISV SROM Format */
342 TULIP_21142_ISV
, /* Digital Semicondutor 21142 ISV SROM Format */
343 TULIP_21143_ISV
, /* Digital Semicondutor 21143 ISV SROM Format */
344 TULIP_21140_DEC_EB
, /* Digital Semicondutor 21140 Evaluation Board */
345 TULIP_21140_MII
, /* 21140[A] with MII */
346 TULIP_21140_DEC_DE500
, /* Digital DE500-?? 10/100 */
347 TULIP_21140_SMC_9332
, /* SMC 9332 */
348 TULIP_21140_COGENT_EM100
, /* Cogent EM100 100 only */
349 TULIP_21140_ZNYX_ZX34X
, /* ZNYX ZX342 10/100 */
350 TULIP_21140_ASANTE
, /* AsanteFast 10/100 */
351 TULIP_21140_EN1207
, /* Accton EN2107 10/100 BNC */
352 TULIP_21041_GENERIC
/* Generic 21041 card */
356 TULIP_MEDIAPOLL_TIMER
, /* 100ms timer fired */
357 TULIP_MEDIAPOLL_FASTTIMER
, /* <100ms timer fired */
358 TULIP_MEDIAPOLL_LINKFAIL
, /* called from interrupt routine */
359 TULIP_MEDIAPOLL_LINKPASS
, /* called from interrupt routine */
360 TULIP_MEDIAPOLL_START
, /* start a media probe (called from reset) */
361 TULIP_MEDIAPOLL_TXPROBE_OK
, /* txprobe succeeded */
362 TULIP_MEDIAPOLL_TXPROBE_FAILED
, /* txprobe failed */
364 } tulip_mediapoll_event_t
;
367 TULIP_LINK_DOWN
, /* Link is down */
368 TULIP_LINK_UP
, /* link is ok */
369 TULIP_LINK_UNKNOWN
/* we can't tell either way */
370 } tulip_link_status_t
;
374 * This data structure is used to abstract out the quirks.
375 * media_probe = tries to determine the media type.
376 * media_select = enables the current media (or autosenses)
377 * media_poll = autosenses media
378 * media_preset = 21140, etal requires bit to set before the
379 * the software reset; hence pre-set. Should be
380 * pre-reset but that's ugly.
384 tulip_board_t bd_type
;
385 void (*bd_media_probe
)(tulip_softc_t
* const sc
);
386 void (*bd_media_select
)(tulip_softc_t
* const sc
);
387 void (*bd_media_poll
)(tulip_softc_t
* const sc
, tulip_mediapoll_event_t event
);
388 void (*bd_media_preset
)(tulip_softc_t
* const sc
);
389 #if defined(__bsdi__) && _BSDI_VERSION >= 199701
390 struct ifmedia_entry
*bd_media_list
;
392 int bd_media_options_mask
;
397 * The next few declarations are for MII/PHY based board.
399 * The first enumeration identifies a superset of various datums
400 * that can be obtained from various PHY chips. Not all PHYs will
401 * support all datums.
402 * The modedata structure indicates what register contains
403 * a datum, what mask is applied the register contents, and what the
405 * The attr structure records information about a supported PHY.
406 * The phy structure records information about a PHY instance.
421 } tulip_phy_modedata_t
;
425 u_int16_t attr_flags
;
426 #define PHY_NEED_HARD_RESET 0x0001
427 #define PHY_DUAL_CYCLE_TA 0x0002
428 tulip_phy_modedata_t attr_modes
[PHY_MODE_MAX
];
430 const char *attr_name
;
435 * Various probe states used when trying to autosense the media.
439 TULIP_PROBE_INACTIVE
,
440 TULIP_PROBE_PHYRESET
,
441 TULIP_PROBE_PHYAUTONEG
,
443 TULIP_PROBE_MEDIATEST
,
445 } tulip_probe_state_t
;
449 * Transmit Statistics
451 u_int32_t dot3StatsSingleCollisionFrames
;
452 u_int32_t dot3StatsMultipleCollisionFrames
;
453 u_int32_t dot3StatsSQETestErrors
;
454 u_int32_t dot3StatsDeferredTransmissions
;
455 u_int32_t dot3StatsLateCollisions
;
456 u_int32_t dot3StatsExcessiveCollisions
;
457 u_int32_t dot3StatsCarrierSenseErrors
;
458 u_int32_t dot3StatsInternalMacTransmitErrors
;
459 u_int32_t dot3StatsInternalTransmitUnderflows
; /* not in rfc1650! */
460 u_int32_t dot3StatsInternalTransmitBabbles
; /* not in rfc1650! */
464 u_int32_t dot3StatsMissedFrames
; /* not in rfc1650! */
465 u_int32_t dot3StatsAlignmentErrors
;
466 u_int32_t dot3StatsFCSErrors
;
467 u_int32_t dot3StatsFrameTooLongs
;
468 u_int32_t dot3StatsInternalMacReceiveErrors
;
469 } tulip_dot3_stats_t
;
472 * Now to important stuff. This is softc structure (where does softc
473 * come from??? No idea) for the tulip device.
476 struct _tulip_softc_t
{
477 #if defined(__bsdi__)
478 struct device tulip_dev
; /* base device */
479 struct isadev tulip_id
; /* ISA device */
480 struct intrhand tulip_ih
; /* intrrupt vectoring */
481 struct atshutdown tulip_ats
; /* shutdown hook */
482 #if _BSDI_VERSION < 199401
483 void *tulip_bpf
; /* for BPF */
485 prf_t tulip_pf
; /* printf function */
486 #if _BSDI_VERSION >= 199701
487 struct mii_data tulip_mii
; /* Generic MII and media data */
488 #define tulip_ifmedia tulip_mii.mii_media
489 #endif /* _BSDI_VERSION >= 199701 */
490 #endif /* _BSDI_VERSION < 199401 */
491 #endif /* __bsdi__ */
492 #if defined(__NetBSD__)
493 struct device tulip_dev
; /* base device */
494 void *tulip_ih
; /* intrrupt vectoring */
495 void *tulip_ats
; /* shutdown hook */
496 struct callout tulip_to_ch
; /* tulip_timeout_callback() */
497 struct callout tulip_fto_ch
; /* tulip_fasttimeout_callback() */
498 bus_space_tag_t tulip_bustag
;
499 bus_space_handle_t tulip_bushandle
; /* CSR region handle */
500 pci_chipset_tag_t tulip_pc
;
501 struct ethercom tulip_ec
;
502 u_int8_t tulip_enaddr
[ETHER_ADDR_LEN
];
504 #if !defined(tulip_ifmedia) && defined(IFM_ETHER)
505 struct ifmedia tulip_ifmedia
;
507 #if defined(TULIP_BUS_DMA)
508 bus_dma_tag_t tulip_dmatag
; /* bus DMA tag */
509 #if !defined(TULIP_BUS_DMA_NOTX)
510 bus_dmamap_t tulip_setupmap
;
511 bus_dmamap_t tulip_txdescmap
;
512 bus_dmamap_t tulip_free_txmaps
[TULIP_TXDESCS
];
513 unsigned tulip_num_free_txmaps
;
515 #if !defined(TULIP_BUS_DMA_NORX)
516 bus_dmamap_t tulip_rxdescmap
;
517 bus_dmamap_t tulip_free_rxmaps
[TULIP_RXDESCS
];
518 unsigned tulip_num_free_rxmaps
;
521 #if !defined(__NetBSD__)
522 struct arpcom tulip_ac
;
524 tulip_regfile_t tulip_csrs
;
525 u_int32_t tulip_flags
;
526 #define TULIP_WANTSETUP 0x00000001
527 #define TULIP_WANTHASHPERFECT 0x00000002
528 #define TULIP_WANTHASHONLY 0x00000004
529 #define TULIP_DOINGSETUP 0x00000008
530 #define TULIP_PRINTMEDIA 0x00000010
531 #define TULIP_TXPROBE_ACTIVE 0x00000020
532 #define TULIP_ALLMULTI 0x00000040
533 #define TULIP_WANTRXACT 0x00000080
534 #define TULIP_RXACT 0x00000100
535 #define TULIP_INRESET 0x00000200
536 #define TULIP_NEEDRESET 0x00000400
537 #define TULIP_SQETEST 0x00000800
538 #define TULIP_FULLDUPLEX 0x00001000
539 #define TULIP_xxxxxx1 0x00002000
540 #define TULIP_WANTTXSTART 0x00004000
541 #define TULIP_NEWTXTHRESH 0x00008000
542 #define TULIP_NOAUTOSENSE 0x00010000
543 #define TULIP_PRINTLINKUP 0x00020000
544 #define TULIP_LINKUP 0x00040000
545 #define TULIP_RXBUFSLOW 0x00080000
546 #define TULIP_NOMESSAGES 0x00100000
547 #define TULIP_SYSTEMERROR 0x00200000
548 #define TULIP_TIMEOUTPENDING 0x00400000
549 #define TULIP_xxxxxx2 0x00800000
550 #define TULIP_TRYNWAY 0x01000000
551 #define TULIP_DIDNWAY 0x02000000
552 #define TULIP_RXIGNORE 0x04000000
553 #define TULIP_PROBE1STPASS 0x08000000
554 #define TULIP_DEVICEPROBE 0x10000000
555 #define TULIP_PROMISC 0x20000000
556 #define TULIP_HASHONLY 0x40000000
557 #define TULIP_xxxxxx3 0x80000000
558 /* only 4 bits left! */
559 u_int32_t tulip_features
; /* static bits indicating features of chip */
560 #define TULIP_HAVE_GPR 0x00000001 /* have gp register (140[A]) */
561 #define TULIP_HAVE_RXBADOVRFLW 0x00000002 /* RX corrupts on overflow */
562 #define TULIP_HAVE_POWERMGMT 0x00000004 /* Snooze/sleep modes */
563 #define TULIP_HAVE_MII 0x00000008 /* Some medium on MII */
564 #define TULIP_HAVE_SIANWAY 0x00000010 /* SIA does NWAY */
565 #define TULIP_HAVE_DUALSENSE 0x00000020 /* SIA senses both AUI & TP */
566 #define TULIP_HAVE_SIAGP 0x00000040 /* SIA has a GP port */
567 #define TULIP_HAVE_BROKEN_HASH 0x00000080 /* Broken Multicast Hash */
568 #define TULIP_HAVE_ISVSROM 0x00000100 /* uses ISV SROM Format */
569 #define TULIP_HAVE_BASEROM 0x00000200 /* Board ROM can be cloned */
570 #define TULIP_HAVE_SLAVEDROM 0x00000400 /* Board ROM cloned */
571 #define TULIP_HAVE_SLAVEDINTR 0x00000800 /* Board slaved interrupt */
572 #define TULIP_HAVE_SHAREDINTR 0x00001000 /* Board shares interrupts */
573 #define TULIP_HAVE_OKROM 0x00002000 /* ROM was recognized */
574 #define TULIP_HAVE_NOMEDIA 0x00004000 /* did not detect any media */
575 #define TULIP_HAVE_STOREFWD 0x00008000 /* have CMD_STOREFWD */
576 #define TULIP_HAVE_SIA100 0x00010000 /* has LS100 in SIA status */
577 #define TULIP_HAVE_OKSROM 0x00020000 /* SROM CRC is OK */
578 u_int32_t tulip_intrmask
; /* our copy of csr_intr */
579 u_int32_t tulip_cmdmode
; /* our copy of csr_cmdmode */
580 u_int32_t tulip_last_system_error
: 3; /* last system error (only value is TULIP_SYSTEMERROR is also set) */
581 u_int32_t tulip_txtimer
; /* transmission timer */
582 u_int32_t tulip_system_errors
; /* number of system errors encountered */
583 u_int32_t tulip_statusbits
; /* status bits from CSR5 that may need to be printed */
585 tulip_media_info_t
*tulip_mediums
[TULIP_MEDIA_MAX
]; /* indexes into mediainfo */
586 tulip_media_t tulip_media
; /* current media type */
587 u_int32_t tulip_abilities
; /* remote system's abiltities (as defined in IEEE 802.3u) */
589 u_int8_t tulip_revinfo
; /* revision of chip */
590 u_int8_t tulip_phyaddr
; /* 0..31 -- address of current phy */
591 u_int8_t tulip_gpinit
; /* active pins on 21140 */
592 u_int8_t tulip_gpdata
; /* default gpdata for 21140 */
595 u_int8_t probe_count
; /* count of probe operations */
596 int32_t probe_timeout
; /* time in ms of probe timeout */
597 tulip_probe_state_t probe_state
; /* current media probe state */
598 tulip_media_t probe_media
; /* current media being probed */
599 u_int32_t probe_mediamask
; /* medias checked */
600 u_int32_t probe_passes
; /* times autosense failed */
601 u_int32_t probe_txprobes
; /* txprobes attempted */
603 #define tulip_probe_count tulip_probe.probe_count
604 #define tulip_probe_timeout tulip_probe.probe_timeout
605 #define tulip_probe_state tulip_probe.probe_state
606 #define tulip_probe_media tulip_probe.probe_media
607 #define tulip_probe_mediamask tulip_probe.probe_mediamask
608 #define tulip_probe_passes tulip_probe.probe_passes
610 tulip_chipid_t tulip_chipid
; /* type of chip we are using */
611 const tulip_boardsw_t
*tulip_boardsw
; /* board/chip characteristics */
612 tulip_softc_t
*tulip_slaves
; /* slaved devices (ZX3xx) */
613 #if defined(TULIP_DEBUG)
615 * Debugging/Statistical information
618 tulip_media_t dbg_last_media
;
620 u_int32_t dbg_media_probes
;
621 u_int32_t dbg_txprobe_nocarr
;
622 u_int32_t dbg_txprobe_exccoll
;
623 u_int32_t dbg_link_downed
;
624 u_int32_t dbg_link_suspected
;
625 u_int32_t dbg_link_intrs
;
626 u_int32_t dbg_link_pollintrs
;
627 u_int32_t dbg_link_failures
;
628 u_int32_t dbg_nway_starts
;
629 u_int32_t dbg_nway_failures
;
630 u_int16_t dbg_phyregs
[32][4];
631 u_int32_t dbg_rxlowbufs
;
632 u_int32_t dbg_rxintrs
;
633 u_int32_t dbg_last_rxintrs
;
634 u_int32_t dbg_high_rxintrs_hz
;
635 u_int32_t dbg_no_txmaps
;
636 u_int32_t dbg_txput_finishes
[8];
637 u_int32_t dbg_txprobes_ok
[TULIP_MEDIA_MAX
];
638 u_int32_t dbg_txprobes_failed
[TULIP_MEDIA_MAX
];
639 u_int32_t dbg_events
[TULIP_MEDIAPOLL_MAX
];
640 u_int32_t dbg_rxpktsperintr
[TULIP_RXDESCS
];
643 #if defined(TULIP_PERFSTATS)
644 #define TULIP_PERF_CURRENT 0
645 #define TULIP_PERF_PREVIOUS 1
646 #define TULIP_PERF_TOTAL 2
647 #define TULIP_PERF_MAX 3
648 struct tulip_perfstats
{
649 u_quad_t perf_intr_cycles
;
650 u_quad_t perf_ifstart_cycles
;
651 u_quad_t perf_ifstart_one_cycles
;
652 u_quad_t perf_ifioctl_cycles
;
653 u_quad_t perf_ifwatchdog_cycles
;
654 u_quad_t perf_timeout_cycles
;
655 u_quad_t perf_txput_cycles
;
656 u_quad_t perf_txintr_cycles
;
657 u_quad_t perf_rxintr_cycles
;
658 u_quad_t perf_rxget_cycles
;
660 unsigned perf_ifstart
;
661 unsigned perf_ifstart_one
;
662 unsigned perf_ifioctl
;
663 unsigned perf_ifwatchdog
;
664 unsigned perf_timeout
;
666 unsigned perf_txintr
;
667 unsigned perf_rxintr
;
669 } tulip_perfstats
[TULIP_PERF_MAX
];
670 #define tulip_curperfstats tulip_perfstats[TULIP_PERF_CURRENT]
672 struct ifqueue tulip_txq
;
673 struct ifqueue tulip_rxq
;
674 tulip_dot3_stats_t tulip_dot3stats
;
675 tulip_ringinfo_t tulip_rxinfo
;
676 tulip_ringinfo_t tulip_txinfo
;
677 tulip_media_info_t tulip_mediainfo
[10];
679 * The setup buffers for sending the setup frame to the chip.
680 * one is the one being sent while the other is the one being
683 u_int32_t tulip_setupbuf
[192/sizeof(u_int32_t
)];
684 u_int32_t tulip_setupdata
[192/sizeof(u_int32_t
)];
685 char tulip_boardid
[16]; /* buffer for board ID */
686 u_int8_t tulip_rombuf
[128];
687 #if defined(__NetBSD__)
688 device_t tulip_pci_busno
; /* needed for multiport boards */
690 u_int8_t tulip_pci_busno
; /* needed for multiport boards */
692 u_int8_t tulip_pci_devno
; /* needed for multiport boards */
693 u_int8_t tulip_connidx
;
694 tulip_srom_connection_t tulip_conntype
;
695 tulip_desc_t
*tulip_rxdescs
;
696 tulip_desc_t
*tulip_txdescs
;
697 #if defined(__NetBSD__) && NRND > 0
698 rndsource_element_t tulip_rndsource
;
702 #if defined(IFM_ETHER)
703 #define TULIP_DO_AUTOSENSE(sc) (IFM_SUBTYPE((sc)->tulip_ifmedia.ifm_media) == IFM_AUTO)
705 #define TULIP_DO_AUTOSENSE(sc) (((sc)->tulip_flags & TULIP_NOAUTOSENSE) == 0)
709 #if defined(TULIP_HDR_DATA)
710 static const char * const tulip_chipdescs
[] = {
712 #if defined(TULIP_EISA)
718 "21140 [10-100Mb/s]",
719 "21140A [10-100Mb/s]",
720 "21142 [10-100Mb/s]",
721 "21143 [10-100Mb/s]",
724 static const char * const tulip_mediums
[] = {
725 "unknown", /* TULIP_MEDIA_UNKNOWN */
726 "10baseT", /* TULIP_MEDIA_10BASET */
727 "Full Duplex 10baseT", /* TULIP_MEDIA_10BASET_FD */
728 "BNC", /* TULIP_MEDIA_BNC */
729 "AUI", /* TULIP_MEDIA_AUI */
730 "External SIA", /* TULIP_MEDIA_EXTSIA */
731 "AUI/BNC", /* TULIP_MEDIA_AUIBNC */
732 "100baseTX", /* TULIP_MEDIA_100BASET */
733 "Full Duplex 100baseTX", /* TULIP_MEDIA_100BASET_FD */
734 "100baseT4", /* TULIP_MEDIA_100BASET4 */
735 "100baseFX", /* TULIP_MEDIA_100BASEFX */
736 "Full Duplex 100baseFX", /* TULIP_MEDIA_100BASEFX_FD */
739 #if defined(IFM_ETHER)
740 static const int tulip_media_to_ifmedia
[] = {
741 IFM_ETHER
| IFM_NONE
, /* TULIP_MEDIA_UNKNOWN */
742 IFM_ETHER
| IFM_10_T
, /* TULIP_MEDIA_10BASET */
743 IFM_ETHER
| IFM_10_T
| IFM_FDX
, /* TULIP_MEDIA_10BASET_FD */
744 IFM_ETHER
| IFM_10_2
, /* TULIP_MEDIA_BNC */
745 IFM_ETHER
| IFM_10_5
, /* TULIP_MEDIA_AUI */
746 IFM_ETHER
| IFM_MANUAL
, /* TULIP_MEDIA_EXTSIA */
747 IFM_ETHER
| IFM_10_5
, /* TULIP_MEDIA_AUIBNC */
748 IFM_ETHER
| IFM_100_TX
, /* TULIP_MEDIA_100BASET */
749 IFM_ETHER
| IFM_100_TX
| IFM_FDX
, /* TULIP_MEDIA_100BASET_FD */
750 IFM_ETHER
| IFM_100_T4
, /* TULIP_MEDIA_100BASET4 */
751 IFM_ETHER
| IFM_100_FX
, /* TULIP_MEDIA_100BASEFX */
752 IFM_ETHER
| IFM_100_FX
| IFM_FDX
, /* TULIP_MEDIA_100BASEFX_FD */
754 #endif /* defined(IFM_ETHER) */
756 static const char * const tulip_system_errors
[] = {
767 static const char * const tulip_status_bits
[] = {
769 "transmit process stopped",
771 "transmit jabber timeout",
774 "transmit underflow",
778 "receive process stopped",
779 "receive watchdog timeout",
788 static const struct {
789 tulip_srom_connection_t sc_type
;
790 tulip_media_t sc_media
;
792 } tulip_srom_conninfo
[] = {
793 { .sc_type
= TULIP_SROM_CONNTYPE_10BASET
,
794 .sc_media
= TULIP_MEDIA_10BASET
},
795 { .sc_type
= TULIP_SROM_CONNTYPE_BNC
,
796 .sc_media
= TULIP_MEDIA_BNC
},
797 { .sc_type
= TULIP_SROM_CONNTYPE_AUI
,
798 .sc_media
= TULIP_MEDIA_AUI
},
799 { .sc_type
= TULIP_SROM_CONNTYPE_100BASETX
,
800 .sc_media
= TULIP_MEDIA_100BASETX
},
801 { .sc_type
= TULIP_SROM_CONNTYPE_100BASET4
,
802 .sc_media
= TULIP_MEDIA_100BASET4
},
803 { .sc_type
= TULIP_SROM_CONNTYPE_100BASEFX
,
804 .sc_media
= TULIP_MEDIA_100BASEFX
},
805 { .sc_type
= TULIP_SROM_CONNTYPE_MII_10BASET
,
806 .sc_media
= TULIP_MEDIA_10BASET
,
807 .sc_attrs
= TULIP_SROM_ATTR_MII
},
808 { .sc_type
= TULIP_SROM_CONNTYPE_MII_100BASETX
,
809 .sc_media
= TULIP_MEDIA_100BASETX
,
810 .sc_attrs
= TULIP_SROM_ATTR_MII
},
811 { .sc_type
= TULIP_SROM_CONNTYPE_MII_100BASET4
,
812 .sc_media
= TULIP_MEDIA_100BASET4
,
813 .sc_attrs
= TULIP_SROM_ATTR_MII
},
814 { .sc_type
= TULIP_SROM_CONNTYPE_MII_100BASEFX
,
815 .sc_media
= TULIP_MEDIA_100BASEFX
,
816 .sc_attrs
= TULIP_SROM_ATTR_MII
},
817 { .sc_type
= TULIP_SROM_CONNTYPE_10BASET_NWAY
,
818 .sc_media
= TULIP_MEDIA_10BASET
,
819 .sc_attrs
= TULIP_SROM_ATTR_NWAY
},
820 { .sc_type
= TULIP_SROM_CONNTYPE_10BASET_FD
,
821 .sc_media
= TULIP_MEDIA_10BASET_FD
},
822 { .sc_type
= TULIP_SROM_CONNTYPE_MII_10BASET_FD
,
823 .sc_media
= TULIP_MEDIA_10BASET_FD
,
824 .sc_attrs
= TULIP_SROM_ATTR_MII
},
825 { .sc_type
= TULIP_SROM_CONNTYPE_100BASETX_FD
,
826 .sc_media
= TULIP_MEDIA_100BASETX_FD
},
827 { .sc_type
= TULIP_SROM_CONNTYPE_MII_100BASETX_FD
,
828 .sc_media
= TULIP_MEDIA_100BASETX_FD
,
829 .sc_attrs
= TULIP_SROM_ATTR_MII
},
830 { .sc_type
= TULIP_SROM_CONNTYPE_10BASET_NOLINKPASS
,
831 .sc_media
= TULIP_MEDIA_10BASET
,
832 .sc_attrs
= TULIP_SROM_ATTR_NOLINKPASS
},
833 { .sc_type
= TULIP_SROM_CONNTYPE_AUTOSENSE
,
834 .sc_media
= TULIP_MEDIA_UNKNOWN
,
835 .sc_attrs
= TULIP_SROM_ATTR_AUTOSENSE
},
836 { .sc_type
= TULIP_SROM_CONNTYPE_AUTOSENSE_POWERUP
,
837 .sc_media
= TULIP_MEDIA_UNKNOWN
,
838 .sc_attrs
= TULIP_SROM_ATTR_AUTOSENSE
|TULIP_SROM_ATTR_POWERUP
},
839 { .sc_type
= TULIP_SROM_CONNTYPE_AUTOSENSE_NWAY
,
840 .sc_media
= TULIP_MEDIA_UNKNOWN
,
841 .sc_attrs
= TULIP_SROM_ATTR_AUTOSENSE
|TULIP_SROM_ATTR_NWAY
},
842 { .sc_type
= TULIP_SROM_CONNTYPE_NOT_USED
,
843 .sc_media
= TULIP_MEDIA_UNKNOWN
}
845 #define TULIP_SROM_LASTCONNIDX \
846 (sizeof(tulip_srom_conninfo)/sizeof(tulip_srom_conninfo[0]) - 1)
848 static const struct {
849 tulip_media_t sm_type
;
850 tulip_srom_media_t sm_srom_type
;
851 } tulip_srom_mediums
[] = {
852 { TULIP_MEDIA_100BASEFX_FD
, TULIP_SROM_MEDIA_100BASEFX_FD
},
853 { TULIP_MEDIA_100BASEFX
, TULIP_SROM_MEDIA_100BASEFX
},
854 { TULIP_MEDIA_100BASET4
, TULIP_SROM_MEDIA_100BASET4
},
855 { TULIP_MEDIA_100BASETX_FD
, TULIP_SROM_MEDIA_100BASETX_FD
},
856 { TULIP_MEDIA_100BASETX
, TULIP_SROM_MEDIA_100BASETX
},
857 { TULIP_MEDIA_10BASET_FD
, TULIP_SROM_MEDIA_10BASET_FD
},
858 { TULIP_MEDIA_AUI
, TULIP_SROM_MEDIA_AUI
},
859 { TULIP_MEDIA_BNC
, TULIP_SROM_MEDIA_BNC
},
860 { TULIP_MEDIA_10BASET
, TULIP_SROM_MEDIA_10BASET
},
861 { .sm_type
= TULIP_MEDIA_UNKNOWN
}
863 #endif /* TULIP_HDR_DATA */
866 * This driver supports a maximum of 32 tulip boards.
867 * This should be enough for the forseeable future.
869 #define TULIP_MAX_DEVICES 32
871 #if defined(TULIP_USE_SOFTINTR) && defined(TULIP_HDR_DATA)
872 static u_int32_t tulip_softintr_mask
;
873 static int tulip_softintr_last_unit
;
874 static int tulip_softintr_max_unit
;
875 static void tulip_softintr(void);
878 #if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NORX)
879 #define TULIP_RXDESC_PRESYNC(sc, di, s) \
880 bus_dmamap_sync((sc)->tulip_dmatag, (sc)->tulip_rxdescmap, \
881 (char *) di - (char *) (sc)->tulip_rxdescs, \
882 (s), BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)
883 #define TULIP_RXDESC_POSTSYNC(sc, di, s) \
884 bus_dmamap_sync((sc)->tulip_dmatag, (sc)->tulip_rxdescmap, \
885 (char *) di - (char *) (sc)->tulip_rxdescs, \
886 (s), BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)
887 #define TULIP_RXMAP_PRESYNC(sc, map) \
888 bus_dmamap_sync((sc)->tulip_dmatag, (map), 0, (map)->dm_mapsize, \
889 BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)
890 #define TULIP_RXMAP_POSTSYNC(sc, map) \
891 bus_dmamap_sync((sc)->tulip_dmatag, (map), 0, (map)->dm_mapsize, \
892 BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)
893 #define TULIP_RXMAP_CREATE(sc, mapp) \
894 bus_dmamap_create((sc)->tulip_dmatag, TULIP_RX_BUFLEN, 2, \
895 TULIP_DATA_PER_DESC, 0, \
896 BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW, (mapp))
898 #define TULIP_RXDESC_PRESYNC(sc, di, s) do { } while (0)
899 #define TULIP_RXDESC_POSTSYNC(sc, di, s) do { } while (0)
900 #define TULIP_RXMAP_PRESYNC(sc, map) do { } while (0)
901 #define TULIP_RXMAP_POSTSYNC(sc, map) do { } while (0)
902 #define TULIP_RXMAP_CREATE(sc, mapp) do { } while (0)
905 #if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NOTX)
906 #define TULIP_TXDESC_PRESYNC(sc, di, s) \
907 bus_dmamap_sync((sc)->tulip_dmatag, (sc)->tulip_txdescmap, \
908 (char *) di - (char *) (sc)->tulip_txdescs, \
909 (s), BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)
910 #define TULIP_TXDESC_POSTSYNC(sc, di, s) \
911 bus_dmamap_sync((sc)->tulip_dmatag, (sc)->tulip_txdescmap, \
912 (char *) di - (char *) (sc)->tulip_txdescs, \
913 (s), BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)
914 #define TULIP_TXMAP_PRESYNC(sc, map) \
915 bus_dmamap_sync((sc)->tulip_dmatag, (map), 0, (map)->dm_mapsize, \
916 BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)
917 #define TULIP_TXMAP_POSTSYNC(sc, map) \
918 bus_dmamap_sync((sc)->tulip_dmatag, (map), 0, (map)->dm_mapsize, \
919 BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)
920 #define TULIP_TXMAP_CREATE(sc, mapp) \
921 bus_dmamap_create((sc)->tulip_dmatag, TULIP_DATA_PER_DESC, \
922 TULIP_MAX_TXSEG, TULIP_DATA_PER_DESC, \
923 0, BUS_DMA_NOWAIT, (mapp))
925 #define TULIP_TXDESC_PRESYNC(sc, di, s) do { } while (0)
926 #define TULIP_TXDESC_POSTSYNC(sc, di, s) do { } while (0)
927 #define TULIP_TXMAP_PRESYNC(sc, map) do { } while (0)
928 #define TULIP_TXMAP_POSTSYNC(sc, map) do { } while (0)
929 #define TULIP_TXMAP_CREATE(sc, mapp) do { } while (0)
933 #define SIOCGADDRROM _IOW('i', 240, struct ifreq) /* get 128 bytes of ROM */
934 #define SIOCGCHIPID _IOWR('i', 241, struct ifreq) /* get chipid */
937 #if defined(__FreeBSD__)
938 #define ifnet_ret_t void
939 typedef int ioctl_cmd_t
;
940 #if defined(TULIP_HDR_DATA)
941 static tulip_softc_t
*tulips
[TULIP_MAX_DEVICES
];
944 #define TULIP_IFP_TO_SOFTC(ifp) ((tulip_softc_t *)((ifp)->if_softc))
946 #define TULIP_BPF_MTAP(sc, m) bpf_mtap(&(sc)->tulip_if, m)
947 #define TULIP_BPF_TAP(sc, p, l) bpf_tap(&(sc)->tulip_if, p, l)
948 #define TULIP_BPF_ATTACH(sc) bpfattach(&(sc)->tulip_if, DLT_EN10MB, sizeof(struct ether_header))
950 #define tulip_intrfunc_t void
951 #define TULIP_VOID_INTRFUNC
952 #define IFF_NOTRAILERS 0
953 #define CLBYTES PAGE_SIZE
955 #define TULIP_KVATOPHYS(sc, va) kvtop(va)
957 #define TULIP_EADDR_FMT "%6D"
958 #define TULIP_EADDR_ARGS(addr) addr, ":"
960 extern int bootverbose
;
961 #define TULIP_IFP_TO_SOFTC(ifp) (TULIP_UNIT_TO_SOFTC((ifp)->if_unit))
962 #include <sys/devconf.h>
963 #define TULIP_DEVCONF
965 #if defined(TULIP_USE_SOFTINTR)
966 NETISR_SET(NETISR_DE
, tulip_softintr
);
968 #define TULIP_UNIT_TO_SOFTC(unit) (tulips[unit])
969 #define TULIP_BURSTSIZE(unit) pci_max_burst_len
970 #define loudprintf if (bootverbose) printf
973 #if defined(__NetBSD__)
974 #define ifnet_ret_t void
975 typedef u_long ioctl_cmd_t
;
976 extern struct cfdriver de_cd
;
977 #define TULIP_UNIT_TO_SOFTC(unit) ((tulip_softc_t *)device_lookup_private(&de_cd,unit))
978 #define TULIP_IFP_TO_SOFTC(ifp) ((tulip_softc_t *)((ifp)->if_softc))
979 #define tulip_unit tulip_dev.dv_unit
980 #define tulip_xname tulip_if.if_xname
981 #define TULIP_RAISESPL() splnet()
982 #define TULIP_RAISESOFTSPL() splsoftnet()
983 #define TULIP_RESTORESPL(s) splx(s)
984 #define tulip_if tulip_ec.ec_if
985 #define tulip_enaddr tulip_enaddr
986 #define tulip_multicnt tulip_ec.ec_multicnt
987 #define TULIP_ETHERCOM(sc) (&(sc)->tulip_ec)
988 #define TULIP_ARP_IFINIT(sc, ifa) arp_ifinit(&(sc)->tulip_if, (ifa))
989 #define TULIP_ETHER_IFATTACH(sc) ether_ifattach(&(sc)->tulip_if, (sc)->tulip_enaddr)
990 #define loudprintf printf
991 #define TULIP_PRINTF_FMT "%s"
992 #define TULIP_PRINTF_ARGS sc->tulip_xname
993 #if !defined(TULIP_BUS_DMA) || defined(TULIP_BUS_DMA_NORX) || defined(TULIP_BUS_DMA_NOTX)
994 #if defined(__alpha__)
995 /* XXX XXX NEED REAL DMA MAPPING SUPPORT XXX XXX */
996 #define TULIP_KVATOPHYS(sc, va) alpha_XXX_dmamap((vaddr_t)(va))
999 #endif /* __NetBSD__ */
1001 #ifndef TULIP_PRINTF_FMT
1002 #define TULIP_PRINTF_FMT "%s%d"
1004 #ifndef TULIP_PRINTF_ARGS
1005 #define TULIP_PRINTF_ARGS sc->tulip_name, sc->tulip_unit
1008 #ifndef TULIP_BURSTSIZE
1009 #define TULIP_BURSTSIZE(unit) 3
1013 #define tulip_if tulip_ac.ac_if
1016 #define tulip_unit tulip_if.if_unit
1018 #define tulip_name tulip_if.if_name
1019 #ifndef tulip_enaddr
1020 #define tulip_enaddr tulip_ac.ac_enaddr
1022 #ifndef tulip_multicnt
1023 #define tulip_multicnt tulip_ac.ac_multicnt
1026 #if !defined(TULIP_ETHERCOM)
1027 #define TULIP_ETHERCOM(sc) (&(sc)->tulip_ac)
1030 #if !defined(TULIP_ARP_IFINIT)
1031 #define TULIP_ARP_IFINIT(sc, ifa) arp_ifinit(TULIP_ETHERCOM(sc), (ifa))
1034 #if !defined(TULIP_ETHER_IFATTACH)
1035 #define TULIP_ETHER_IFATTACH(sc) ether_ifattach(&(sc)->tulip_if)
1038 #if !defined(tulip_bpf) && (!defined(__bsdi__) || _BSDI_VERSION >= 199401)
1039 #define tulip_bpf tulip_if.if_bpf
1042 #if !defined(tulip_intrfunc_t)
1043 #define tulip_intrfunc_t int
1046 #if !defined(TULIP_KVATOPHYS) && (!defined(TULIP_BUS_DMA) || defined(TULIP_BUS_DMA_NORX) || defined(TULIP_BUS_DMA_NOTX))
1047 #define TULIP_KVATOPHYS(sc, va) vtophys(va)
1050 #ifndef TULIP_RAISESPL
1051 #define TULIP_RAISESPL() splimp()
1053 #ifndef TULIP_RAISESOFTSPL
1054 #define TULIP_RAISESOFTSPL() splnet()
1056 #ifndef TULIP_RESTORESPL
1057 #define TULIP_RESTORESPL(s) splx(s)
1061 * While I think FreeBSD's 2.2 change to the bpf is a nice simplification,
1062 * it does add yet more conditional code to this driver. Sigh.
1064 #if !defined(TULIP_BPF_MTAP) && NBPFILTER > 0
1065 #define TULIP_BPF_MTAP(sc, m) bpf_mtap((sc)->tulip_bpf, m)
1066 #define TULIP_BPF_TAP(sc, p, l) bpf_tap((sc)->tulip_bpf, p, l)
1067 #define TULIP_BPF_ATTACH(sc) bpfattach(&(sc)->tulip_bpf, &(sc)->tulip_if, DLT_EN10MB, sizeof(struct ether_header))
1070 #if defined(TULIP_PERFSTATS)
1071 #define TULIP_PERFMERGE(sc, member) \
1072 do { (sc)->tulip_perfstats[TULIP_PERF_TOTAL].member \
1073 += (sc)->tulip_perfstats[TULIP_PERF_CURRENT].member; \
1074 (sc)->tulip_perfstats[TULIP_PERF_PREVIOUS].member \
1075 = (sc)->tulip_perfstats[TULIP_PERF_CURRENT].member; \
1076 (sc)->tulip_perfstats[TULIP_PERF_CURRENT].member = 0; } while (0)
1077 #define TULIP_PERFSTART(name) const tulip_cycle_t perfstart_ ## name = TULIP_PERFREAD();
1078 #define TULIP_PERFEND(name) do { \
1079 (sc)->tulip_curperfstats.perf_ ## name ## _cycles += TULIP_PERFDIFF(perfstart_ ## name, TULIP_PERFREAD()); \
1080 (sc)->tulip_curperfstats.perf_ ## name++; \
1082 #if defined(__i386__)
1083 typedef u_quad_t tulip_cycle_t
;
1084 static __inline tulip_cycle_t
1089 __asm
volatile (".byte 0x0f, 0x31" : "=A" (x
));
1092 #define TULIP_PERFDIFF(s, f) ((f) - (s))
1093 #elif defined(__alpha__)
1094 typedef unsigned long tulip_cycle_t
;
1095 static __inline tulip_cycle_t
1100 __asm
volatile ("rpcc %0" : "=r" (x
));
1103 #define TULIP_PERFDIFF(s, f) ((unsigned int) ((f) - (s)))
1106 #define TULIP_PERFSTART(name)
1107 #define TULIP_PERFEND(name) do { } while (0)
1108 #define TULIP_PERFMERGE(s,n) do { } while (0)
1109 #endif /* TULIP_PERFSTATS */
1112 * However, this change to FreeBSD I am much less enamored with.
1114 #if !defined(TULIP_EADDR_FMT)
1115 #define TULIP_EADDR_FMT "%s"
1116 #define TULIP_EADDR_ARGS(addr) ether_sprintf(addr)
1119 #define TULIP_CRC32_POLY 0xEDB88320UL /* CRC-32 Poly -- Little Endian */
1120 #define TULIP_MAX_TXSEG 30
1122 #define TULIP_ADDREQUAL(a1, a2) \
1123 (((u_int16_t *)a1)[0] == ((u_int16_t *)a2)[0] \
1124 && ((u_int16_t *)a1)[1] == ((u_int16_t *)a2)[1] \
1125 && ((u_int16_t *)a1)[2] == ((u_int16_t *)a2)[2])
1126 #define TULIP_ADDRBRDCST(a1) \
1127 (((u_int16_t *)a1)[0] == 0xFFFFU \
1128 && ((u_int16_t *)a1)[1] == 0xFFFFU \
1129 && ((u_int16_t *)a1)[2] == 0xFFFFU)
1131 typedef int tulip_spl_t
;
1133 #endif /* !defined(_DEVAR_H) */